Compare commits
3 Commits
056ca965b3
...
jwl-dy
| Author | SHA1 | Date | |
|---|---|---|---|
| 6141270437 | |||
|
|
074b53f307 | ||
|
|
ab05529015 |
@@ -7,4 +7,6 @@ VITE_APP_ENV = 'development'
|
|||||||
# 金武联驾校/开发环境
|
# 金武联驾校/开发环境
|
||||||
VITE_APP_BASE_API = 'https://jwl.ahduima.com/'
|
VITE_APP_BASE_API = 'https://jwl.ahduima.com/'
|
||||||
#
|
#
|
||||||
VITE_WEB_BASE_URL = 'https://jwl.ahduima.com'
|
VITE_WEB_BASE_URL = 'https://jwl.ahduima.com'
|
||||||
|
# 资源地址
|
||||||
|
VITE_RESOURSE_URL = 'http://huodong.ahduima.com'
|
||||||
@@ -9,3 +9,6 @@ VITE_APP_BASE_API = 'https://jwl.ahduima.com/'
|
|||||||
|
|
||||||
#
|
#
|
||||||
VITE_WEB_BASE_URL = 'https://jwl.ahduima.com'
|
VITE_WEB_BASE_URL = 'https://jwl.ahduima.com'
|
||||||
|
|
||||||
|
# 资源地址
|
||||||
|
VITE_RESOURSE_URL = 'http://huodong.ahduima.com'
|
||||||
@@ -4,8 +4,10 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:h5": "uni",
|
"dev:h5": "uni",
|
||||||
"dev": "uni -p mp-weixin",
|
"dev": "uni -p mp-weixin",
|
||||||
|
"dev:dy": "uni -p mp-toutiao",
|
||||||
"build:h5": "uni build",
|
"build:h5": "uni build",
|
||||||
"build": "uni build -p mp-weixin",
|
"build": "uni build -p mp-weixin",
|
||||||
|
"build:dy": "uni build -p mp-toutiao",
|
||||||
"build-test:mp-weixin": "uni --mode test -p mp-weixin"
|
"build-test:mp-weixin": "uni --mode test -p mp-weixin"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -14,6 +16,7 @@
|
|||||||
"@dcloudio/uni-components": "3.0.0-alpha-3060420220922001",
|
"@dcloudio/uni-components": "3.0.0-alpha-3060420220922001",
|
||||||
"@dcloudio/uni-h5": "3.0.0-alpha-3060420220922001",
|
"@dcloudio/uni-h5": "3.0.0-alpha-3060420220922001",
|
||||||
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-3060420220922001",
|
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-3060420220922001",
|
||||||
|
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3060420220922001",
|
||||||
"jsencrypt-plus": "^0.1.0",
|
"jsencrypt-plus": "^0.1.0",
|
||||||
"pinia": "2.0.36",
|
"pinia": "2.0.36",
|
||||||
"pinia-plugin-persist-uni": "^1.2.0",
|
"pinia-plugin-persist-uni": "^1.2.0",
|
||||||
|
|||||||
75
src/jtools/api/activity.js
Normal file
75
src/jtools/api/activity.js
Normal file
@@ -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
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ function service(options = {}) {
|
|||||||
useUserStore().logoutWithoutToken()
|
useUserStore().logoutWithoutToken()
|
||||||
//请求成功
|
//请求成功
|
||||||
resolved(res.data);
|
resolved(res.data);
|
||||||
} else if(res.data.code != '0000'&&res.data.code !='4001') {
|
} else if(res.data.code != '0000'&&res.data.code !='4001'&&res.data.code != 200) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res?.data?.message || '访问出错',
|
title: res?.data?.message || '访问出错',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|||||||
@@ -66,7 +66,13 @@
|
|||||||
"usingComponents" : true
|
"usingComponents" : true
|
||||||
},
|
},
|
||||||
"mp-toutiao" : {
|
"mp-toutiao" : {
|
||||||
"usingComponents" : true
|
"usingComponents" : true,
|
||||||
|
"appid" : "ttbbd1cd6c24e1c00801",
|
||||||
|
"setting" : {
|
||||||
|
"es6" : true,
|
||||||
|
"postcss" : true,
|
||||||
|
"minified" : true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"uniStatistics" : {
|
"uniStatistics" : {
|
||||||
"enable" : false
|
"enable" : false
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationBarTitleText": "金武联驾考",
|
||||||
"enablePullDownRefresh": false
|
"enablePullDownRefresh": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<view style="padding-bottom: 50px;background-color: #9e0f00;">
|
<view style="padding-bottom: 50px;background-color: #9e0f00;">
|
||||||
<image class="wp100" mode="widthFix" src="https://jwl-jiakao-bq.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%9B%BE%E7%89%87/ggl_header.png"></image>
|
<image class="wp100" mode="widthFix" src="https://jwl-jiakao-bq.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%9B%BE%E7%89%87/ggl_header.png"></image>
|
||||||
<view class="tip">您今日还剩1次刮奖机会,共有999人参加活动</view>
|
<view class="tip">您今日还剩{{actiNum}}次刮奖机会,共有{{total}}人参加活动</view>
|
||||||
<view class="scraping">
|
<view class="scraping">
|
||||||
<scraping-card :result="result" watermark="刮一刮" title="刮一刮赢取大奖" ref="reset" ></scraping-card>
|
<scraping-card style="z-index: 20;" :result="result" watermark="刮一刮" title="刮一刮赢取大奖" ref="reset" @complete="handleComplete" >
|
||||||
<view v-if="showBtn" class="gj">
|
<cover-view v-if="showBtn" class="gj">
|
||||||
<view class="btn" @tap="handleScrap">
|
<cover-view class="btn" @tap="handleScrap">
|
||||||
点我刮奖
|
{{btnText}}
|
||||||
</view>
|
</cover-view>
|
||||||
</view>
|
</cover-view>
|
||||||
|
</scraping-card>
|
||||||
</view>
|
</view>
|
||||||
<view class="relative mt30 m20lr">
|
<view class="relative mt30 m20lr">
|
||||||
<image class="wp100" mode="widthFix" src="/static/image/index/tip.png"></image>
|
<image class="wp100" mode="widthFix" src="/static/image/index/tip.png"></image>
|
||||||
<view class="title">中奖名单</view>
|
<view class="title">中奖名单</view>
|
||||||
<view class="card">
|
<view class="card">
|
||||||
<view v-for="(item, index) in winningList" :key="index" class="card-item">
|
<view v-for="(item, index) in winningList" :key="index" class="card-item">
|
||||||
<text class="item-text">188****8888</text>
|
<text class="item-text">{{ hidePhoneNumber(item.phone) }}</text>
|
||||||
<text class="item-text">一等奖</text>
|
<text class="item-text">{{ item.awards }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -24,35 +25,113 @@
|
|||||||
<image class="wp100" mode="widthFix" src="/static/image/index/tip.png"></image>
|
<image class="wp100" mode="widthFix" src="/static/image/index/tip.png"></image>
|
||||||
<view class="title">活动说明</view>
|
<view class="title">活动说明</view>
|
||||||
<view class="card">
|
<view class="card">
|
||||||
<view class="item-text">1. 中奖率100%</view>
|
<u-parse :content="activityRule"></u-parse>
|
||||||
<view class="item-text">2. 报名后可获得一次抽奖机会</view>
|
|
||||||
<view class="item-text">3. 中奖用户请于"我的-我的奖品"中查看并核销</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import useUserStore from '@/jtools/store/user'
|
||||||
import ScrapingCard from './scraping.vue'
|
import ScrapingCard from './scraping.vue'
|
||||||
|
import { queryActivityDetail,queryLuckyNum,queryLuckyResult,saveWinner,getLuckyRecord } from '@/jtools/api/activity'
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ScrapingCard
|
ScrapingCard
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
result: '特等奖',
|
detailId: undefined,
|
||||||
|
result: '',
|
||||||
|
btnText: '点我刮奖',
|
||||||
showBtn: true,
|
showBtn: true,
|
||||||
winningList: [1,2,3,4,5,6,7,8]
|
actiNum: 0,
|
||||||
|
total: 0,
|
||||||
|
winningList: [],
|
||||||
|
activityRule: undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onLoad(op) {
|
||||||
|
this.detailId = op.detailId
|
||||||
|
this.getActivityDetail()
|
||||||
|
this.getActivityNum()
|
||||||
|
this.searchWinningList()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleScrap() {
|
handleScrap() {
|
||||||
this.showBtn = !this.showBtn
|
if(!this.actiNum) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '暂无抽奖机会'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
queryLuckyResult({
|
||||||
|
detailId: this.detailId
|
||||||
|
}).then(resp => {
|
||||||
|
if(resp.code == 200) {
|
||||||
|
this.result = resp.msg
|
||||||
|
this.showBtn = !this.showBtn
|
||||||
|
this.$refs.reset.init()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getActivityDetail() {
|
||||||
|
queryActivityDetail({detailId: this.detailId}).then(resp => {
|
||||||
|
if(resp.code == 200) {
|
||||||
|
this.activityRule = resp.data.activity.activityRule
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
hidePhoneNumber(phoneNumber) {
|
||||||
|
// 验证电话号码格式
|
||||||
|
if (!/^\d{11}$/.test(phoneNumber)) {
|
||||||
|
return "无效的电话号码";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 替换中间四位数字为星号
|
||||||
|
return phoneNumber.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
|
||||||
|
},
|
||||||
|
getActivityNum() {
|
||||||
|
queryLuckyNum({
|
||||||
|
detailId: this.detailId,
|
||||||
|
phone: useUserStore().userInfo?.phone || ''
|
||||||
|
}).then(resp => {
|
||||||
|
if(resp.code == 200) {
|
||||||
|
this.actiNum = resp.data.drawNum
|
||||||
|
this.total = resp.data.totalPeople
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
searchWinningList() {
|
||||||
|
getLuckyRecord({
|
||||||
|
detailId: this.detailId,
|
||||||
|
pageSize: 8
|
||||||
|
}).then(resp => {
|
||||||
|
if(resp.code == 200) {
|
||||||
|
this.winningList = resp.rows
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleComplete() {
|
||||||
|
saveWinner({
|
||||||
|
phone: useUserStore().userInfo?.phone || '',
|
||||||
|
detailId: this.detailId,
|
||||||
|
awards: this.result
|
||||||
|
}).then(resp => {
|
||||||
|
this.btnText = '再刮一次!'
|
||||||
|
if(resp.code == 200) {
|
||||||
|
this.getActivityNum()
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: `恭喜获得${this.result}`
|
||||||
|
})
|
||||||
|
this.showBtn = true
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -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 标题配置默认值 **/
|
|
||||||
const TITLE = {
|
|
||||||
text: '刮一刮',
|
|
||||||
fontSize: 16,
|
|
||||||
color: '#333',
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @name 涂层配置默认值
|
|
||||||
* @property { string } color 涂层颜色
|
|
||||||
* @property { number } drawSize 清除涂层的画笔大小
|
|
||||||
*/
|
|
||||||
const MASK = {
|
|
||||||
color: '#DDDDDD',
|
|
||||||
drawSize: 20,
|
|
||||||
}
|
|
||||||
/** @name 容错值,解决部分机型涂层没有覆盖满的情况,主要原因是由于像素尺寸不同导致的,应尽可能让width与height保持整数 **/
|
|
||||||
const TOLERANT = 3;
|
|
||||||
|
|
||||||
let ctx = null;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
/** @name 涂层设置 **/
|
|
||||||
mask: {
|
|
||||||
type: [String, Object],
|
|
||||||
},
|
|
||||||
/** @name 水印设置 **/
|
|
||||||
watermark: {
|
|
||||||
type: [String, Object],
|
|
||||||
},
|
|
||||||
/** @name 提示文字 **/
|
|
||||||
title: {
|
|
||||||
type: [String, Object],
|
|
||||||
},
|
|
||||||
/** @name 刮开百分之多少直接消除图层,为0的时候不消除 **/
|
|
||||||
percentage: {
|
|
||||||
type: Number,
|
|
||||||
default: 60,
|
|
||||||
},
|
|
||||||
result: {
|
|
||||||
type: String,
|
|
||||||
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() {
|
|
||||||
return {
|
|
||||||
...WATERMARK,
|
|
||||||
...(typeof this.watermark === 'object' ? this.watermark : { text: this.watermark }),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
titleSetting() {
|
|
||||||
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 绘制水印 **/
|
|
||||||
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) {
|
|
||||||
// const clearPercent = await this.getClearMaskPercent();
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
async touchend() {
|
|
||||||
if (this.percentage > 0) {
|
|
||||||
const clearPercent = await this.getClearMaskPercent();
|
|
||||||
if (clearPercent >= this.percentage) {
|
|
||||||
ctx.moveTo(0, 0);
|
|
||||||
ctx.clearRect(0, 0, this.width, this.height);
|
|
||||||
ctx.stroke();
|
|
||||||
ctx.draw(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/** @name 计算被清除的涂层百分比 **/
|
|
||||||
getClearMaskPercent() {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
uni.canvasGetImageData({
|
|
||||||
canvasId: 'scraping-happy',
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
width: this.width,
|
|
||||||
height: this.height,
|
|
||||||
success: res => {
|
|
||||||
// 区域内所有点的像素信息,它是一个数组,数组中每 "4" 项表示一个点的 rgba 值
|
|
||||||
const allPointPixels = res.data;
|
|
||||||
// 储存被清除的点-点的透明度
|
|
||||||
const clearPoint = [];
|
|
||||||
// 取透明度来判断,如果透明度值小于一半,则判断为该点已经被清除
|
|
||||||
for (let i = 0; i < allPointPixels.length; i += 4) {
|
|
||||||
if (allPointPixels[i + 3] < 128) {
|
|
||||||
clearPoint.push(allPointPixels[i + 3]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 已被清除的百分比 = 清除的点 / 全部的点
|
|
||||||
const percent = (
|
|
||||||
(clearPoint.length / (allPointPixels.length / 4)) *
|
|
||||||
100
|
|
||||||
).toFixed(2);
|
|
||||||
resolve(percent);
|
|
||||||
},
|
|
||||||
fail: e => {
|
|
||||||
console.log('canvasGetImageData', e);
|
|
||||||
},
|
|
||||||
}, this);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** @name 重置 **/
|
|
||||||
reset() {
|
|
||||||
this.initCanvas();
|
|
||||||
this.touchX = 0;
|
|
||||||
this.touchY = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
/** @name 标题配置默认值 **/
|
||||||
|
const TITLE = {
|
||||||
|
text: '刮一刮',
|
||||||
|
fontSize: 16,
|
||||||
|
color: '#333',
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @name 涂层配置默认值
|
||||||
|
* @property { string } color 涂层颜色
|
||||||
|
* @property { number } drawSize 清除涂层的画笔大小
|
||||||
|
*/
|
||||||
|
const MASK = {
|
||||||
|
color: '#DDDDDD',
|
||||||
|
drawSize: 20,
|
||||||
|
}
|
||||||
|
/** @name 容错值,解决部分机型涂层没有覆盖满的情况,主要原因是由于像素尺寸不同导致的,应尽可能让width与height保持整数 **/
|
||||||
|
const TOLERANT = 3;
|
||||||
|
|
||||||
|
let ctx = null;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
/** @name 涂层设置 **/
|
||||||
|
mask: {
|
||||||
|
type: [String, Object],
|
||||||
|
},
|
||||||
|
/** @name 水印设置 **/
|
||||||
|
watermark: {
|
||||||
|
type: [String, Object],
|
||||||
|
},
|
||||||
|
/** @name 提示文字 **/
|
||||||
|
title: {
|
||||||
|
type: [String, Object],
|
||||||
|
},
|
||||||
|
/** @name 刮开百分之多少直接消除图层,为0的时候不消除 **/
|
||||||
|
percentage: {
|
||||||
|
type: Number,
|
||||||
|
default: 40,
|
||||||
|
},
|
||||||
|
result: {
|
||||||
|
type: String,
|
||||||
|
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() {
|
||||||
|
return {
|
||||||
|
...WATERMARK,
|
||||||
|
...(typeof this.watermark === 'object' ? this.watermark : {
|
||||||
|
text: this.watermark
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
titleSetting() {
|
||||||
|
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 绘制水印 **/
|
||||||
|
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) {
|
||||||
|
// const clearPercent = await this.getClearMaskPercent();
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
async touchend() {
|
||||||
|
if (this.percentage > 0) {
|
||||||
|
const clearPercent = await this.getClearMaskPercent();
|
||||||
|
if (clearPercent >= this.percentage) {
|
||||||
|
ctx.moveTo(0, 0);
|
||||||
|
ctx.clearRect(0, 0, this.width, this.height);
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.draw(true);
|
||||||
|
this.$emit('complete')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** @name 计算被清除的涂层百分比 **/
|
||||||
|
getClearMaskPercent() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
uni.canvasGetImageData({
|
||||||
|
canvasId: 'scraping-happy',
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
width: this.width,
|
||||||
|
height: this.height,
|
||||||
|
success: res => {
|
||||||
|
// 区域内所有点的像素信息,它是一个数组,数组中每 "4" 项表示一个点的 rgba 值
|
||||||
|
const allPointPixels = res.data;
|
||||||
|
// 储存被清除的点-点的透明度
|
||||||
|
const clearPoint = [];
|
||||||
|
// 取透明度来判断,如果透明度值小于一半,则判断为该点已经被清除
|
||||||
|
for (let i = 0; i < allPointPixels.length; i += 4) {
|
||||||
|
if (allPointPixels[i + 3] < 128) {
|
||||||
|
clearPoint.push(allPointPixels[i + 3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 已被清除的百分比 = 清除的点 / 全部的点
|
||||||
|
const percent = (
|
||||||
|
(clearPoint.length / (allPointPixels.length / 4)) *
|
||||||
|
100
|
||||||
|
).toFixed(2);
|
||||||
|
resolve(percent);
|
||||||
|
},
|
||||||
|
fail: e => {
|
||||||
|
console.log('canvasGetImageData', e);
|
||||||
|
},
|
||||||
|
}, this);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** @name 重置 **/
|
||||||
|
reset() {
|
||||||
|
this.initCanvas();
|
||||||
|
this.touchX = 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;
|
||||||
</style>
|
font-weight: bold;
|
||||||
|
letter-spacing: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,137 +1,153 @@
|
|||||||
<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: '',
|
getLoading: true,
|
||||||
categoryList: [],
|
show: false,
|
||||||
rightList: storage.get(`rightList_subject${this.subject}`) || [],
|
subject: storage.get('curSubject') || '1',
|
||||||
wrongList: storage.get(`wrongList_subject${this.subject}`) || [],
|
curTab: 0,
|
||||||
activityList: ['https://cdn.uviewui.com/uview/swiper/swiper1.png']
|
searchValue: '',
|
||||||
};
|
cityName: '',
|
||||||
},
|
categoryList: [],
|
||||||
onShow() {
|
rightList: storage.get(`rightList_subject${this.subject}`) || [],
|
||||||
this.show=true
|
wrongList: storage.get(`wrongList_subject${this.subject}`) || [],
|
||||||
this.getSubjectConfig()
|
activityList: []
|
||||||
if (this.subject == '1' || this.subject == '4') {
|
};
|
||||||
this.rightList = storage.get(`rightList_subject${this.subject}`) || []
|
},
|
||||||
this.wrongList = storage.get(`wrongList_subject${this.subject}`) || []
|
onShow() {
|
||||||
}
|
setTimeout(() => {
|
||||||
if(this.subject=='2'||this.subject=='3'){
|
this.getLoading = false
|
||||||
this.$refs.subjectRef.getDiverType()
|
this.show = true
|
||||||
}
|
}, 100);
|
||||||
},
|
this.getSubjectConfig()
|
||||||
onHide(){
|
if (this.subject == '1' || this.subject == '4') {
|
||||||
this.show=false
|
this.rightList = storage.get(`rightList_subject${this.subject}`) || []
|
||||||
},
|
this.wrongList = storage.get(`wrongList_subject${this.subject}`) || []
|
||||||
computed: {
|
}
|
||||||
...mapState(useQuestionStore, ["loading_subject4", "loading_subject1","curSubject","orderQuestion_subject1","orderQuestion_subject4"]), //映射函数,取出tagslist
|
if (this.subject == '2' || this.subject == '3') {
|
||||||
getLoading() {
|
this.$refs.subjectRef.getDiverType()
|
||||||
return this.loading_subject4 && this.loading_subject1
|
}
|
||||||
}
|
this.queryActivityList()
|
||||||
},
|
},
|
||||||
watch:{
|
onHide() {
|
||||||
getLoading(newVal){
|
this.show = false
|
||||||
if(this.show){
|
},
|
||||||
if(newVal){
|
computed: {
|
||||||
if(this.loading_subject4 && this.loading_subject1){
|
...mapState(useQuestionStore, ["loading_subject4", "loading_subject1", "curSubject", "orderQuestion_subject1",
|
||||||
uni.hideTabBar();
|
"orderQuestion_subject4"
|
||||||
}
|
]), //映射函数,取出tagslist
|
||||||
}else{
|
},
|
||||||
uni.showTabBar()
|
methods: {
|
||||||
}
|
...mapActions(useQuestionStore, ['getOrderQuestion_sub4', 'getOrderQuestion_sub1', 'changeSubject']),
|
||||||
}
|
//获取科目配置
|
||||||
}
|
getSubjectConfig() {
|
||||||
},
|
const carTypeId = storage.get('carType') || '1001'
|
||||||
methods: {
|
querySysConfigList(carTypeId, 'Subject').then(resp => {
|
||||||
...mapActions(useQuestionStore, ['getOrderQuestion_sub4', 'getOrderQuestion_sub1', 'changeSubject']),
|
if (resp.code === '0000') {
|
||||||
//获取科目配置
|
this.categoryList = resp.data.map(item => {
|
||||||
getSubjectConfig() {
|
return {
|
||||||
const carTypeId = storage.get('carType') || '1001'
|
...item,
|
||||||
querySysConfigList(carTypeId, 'Subject').then(resp => {
|
name: item.configItemName
|
||||||
if (resp.code === '0000') {
|
}
|
||||||
this.categoryList = resp.data.map(item => {
|
})
|
||||||
return {
|
this.subject = storage.get('curSubject') || '1',
|
||||||
...item,
|
this.curTab = this.categoryList.findIndex(item => item.configItemCode == this.subject) || 0
|
||||||
name: item.configItemName
|
}
|
||||||
}
|
})
|
||||||
})
|
},
|
||||||
this.subject=storage.get('curSubject') || '1',
|
//切换科目
|
||||||
this.curTab=this.categoryList.findIndex(item=>item.configItemCode==this.subject)
|
async changeCategory(val) {
|
||||||
}
|
this.subject = val.configItemCode
|
||||||
})
|
this.changeSubject(this.subject)
|
||||||
},
|
if (this.subject == '1' || this.subject == '4') {
|
||||||
//切换科目
|
this.rightList = storage.get(`rightList_subject${this.subject}`) || []
|
||||||
async changeCategory(val) {
|
this.wrongList = storage.get(`wrongList_subject${this.subject}`) || []
|
||||||
this.subject = val.configItemCode
|
} else {
|
||||||
this.changeSubject(this.subject)
|
setTimeout(() => {
|
||||||
if (this.subject == '1' || this.subject == '4') {
|
this.$refs.subjectRef.getDiverType()
|
||||||
this.rightList = storage.get(`rightList_subject${this.subject}`) || []
|
}, 100)
|
||||||
this.wrongList = storage.get(`wrongList_subject${this.subject}`) || []
|
}
|
||||||
} else {
|
},
|
||||||
setTimeout(() => {
|
//查询活动列表
|
||||||
this.$refs.subjectRef.getDiverType()
|
queryActivityList() {
|
||||||
}, 100)
|
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>
|
||||||
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<view class="list-call">
|
<view class="list-call">
|
||||||
<u-input class="sl-input" border="none" v-model="login.phone" type="number" maxlength="11"
|
<u-input class="sl-input" border="none" v-model="loginForm.phone" type="number" maxlength="11"
|
||||||
placeholder="输入手机号" />
|
placeholder="输入手机号" />
|
||||||
</view>
|
</view>
|
||||||
<view class="list-call">
|
<view class="list-call">
|
||||||
<u-input class="sl-input" v-model="login.code" type="text" maxlength="6" border="none" placeholder="输入验证码">
|
<u-input class="sl-input" v-model="loginForm.code" type="text" maxlength="6" border="none" placeholder="输入验证码">
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
<text class="fs14 mr10" style="color: #05C341;" @tap="getCode">{{ countDown == 0 ? '获取验证码' : countDown }}</text>
|
<text class="fs14 mr10" style="color: #05C341;" @tap="getCode">{{ countDown == 0 ? '获取验证码' : countDown }}</text>
|
||||||
</template>
|
</template>
|
||||||
@@ -39,7 +39,7 @@ import storage from '@/jtools/storage';
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
login: {
|
loginForm: {
|
||||||
phone: '',
|
phone: '',
|
||||||
code: ''
|
code: ''
|
||||||
},
|
},
|
||||||
@@ -54,9 +54,9 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getCode() {
|
getCode() {
|
||||||
if (isPhone(this.login.phone) && this.countDown == 0) {
|
if (isPhone(this.loginForm.phone) && this.countDown == 0) {
|
||||||
getCode({
|
getCode({
|
||||||
phone: this.login.phone
|
phone: this.loginForm.phone
|
||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
// if (resp.code == '0000') {
|
// if (resp.code == '0000') {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -80,8 +80,8 @@ export default {
|
|||||||
this.countDown = 0
|
this.countDown = 0
|
||||||
},
|
},
|
||||||
bindLogin() {
|
bindLogin() {
|
||||||
if (isPhone(this.login.phone) && this.login.code) {
|
if (isPhone(this.loginForm.phone) && this.loginForm.code) {
|
||||||
let params = { ...this.login }
|
let params = { ...this.loginForm }
|
||||||
if (storage.get('companyId')) {
|
if (storage.get('companyId')) {
|
||||||
params.id = storage.get('companyId')
|
params.id = storage.get('companyId')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="mt5 fs14 cor-666">陪您学车 第{{ user.days }}天</view>
|
<view class="mt5 fs14 cor-666">陪您学车 第{{ user.days }}天</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view v-if="canRecieve" class="ml20 p20" @tap="handleScan">
|
||||||
|
<u-icon name="scan" size="40"></u-icon>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="info flex ai-c" v-else @tap="toLogin">
|
<view class="info flex ai-c" v-else @tap="toLogin">
|
||||||
<u-avatar class="br-p50 overflow-h" :size="64" src="@/static/image/mine/default_avatar.png" shape="circle"></u-avatar>
|
<u-avatar class="br-p50 overflow-h" :size="64" src="@/static/image/mine/default_avatar.png" shape="circle"></u-avatar>
|
||||||
@@ -107,8 +110,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import useUserStore from '@/jtools/store/user'
|
import useUserStore from '@/jtools/store/user'
|
||||||
import storage from '@/jtools/storage';
|
import storage from '@/jtools/storage';
|
||||||
|
import { receiveWinner,canRecieveGift } from '@/jtools/api/activity'
|
||||||
export default {
|
export default {
|
||||||
components: {},
|
|
||||||
computed: {
|
computed: {
|
||||||
isLogin() {
|
isLogin() {
|
||||||
return useUserStore().isLogin
|
return useUserStore().isLogin
|
||||||
@@ -148,14 +151,25 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
carName: storage.get('carName') || '小车C1/C2/C3',
|
carName: storage.get('carName') || '小车C1/C2/C3',
|
||||||
isIOS: true
|
isIOS: true,
|
||||||
|
canRecieve: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.isIOS = this.$platform.device().includes('ios')
|
this.isIOS = this.$platform.device().includes('ios')
|
||||||
this.carName = storage.get('carName') || '小车C1/C2/C3'
|
this.carName = storage.get('carName') || '小车C1/C2/C3'
|
||||||
|
this.searchActivityAuth()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
searchActivityAuth() {
|
||||||
|
canRecieveGift({
|
||||||
|
phone: useUserStore().userInfo?.phone || ''
|
||||||
|
}).then(resp => {
|
||||||
|
if(resp.code == 200) {
|
||||||
|
this.canRecieve = resp.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
// 拨打电话
|
// 拨打电话
|
||||||
callPhoneNumber() {
|
callPhoneNumber() {
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({
|
||||||
@@ -233,6 +247,25 @@ export default {
|
|||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/me/myGift'
|
url: '/pages/me/myGift'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
handleScan() {
|
||||||
|
uni.scanCode({
|
||||||
|
scanType: ['qrCode'],
|
||||||
|
success(res) {
|
||||||
|
console.log('条码内容:' + res.result);
|
||||||
|
receiveWinner({
|
||||||
|
id: res.result,
|
||||||
|
receiveUser: useUserStore().userInfo?.phone || []
|
||||||
|
}).then(resp => {
|
||||||
|
if(resp.code == 200) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '核销成功!'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,66 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="p10lr p20tb">
|
<view class="p10lr p20tb">
|
||||||
<view v-for="(item, index) in list" :key="index" class="item">
|
<u-list @scrolltolower="loadmore">
|
||||||
<view class="relative">
|
<u-list-item v-for="(item, index) in list" :key="index" class="item">
|
||||||
<img src="/static/image/mine/giftitem.png" style="width: 100%;" mode="widthFix" alt="" />
|
<view class="relative">
|
||||||
<view class="ab_full df ai-c jcc">一等奖</view>
|
<img src="/static/image/mine/giftitem.png" style="width: 100%;" mode="widthFix" alt="" />
|
||||||
</view>
|
<view class="ab_full df ai-c jcc">{{item.awards}}</view>
|
||||||
<view class="df ai-c jcsb p20tb p10lr">
|
|
||||||
<view class="item-label">
|
|
||||||
<view>活动名称:幸运刮刮乐开心赢大奖</view>
|
|
||||||
<view>参与时间:2024-01-01 08:00</view>
|
|
||||||
<view>有效期至:2024-03-01 08:00</view>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="ml20" style="width: 120rpx;">
|
<view class="df ai-c jcsb p20tb p10lr">
|
||||||
<img v-if="index%2==0" src="/static/image/mine/writeoff.png" style="width: 120rpx;height: 120rpx;" />
|
<view class="item-label">
|
||||||
<view v-else class="btn" @tap="handleWriteoff(item)">核销</view>
|
<view>活动名称:{{ item.activityName }}</view>
|
||||||
|
<view>参与时间:{{ item.createTime }}</view>
|
||||||
|
<view>有效期至:{{ item.endTime }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="ml20" style="width: 120rpx;">
|
||||||
|
<img v-if="item.status" src="/static/image/mine/writeoff.png" style="width: 120rpx;height: 120rpx;" />
|
||||||
|
<view v-else class="btn" @tap="handleWriteoff(item)">核销</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</u-list-item>
|
||||||
</view>
|
</u-list>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import useUserStore from '@/jtools/store/user'
|
||||||
|
import { getLuckyRecord } from '@/jtools/api/activity'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
pageNum: 1,
|
||||||
list: []
|
list: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
this.pageNum = 1
|
||||||
|
this.list = []
|
||||||
this.handleSearch()
|
this.handleSearch()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleSearch() {
|
handleSearch() {
|
||||||
this.list = [1,2,3,4,5]
|
getLuckyRecord({
|
||||||
|
phone: useUserStore().userInfo.phone,
|
||||||
|
pageSize: 10,
|
||||||
|
pageNum: this.pageNum
|
||||||
|
}).then(resp => {
|
||||||
|
if(resp.code == 200) {
|
||||||
|
if(resp.rows && resp.rows.length) {
|
||||||
|
this.list = [...this.list, ...resp.rows]
|
||||||
|
} else {
|
||||||
|
this.pageNum = this.pageNum > 1 ? this.pageNum-1 : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
loadmore() {
|
||||||
|
this.handleSearch(this.pageNum++)
|
||||||
},
|
},
|
||||||
handleWriteoff(item) {
|
handleWriteoff(item) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/me/qrCode?item=${item}`
|
url: `/pages/me/qrCode?id=${item.id}`
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="df jcc" style="padding-top: 100px;">
|
<view class="df jcc" style="padding-top: 100px;">
|
||||||
<qrcode value="123" :size="200"/>
|
<qrcode v-if="value" :value="value" :size="200"/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -16,11 +16,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
this.value = option.item
|
this.value = option.id
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user