pull/35/head
parent
056ca965b3
commit
ab05529015
@ -0,0 +1,75 @@ |
|||||||
|
import request from '../request/index.js'; |
||||||
|
|
||||||
|
//查询活动列表
|
||||||
|
export function queryActivityList(data) { |
||||||
|
return request({ |
||||||
|
url: 'activity/applet/activity/list', |
||||||
|
method: 'get', |
||||||
|
data, |
||||||
|
noToken: true |
||||||
|
}); |
||||||
|
} |
||||||
|
//查询活动详情
|
||||||
|
export function queryActivityDetail(data) { |
||||||
|
return request({ |
||||||
|
url: 'activity/applet/activity/detail', |
||||||
|
method: 'get', |
||||||
|
data, |
||||||
|
noToken: true |
||||||
|
}); |
||||||
|
} |
||||||
|
//查询抽奖次数
|
||||||
|
export function queryLuckyNum(data) { |
||||||
|
return request({ |
||||||
|
url: 'activity/applet/activity/lucky/num', |
||||||
|
method: 'get', |
||||||
|
data, |
||||||
|
noToken: true |
||||||
|
}); |
||||||
|
} |
||||||
|
//查询中奖结果
|
||||||
|
export function queryLuckyResult(data) { |
||||||
|
return request({ |
||||||
|
url: 'activity/applet/activity/lucky/result', |
||||||
|
method: 'get', |
||||||
|
data, |
||||||
|
noToken: true |
||||||
|
}); |
||||||
|
} |
||||||
|
//录入中奖结果
|
||||||
|
export function saveWinner(data) { |
||||||
|
return request({ |
||||||
|
url: 'activity/applet/activity/winner/save', |
||||||
|
method: 'POST', |
||||||
|
data, |
||||||
|
noToken: true |
||||||
|
}); |
||||||
|
} |
||||||
|
//核销
|
||||||
|
export function receiveWinner(data) { |
||||||
|
return request({ |
||||||
|
url: 'activity/applet/activity/winner/receive', |
||||||
|
method: 'POST', |
||||||
|
data, |
||||||
|
noToken: true |
||||||
|
}); |
||||||
|
} |
||||||
|
//查询中奖记录
|
||||||
|
export function getLuckyRecord(data) { |
||||||
|
return request({ |
||||||
|
url: 'activity/applet/activity/lucky/record', |
||||||
|
method: 'get', |
||||||
|
data, |
||||||
|
noToken: true |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
//查询中奖记录
|
||||||
|
export function canRecieveGift(data) { |
||||||
|
return request({ |
||||||
|
url: 'activity/applet/activity/receive/user', |
||||||
|
method: 'get', |
||||||
|
data, |
||||||
|
noToken: true |
||||||
|
}); |
||||||
|
} |
@ -1,266 +1,280 @@ |
|||||||
<template> |
<template> |
||||||
<view class="scraping-happy" id="container"> |
<view class="scraping-happy" id="container"> |
||||||
<canvas |
<canvas canvas-id="scraping-happy" class="scraping__canvas" :disable-scroll="true" @touchstart="touchstart" |
||||||
canvas-id="scraping-happy" |
@touchmove="touchmove" @touchend="touchend" /> |
||||||
class="scraping__canvas" |
|
||||||
:disable-scroll="true" |
|
||||||
@touchstart="touchstart" |
|
||||||
@touchmove="touchmove" |
|
||||||
@touchend="touchend" |
|
||||||
/> |
|
||||||
<cover-view class="scraping__view"> |
<cover-view class="scraping__view"> |
||||||
{{ showText }} |
{{ showText }} |
||||||
</cover-view> |
</cover-view> |
||||||
|
<slot></slot> |
||||||
</view> |
</view> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script> |
<script> |
||||||
/** @name 水印配置默认值 **/ |
/** @name 水印配置默认值 **/ |
||||||
const WATERMARK = { |
const WATERMARK = { |
||||||
text: '刮一刮', |
text: '刮一刮', |
||||||
fontSize: 14, |
fontSize: 14, |
||||||
color: '#C5C5C5', |
color: '#C5C5C5', |
||||||
} |
} |
||||||
/** @name 标题配置默认值 **/ |
/** @name 标题配置默认值 **/ |
||||||
const TITLE = { |
const TITLE = { |
||||||
text: '刮一刮', |
text: '刮一刮', |
||||||
fontSize: 16, |
fontSize: 16, |
||||||
color: '#333', |
color: '#333', |
||||||
} |
} |
||||||
/** |
/** |
||||||
* @name 涂层配置默认值 |
* @name 涂层配置默认值 |
||||||
* @property { string } color 涂层颜色 |
* @property { string } color 涂层颜色 |
||||||
* @property { number } drawSize 清除涂层的画笔大小 |
* @property { number } drawSize 清除涂层的画笔大小 |
||||||
*/ |
*/ |
||||||
const MASK = { |
const MASK = { |
||||||
color: '#DDDDDD', |
color: '#DDDDDD', |
||||||
drawSize: 20, |
drawSize: 20, |
||||||
} |
} |
||||||
/** @name 容错值,解决部分机型涂层没有覆盖满的情况,主要原因是由于像素尺寸不同导致的,应尽可能让width与height保持整数 **/ |
/** @name 容错值,解决部分机型涂层没有覆盖满的情况,主要原因是由于像素尺寸不同导致的,应尽可能让width与height保持整数 **/ |
||||||
const TOLERANT = 3; |
const TOLERANT = 3; |
||||||
|
|
||||||
let ctx = null; |
let ctx = null; |
||||||
|
|
||||||
export default { |
export default { |
||||||
props: { |
props: { |
||||||
/** @name 涂层设置 **/ |
/** @name 涂层设置 **/ |
||||||
mask: { |
mask: { |
||||||
type: [String, Object], |
type: [String, Object], |
||||||
}, |
}, |
||||||
/** @name 水印设置 **/ |
/** @name 水印设置 **/ |
||||||
watermark: { |
watermark: { |
||||||
type: [String, Object], |
type: [String, Object], |
||||||
}, |
}, |
||||||
/** @name 提示文字 **/ |
/** @name 提示文字 **/ |
||||||
title: { |
title: { |
||||||
type: [String, Object], |
type: [String, Object], |
||||||
}, |
}, |
||||||
/** @name 刮开百分之多少直接消除图层,为0的时候不消除 **/ |
/** @name 刮开百分之多少直接消除图层,为0的时候不消除 **/ |
||||||
percentage: { |
percentage: { |
||||||
type: Number, |
type: Number, |
||||||
default: 60, |
default: 40, |
||||||
}, |
}, |
||||||
result: { |
result: { |
||||||
type: String, |
type: String, |
||||||
default: '' |
default: '' |
||||||
} |
|
||||||
}, |
|
||||||
data() { |
|
||||||
return { |
|
||||||
width: 0, |
|
||||||
height: 0, |
|
||||||
touchX: 0, |
|
||||||
touchY: 0, |
|
||||||
showText: '' |
|
||||||
} |
|
||||||
}, |
|
||||||
computed: { |
|
||||||
maskSetting() { |
|
||||||
return { |
|
||||||
...MASK, |
|
||||||
...(typeof this.mask === 'object' ? this.mask : { text: this.mask }), |
|
||||||
} |
} |
||||||
}, |
}, |
||||||
watermarkSetting() { |
data() { |
||||||
return { |
return { |
||||||
...WATERMARK, |
width: 0, |
||||||
...(typeof this.watermark === 'object' ? this.watermark : { text: this.watermark }), |
height: 0, |
||||||
}; |
touchX: 0, |
||||||
}, |
touchY: 0, |
||||||
titleSetting() { |
showText: '' |
||||||
return { |
} |
||||||
...TITLE, |
|
||||||
...(typeof this.title === 'object' ? this.title : { text: this.title }), |
|
||||||
}; |
|
||||||
} |
|
||||||
}, |
|
||||||
mounted() { |
|
||||||
// 获取画布实例 |
|
||||||
ctx = uni.createCanvasContext('scraping-happy', this); |
|
||||||
this.init(); |
|
||||||
}, |
|
||||||
methods: { |
|
||||||
/** @name 初始化 **/ |
|
||||||
init() { |
|
||||||
const query = uni.createSelectorQuery().in(this); |
|
||||||
query |
|
||||||
.select('#container') |
|
||||||
.boundingClientRect(({ width, height }) => { |
|
||||||
this.width = width; |
|
||||||
this.height = height; |
|
||||||
setTimeout(() => { |
|
||||||
this.initCanvas(); |
|
||||||
this.showText = this.result |
|
||||||
}, 20) |
|
||||||
}) |
|
||||||
.exec(); |
|
||||||
}, |
|
||||||
/** @name 初始化canvas状态 **/ |
|
||||||
initCanvas() { |
|
||||||
const { width, height } = this; |
|
||||||
// 清空矩形内容 |
|
||||||
ctx.clearRect(0, 0, width, height); |
|
||||||
// 设置画笔颜色 |
|
||||||
ctx.setFillStyle(this.maskSetting.color); |
|
||||||
// 绘制矩形 |
|
||||||
ctx.fillRect(0, 0, width, height + TOLERANT); |
|
||||||
// 绘制水印 |
|
||||||
this.drawWatermark(); |
|
||||||
// 绘制提示文字 |
|
||||||
this.drawTitle(); |
|
||||||
// 绘制到canvas身上 |
|
||||||
ctx.draw(); |
|
||||||
}, |
}, |
||||||
/** @name 绘制水印 **/ |
computed: { |
||||||
drawWatermark() { |
maskSetting() { |
||||||
if (!this.watermarkSetting.text) return; |
return { |
||||||
// 保存当前的绘图上下文 |
...MASK, |
||||||
ctx.save(); |
...(typeof this.mask === 'object' ? this.mask : { |
||||||
// 旋转 |
text: this.mask |
||||||
ctx.rotate((-10 * Math.PI) / 180); |
}), |
||||||
// 水印具体绘制过程 |
|
||||||
const { width, height } = this; |
|
||||||
const watermarkWidth = this.watermarkSetting.text.length * this.watermarkSetting.fontSize; |
|
||||||
let x = 0; |
|
||||||
let y = 0; |
|
||||||
let i = 0; |
|
||||||
while ((x <= width * 5 || y <= height * 5) && i < 300) { |
|
||||||
ctx.setFillStyle(this.watermarkSetting.color); |
|
||||||
ctx.setFontSize(this.watermarkSetting.fontSize); |
|
||||||
ctx.fillText(this.watermarkSetting.text, x, y); |
|
||||||
x += watermarkWidth + watermarkWidth * 1.6; |
|
||||||
if (x > width && y <= height) { |
|
||||||
x = -Math.random() * 100; |
|
||||||
y += this.watermarkSetting.fontSize * 3; |
|
||||||
} |
} |
||||||
i++; |
}, |
||||||
|
watermarkSetting() { |
||||||
|
return { |
||||||
|
...WATERMARK, |
||||||
|
...(typeof this.watermark === 'object' ? this.watermark : { |
||||||
|
text: this.watermark |
||||||
|
}), |
||||||
|
}; |
||||||
|
}, |
||||||
|
titleSetting() { |
||||||
|
return { |
||||||
|
...TITLE, |
||||||
|
...(typeof this.title === 'object' ? this.title : { |
||||||
|
text: this.title |
||||||
|
}), |
||||||
|
}; |
||||||
} |
} |
||||||
ctx.restore(); |
|
||||||
}, |
|
||||||
/** @name 绘制提示文字 **/ |
|
||||||
drawTitle() { |
|
||||||
if (!this.titleSetting.text) return; |
|
||||||
ctx.setTextAlign('center'); |
|
||||||
ctx.setTextBaseline('middle'); |
|
||||||
ctx.setFillStyle(this.titleSetting.color); |
|
||||||
ctx.setFontSize(this.titleSetting.fontSize); |
|
||||||
ctx.fillText(this.titleSetting.text, this.width / 2, this.height / 3); |
|
||||||
}, |
}, |
||||||
/** @name 触摸事件 **/ |
mounted() { |
||||||
touchstart(e) { |
// 获取画布实例 |
||||||
this.touchX = e.touches[0].x; |
ctx = uni.createCanvasContext('scraping-happy', this); |
||||||
this.touchY = e.touches[0].y; |
this.init(); |
||||||
}, |
}, |
||||||
async touchmove(e) { |
methods: { |
||||||
// 把画笔到画布中的指定点 |
/** @name 初始化 **/ |
||||||
ctx.moveTo(this.touchX, this.touchY); |
init() { |
||||||
// 清除涂层 |
const query = uni.createSelectorQuery().in(this); |
||||||
ctx.clearRect(this.touchX, this.touchY, this.maskSetting.drawSize, this.maskSetting.drawSize); |
query |
||||||
ctx.draw(true); |
.select('#container') |
||||||
// 记录移动点位 |
.boundingClientRect(({ |
||||||
this.touchX = e.touches[0].x; |
width, |
||||||
this.touchY = e.touches[0].y; |
height |
||||||
|
}) => { |
||||||
|
this.width = width; |
||||||
|
this.height = height; |
||||||
|
setTimeout(() => { |
||||||
|
this.initCanvas(); |
||||||
|
this.showText = this.result |
||||||
|
}, 20) |
||||||
|
}) |
||||||
|
.exec(); |
||||||
|
}, |
||||||
|
/** @name 初始化canvas状态 **/ |
||||||
|
initCanvas() { |
||||||
|
const { |
||||||
|
width, |
||||||
|
height |
||||||
|
} = this; |
||||||
|
// 清空矩形内容 |
||||||
|
ctx.clearRect(0, 0, width, height); |
||||||
|
// 设置画笔颜色 |
||||||
|
ctx.setFillStyle(this.maskSetting.color); |
||||||
|
// 绘制矩形 |
||||||
|
ctx.fillRect(0, 0, width, height + TOLERANT); |
||||||
|
// 绘制水印 |
||||||
|
this.drawWatermark(); |
||||||
|
// 绘制提示文字 |
||||||
|
this.drawTitle(); |
||||||
|
// 绘制到canvas身上 |
||||||
|
ctx.draw(); |
||||||
|
}, |
||||||
|
/** @name 绘制水印 **/ |
||||||
|
drawWatermark() { |
||||||
|
if (!this.watermarkSetting.text) return; |
||||||
|
// 保存当前的绘图上下文 |
||||||
|
ctx.save(); |
||||||
|
// 旋转 |
||||||
|
ctx.rotate((-10 * Math.PI) / 180); |
||||||
|
// 水印具体绘制过程 |
||||||
|
const { |
||||||
|
width, |
||||||
|
height |
||||||
|
} = this; |
||||||
|
const watermarkWidth = this.watermarkSetting.text.length * this.watermarkSetting.fontSize; |
||||||
|
let x = 0; |
||||||
|
let y = 0; |
||||||
|
let i = 0; |
||||||
|
while ((x <= width * 5 || y <= height * 5) && i < 300) { |
||||||
|
ctx.setFillStyle(this.watermarkSetting.color); |
||||||
|
ctx.setFontSize(this.watermarkSetting.fontSize); |
||||||
|
ctx.fillText(this.watermarkSetting.text, x, y); |
||||||
|
x += watermarkWidth + watermarkWidth * 1.6; |
||||||
|
if (x > width && y <= height) { |
||||||
|
x = -Math.random() * 100; |
||||||
|
y += this.watermarkSetting.fontSize * 3; |
||||||
|
} |
||||||
|
i++; |
||||||
|
} |
||||||
|
ctx.restore(); |
||||||
|
}, |
||||||
|
/** @name 绘制提示文字 **/ |
||||||
|
drawTitle() { |
||||||
|
if (!this.titleSetting.text) return; |
||||||
|
ctx.setTextAlign('center'); |
||||||
|
ctx.setTextBaseline('middle'); |
||||||
|
ctx.setFillStyle(this.titleSetting.color); |
||||||
|
ctx.setFontSize(this.titleSetting.fontSize); |
||||||
|
ctx.fillText(this.titleSetting.text, this.width / 2, this.height / 3); |
||||||
|
}, |
||||||
|
/** @name 触摸事件 **/ |
||||||
|
touchstart(e) { |
||||||
|
this.touchX = e.touches[0].x; |
||||||
|
this.touchY = e.touches[0].y; |
||||||
|
}, |
||||||
|
async touchmove(e) { |
||||||
|
// 把画笔到画布中的指定点 |
||||||
|
ctx.moveTo(this.touchX, this.touchY); |
||||||
|
// 清除涂层 |
||||||
|
ctx.clearRect(this.touchX, this.touchY, this.maskSetting.drawSize, this.maskSetting.drawSize); |
||||||
|
ctx.draw(true); |
||||||
|
// 记录移动点位 |
||||||
|
this.touchX = e.touches[0].x; |
||||||
|
this.touchY = e.touches[0].y; |
||||||
|
|
||||||
// if (this.percentage > 0) { |
// if (this.percentage > 0) { |
||||||
// const clearPercent = await this.getClearMaskPercent(); |
// const clearPercent = await this.getClearMaskPercent(); |
||||||
// } |
// } |
||||||
}, |
}, |
||||||
async touchend() { |
async touchend() { |
||||||
if (this.percentage > 0) { |
if (this.percentage > 0) { |
||||||
const clearPercent = await this.getClearMaskPercent(); |
const clearPercent = await this.getClearMaskPercent(); |
||||||
if (clearPercent >= this.percentage) { |
if (clearPercent >= this.percentage) { |
||||||
ctx.moveTo(0, 0); |
ctx.moveTo(0, 0); |
||||||
ctx.clearRect(0, 0, this.width, this.height); |
ctx.clearRect(0, 0, this.width, this.height); |
||||||
ctx.stroke(); |
ctx.stroke(); |
||||||
ctx.draw(true); |
ctx.draw(true); |
||||||
|
this.$emit('complete') |
||||||
|
} |
||||||
} |
} |
||||||
} |
}, |
||||||
}, |
/** @name 计算被清除的涂层百分比 **/ |
||||||
/** @name 计算被清除的涂层百分比 **/ |
getClearMaskPercent() { |
||||||
getClearMaskPercent() { |
return new Promise(resolve => { |
||||||
return new Promise(resolve => { |
uni.canvasGetImageData({ |
||||||
uni.canvasGetImageData({ |
canvasId: 'scraping-happy', |
||||||
canvasId: 'scraping-happy', |
x: 0, |
||||||
x: 0, |
y: 0, |
||||||
y: 0, |
width: this.width, |
||||||
width: this.width, |
height: this.height, |
||||||
height: this.height, |
success: res => { |
||||||
success: res => { |
// 区域内所有点的像素信息,它是一个数组,数组中每 "4" 项表示一个点的 rgba 值 |
||||||
// 区域内所有点的像素信息,它是一个数组,数组中每 "4" 项表示一个点的 rgba 值 |
const allPointPixels = res.data; |
||||||
const allPointPixels = res.data; |
// 储存被清除的点-点的透明度 |
||||||
// 储存被清除的点-点的透明度 |
const clearPoint = []; |
||||||
const clearPoint = []; |
// 取透明度来判断,如果透明度值小于一半,则判断为该点已经被清除 |
||||||
// 取透明度来判断,如果透明度值小于一半,则判断为该点已经被清除 |
for (let i = 0; i < allPointPixels.length; i += 4) { |
||||||
for (let i = 0; i < allPointPixels.length; i += 4) { |
if (allPointPixels[i + 3] < 128) { |
||||||
if (allPointPixels[i + 3] < 128) { |
clearPoint.push(allPointPixels[i + 3]); |
||||||
clearPoint.push(allPointPixels[i + 3]); |
} |
||||||
} |
} |
||||||
} |
// 已被清除的百分比 = 清除的点 / 全部的点 |
||||||
// 已被清除的百分比 = 清除的点 / 全部的点 |
const percent = ( |
||||||
const percent = ( |
(clearPoint.length / (allPointPixels.length / 4)) * |
||||||
(clearPoint.length / (allPointPixels.length / 4)) * |
100 |
||||||
100 |
).toFixed(2); |
||||||
).toFixed(2); |
resolve(percent); |
||||||
resolve(percent); |
}, |
||||||
}, |
fail: e => { |
||||||
fail: e => { |
console.log('canvasGetImageData', e); |
||||||
console.log('canvasGetImageData', e); |
}, |
||||||
}, |
}, this); |
||||||
}, this); |
}); |
||||||
}); |
}, |
||||||
}, |
/** @name 重置 **/ |
||||||
/** @name 重置 **/ |
reset() { |
||||||
reset() { |
this.initCanvas(); |
||||||
this.initCanvas(); |
this.touchX = 0; |
||||||
this.touchX = 0; |
this.touchY = 0; |
||||||
this.touchY = 0; |
} |
||||||
} |
} |
||||||
} |
}; |
||||||
}; |
|
||||||
</script> |
</script> |
||||||
|
|
||||||
<style> |
<style> |
||||||
.scraping-happy { |
.scraping-happy { |
||||||
width: 100%; |
width: 100%; |
||||||
height: 200rpx; |
height: 200rpx; |
||||||
position: relative; |
position: relative; |
||||||
display: flex; |
display: flex; |
||||||
justify-content: center; |
justify-content: center; |
||||||
align-items: center; |
align-items: center; |
||||||
} |
} |
||||||
.scraping__canvas { |
|
||||||
width: 100%; |
.scraping__canvas { |
||||||
height: 100%; |
width: 100%; |
||||||
position: absolute; |
height: 100%; |
||||||
z-index: 10; |
position: absolute; |
||||||
/* background-color: red; */ |
z-index: 10; |
||||||
display: inline-block; |
/* background-color: red; */ |
||||||
} |
display: inline-block; |
||||||
.scraping__view { |
} |
||||||
position: absolute; |
|
||||||
z-index: 1; |
.scraping__view { |
||||||
color: #f29100; |
position: absolute; |
||||||
font-size: 20px; |
z-index: 1; |
||||||
font-weight: bold; |
color: #f29100; |
||||||
} |
font-size: 20px; |
||||||
|
font-weight: bold; |
||||||
|
letter-spacing: 8px; |
||||||
|
} |
||||||
</style> |
</style> |
@ -1,137 +1,165 @@ |
|||||||
<template> |
<template> |
||||||
<view> |
<view> |
||||||
<view v-if="getLoading" class="wp100 relative" style="height: 100vh;"> |
<view v-if="getLoading" class="wp100 relative" style="height: 100vh;"> |
||||||
<image class="wp100" mode="widthFix" src="https://oss-bq.ahduima.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%9B%BE%E7%89%87/%E8%80%83%E8%AF%95%E6%8F%90%E9%86%92_20230906135037.png"></image> |
<image class="wp100" mode="widthFix" |
||||||
<view class="wp100 flex ai-c jc-c" style="position: absolute;bottom: 0;left: 0;padding-bottom: 124rpx;"> |
src="https://oss-bq.ahduima.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%9B%BE%E7%89%87/%E8%80%83%E8%AF%95%E6%8F%90%E9%86%92_20230906135037.png"> |
||||||
<image style="width: 452rpx;" src="https://oss-bq.ahduima.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%9B%BE%E7%89%87/%E9%87%91%E6%AD%A6%E8%81%94_20230831123333.png" mode="widthFix"></image> |
</image> |
||||||
</view> |
<view class="wp100 flex ai-c jc-c" style="position: absolute;bottom: 0;left: 0;padding-bottom: 124rpx;"> |
||||||
</view> |
<image style="width: 452rpx;" |
||||||
<view v-if="!getLoading"> |
src="https://oss-bq.ahduima.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%9B%BE%E7%89%87/%E9%87%91%E6%AD%A6%E8%81%94_20230831123333.png" |
||||||
<j-navbar :isBack="false">金武联驾考</j-navbar> |
mode="widthFix"></image> |
||||||
<u-sticky bgColor="#fff"> |
|
||||||
<u-tabs :list="categoryList" :current="curTab" :scrollable="false" @change="changeCategory"></u-tabs> |
|
||||||
</u-sticky> |
|
||||||
<view class="m10tb"> |
|
||||||
<u-swiper :list="activityList" @click="handleToActivity"></u-swiper> |
|
||||||
</view> |
</view> |
||||||
<view style="background-color: rgb(245, 245, 245);"> |
</view> |
||||||
<template v-if="subject=='1' || subject=='4'"> |
<view v-if="!getLoading"> |
||||||
<Subject1 :subject="subject" :rightList="rightList" :wrongList="wrongList" /> |
<j-navbar :isBack="false">金武联驾考</j-navbar> |
||||||
</template> |
<u-sticky bgColor="#fff"> |
||||||
<template v-else> |
<u-tabs :list="categoryList" :current="curTab" :scrollable="false" @change="changeCategory"></u-tabs> |
||||||
<Subject2 :subject="subject" ref="subjectRef" /> |
</u-sticky> |
||||||
</template> |
<view class="m10tb" v-if="activityList&&activityList.length"> |
||||||
</view> |
<u-swiper class="acticity" keyName="image" :list="activityList" @click="handleToActivity"></u-swiper> |
||||||
</view> |
</view> |
||||||
</view> |
<view style="background-color: rgb(245, 245, 245);"> |
||||||
|
<template v-if="subject=='1' || subject=='4'"> |
||||||
|
<Subject1 :subject="subject" :rightList="rightList" :wrongList="wrongList" /> |
||||||
|
</template> |
||||||
|
<template v-else> |
||||||
|
<Subject2 :subject="subject" ref="subjectRef" /> |
||||||
|
</template> |
||||||
|
</view> |
||||||
|
</view> |
||||||
|
</view> |
||||||
</template> |
</template> |
||||||
<script> |
<script> |
||||||
import { |
import { |
||||||
mapState, |
mapState, |
||||||
mapActions |
mapActions |
||||||
} from 'pinia' //引入映射函数 |
} from 'pinia' //引入映射函数 |
||||||
import useQuestionStore from '@/jtools/store/question' //引入store |
import useQuestionStore from '@/jtools/store/question' //引入store |
||||||
import storage from '@/jtools/storage'; |
import useUserStore from '@/jtools/store/user' |
||||||
import { |
import storage from '@/jtools/storage'; |
||||||
querySysConfigList, |
import { |
||||||
} from '@/jtools/api/question'; |
querySysConfigList, |
||||||
import Subject1 from "./components/Subject1"; |
} from '@/jtools/api/question'; |
||||||
import Subject2 from "./components/Subject2"; |
import Subject1 from "./components/Subject1"; |
||||||
export default { |
import Subject2 from "./components/Subject2"; |
||||||
components: { |
import { |
||||||
Subject1, |
queryActivityList |
||||||
Subject2 |
} from '@/jtools/api/activity'; |
||||||
}, |
export default { |
||||||
data() { |
components: { |
||||||
return { |
Subject1, |
||||||
show:false, |
Subject2 |
||||||
subject: storage.get('curSubject') || '1', |
}, |
||||||
curTab: 0, |
data() { |
||||||
searchValue: '', |
return { |
||||||
cityName: '', |
show: false, |
||||||
categoryList: [], |
subject: storage.get('curSubject') || '1', |
||||||
rightList: storage.get(`rightList_subject${this.subject}`) || [], |
curTab: 0, |
||||||
wrongList: storage.get(`wrongList_subject${this.subject}`) || [], |
searchValue: '', |
||||||
activityList: ['https://cdn.uviewui.com/uview/swiper/swiper1.png'] |
cityName: '', |
||||||
}; |
categoryList: [], |
||||||
}, |
rightList: storage.get(`rightList_subject${this.subject}`) || [], |
||||||
onShow() { |
wrongList: storage.get(`wrongList_subject${this.subject}`) || [], |
||||||
this.show=true |
activityList: [] |
||||||
this.getSubjectConfig() |
}; |
||||||
if (this.subject == '1' || this.subject == '4') { |
}, |
||||||
this.rightList = storage.get(`rightList_subject${this.subject}`) || [] |
onShow() { |
||||||
this.wrongList = storage.get(`wrongList_subject${this.subject}`) || [] |
this.show = true |
||||||
} |
this.getSubjectConfig() |
||||||
if(this.subject=='2'||this.subject=='3'){ |
if (this.subject == '1' || this.subject == '4') { |
||||||
this.$refs.subjectRef.getDiverType() |
this.rightList = storage.get(`rightList_subject${this.subject}`) || [] |
||||||
} |
this.wrongList = storage.get(`wrongList_subject${this.subject}`) || [] |
||||||
}, |
} |
||||||
onHide(){ |
if (this.subject == '2' || this.subject == '3') { |
||||||
this.show=false |
this.$refs.subjectRef.getDiverType() |
||||||
}, |
} |
||||||
computed: { |
this.queryActivityList() |
||||||
...mapState(useQuestionStore, ["loading_subject4", "loading_subject1","curSubject","orderQuestion_subject1","orderQuestion_subject4"]), //映射函数,取出tagslist |
}, |
||||||
getLoading() { |
onHide() { |
||||||
return this.loading_subject4 && this.loading_subject1 |
this.show = false |
||||||
} |
}, |
||||||
}, |
computed: { |
||||||
watch:{ |
...mapState(useQuestionStore, ["loading_subject4", "loading_subject1", "curSubject", "orderQuestion_subject1", |
||||||
getLoading(newVal){ |
"orderQuestion_subject4" |
||||||
if(this.show){ |
]), //映射函数,取出tagslist |
||||||
if(newVal){ |
getLoading() { |
||||||
if(this.loading_subject4 && this.loading_subject1){ |
return this.loading_subject4 && this.loading_subject1 |
||||||
uni.hideTabBar(); |
} |
||||||
} |
}, |
||||||
}else{ |
watch: { |
||||||
uni.showTabBar() |
getLoading(newVal) { |
||||||
} |
if (this.show) { |
||||||
} |
if (newVal) { |
||||||
} |
if (this.loading_subject4 && this.loading_subject1) { |
||||||
}, |
uni.hideTabBar(); |
||||||
methods: { |
} |
||||||
...mapActions(useQuestionStore, ['getOrderQuestion_sub4', 'getOrderQuestion_sub1', 'changeSubject']), |
} else { |
||||||
//获取科目配置 |
uni.showTabBar() |
||||||
getSubjectConfig() { |
} |
||||||
const carTypeId = storage.get('carType') || '1001' |
} |
||||||
querySysConfigList(carTypeId, 'Subject').then(resp => { |
} |
||||||
if (resp.code === '0000') { |
}, |
||||||
this.categoryList = resp.data.map(item => { |
methods: { |
||||||
return { |
...mapActions(useQuestionStore, ['getOrderQuestion_sub4', 'getOrderQuestion_sub1', 'changeSubject']), |
||||||
...item, |
//获取科目配置 |
||||||
name: item.configItemName |
getSubjectConfig() { |
||||||
} |
const carTypeId = storage.get('carType') || '1001' |
||||||
}) |
querySysConfigList(carTypeId, 'Subject').then(resp => { |
||||||
this.subject=storage.get('curSubject') || '1', |
if (resp.code === '0000') { |
||||||
this.curTab=this.categoryList.findIndex(item=>item.configItemCode==this.subject) |
this.categoryList = resp.data.map(item => { |
||||||
} |
return { |
||||||
}) |
...item, |
||||||
}, |
name: item.configItemName |
||||||
//切换科目 |
} |
||||||
async changeCategory(val) { |
}) |
||||||
this.subject = val.configItemCode |
this.subject = storage.get('curSubject') || '1', |
||||||
this.changeSubject(this.subject) |
this.curTab = this.categoryList.findIndex(item => item.configItemCode == this.subject) |
||||||
if (this.subject == '1' || this.subject == '4') { |
} |
||||||
this.rightList = storage.get(`rightList_subject${this.subject}`) || [] |
}) |
||||||
this.wrongList = storage.get(`wrongList_subject${this.subject}`) || [] |
}, |
||||||
} else { |
//切换科目 |
||||||
setTimeout(() => { |
async changeCategory(val) { |
||||||
this.$refs.subjectRef.getDiverType() |
this.subject = val.configItemCode |
||||||
}, 100) |
this.changeSubject(this.subject) |
||||||
} |
if (this.subject == '1' || this.subject == '4') { |
||||||
}, |
this.rightList = storage.get(`rightList_subject${this.subject}`) || [] |
||||||
|
this.wrongList = storage.get(`wrongList_subject${this.subject}`) || [] |
||||||
|
} else { |
||||||
|
setTimeout(() => { |
||||||
|
this.$refs.subjectRef.getDiverType() |
||||||
|
}, 100) |
||||||
|
} |
||||||
|
}, |
||||||
|
//查询活动列表 |
||||||
|
queryActivityList() { |
||||||
|
queryActivityList({ |
||||||
|
schoolId: useUserStore().userInfo?.schoolId || '' |
||||||
|
}).then(resp => { |
||||||
|
this.activityList = resp.data.map(item => ({ |
||||||
|
...item, |
||||||
|
image: 'https://jwl.ahduima.com' + item.image |
||||||
|
})); |
||||||
|
}) |
||||||
|
}, |
||||||
// 去活动 |
// 去活动 |
||||||
handleToActivity(index) { |
handleToActivity(index) { |
||||||
|
let detailId; |
||||||
|
this.activityList.find((item, index1) => { |
||||||
|
if (index === index1) { |
||||||
|
detailId = item.detailId; |
||||||
|
} |
||||||
|
}) |
||||||
uni.navigateTo({ |
uni.navigateTo({ |
||||||
url: '/pages/index/activity' |
url: '/pages/index/activity?detailId=' + detailId, |
||||||
}) |
}) |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
</script> |
</script> |
||||||
|
|
||||||
<style lang="scss" scoped> |
<style lang="scss" scoped> |
||||||
::v-deep .u-tabs__wrapper__nav__line { |
::v-deep .u-tabs__wrapper__nav__line { |
||||||
background: linear-gradient(90deg, #11DF20 0%, #00B74F 100%) !important; |
background: linear-gradient(90deg, #11DF20 0%, #00B74F 100%) !important; |
||||||
bottom: 14rpx !important; |
bottom: 14rpx !important; |
||||||
} |
} |
||||||
</style> |
</style> |
Loading…
Reference in new issue