|
@@ -34,9 +34,7 @@
|
|
|
</view>
|
|
|
<view class="award-list">
|
|
|
<view v-for="(item,index) in giftList" :key="item.id" class="award-list-item">
|
|
|
- <image
|
|
|
- src="https://oss.productronicachina.com.cn/resources/common/up/0000001002/20250224/67bbd36f30962.png"
|
|
|
- alt="image" mode="widthFix"></image>
|
|
|
+ <image :src="item.picture_url" alt="image" mode="widthFix"></image>
|
|
|
<view class="award-info">
|
|
|
<view class="award-info-title">
|
|
|
{{ item.name }}
|
|
@@ -49,8 +47,8 @@
|
|
|
<mp-html class="award-info-desc" :content="item.description"></mp-html>
|
|
|
</view>
|
|
|
<view class="award-option">
|
|
|
- <view @click="getGift(item)" :class="['award-option-btn',getClass(item)]">
|
|
|
- {{ getText(item) }}
|
|
|
+ <view @click="getGift(item,index)" :class="['award-option-btn',getClass(item,index)]">
|
|
|
+ {{ getText(item, index) }}
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -126,8 +124,7 @@ import UScrollView from "@/components/common/u-scroll-view";
|
|
|
import NewsItem from "@/pages/news/components/news-item";
|
|
|
import DisclaimerText from "@/components/disclaimer-text";
|
|
|
import floatButton from "@/components/layout/float-button";
|
|
|
-import VanDialog from "@/wxcomponents/vant/dialog/dialog.js";
|
|
|
-import {giftList, checkInCount, claim, receiptNote, getActivityInfo, getRouteList} from "@/api/checkIn";
|
|
|
+import {checkInCount, claim, receiptNote, getActivityInfo, getRouteList, getGiftList} from "@/api/checkIn";
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
@@ -141,6 +138,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ activeIndex: null,
|
|
|
awardProgressValue: '0%',
|
|
|
giftList: [],
|
|
|
routes: [],
|
|
@@ -150,7 +148,9 @@ export default {
|
|
|
show_qr: false,
|
|
|
qr_code: '',
|
|
|
check_finish: false,
|
|
|
- current_gift: {},
|
|
|
+ current_gift: {
|
|
|
+
|
|
|
+ },
|
|
|
timer: null,
|
|
|
rule: '',
|
|
|
rule_title: '',
|
|
@@ -163,8 +163,7 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.getGiftList()
|
|
|
- this.getCheckinCount()
|
|
|
+ this.getGiftListEvent()
|
|
|
this.getActiveInfo()
|
|
|
this.getRouteListInfo()
|
|
|
},
|
|
@@ -172,32 +171,38 @@ export default {
|
|
|
clearTimeout(this.timer)
|
|
|
},
|
|
|
computed: {
|
|
|
- getProcess(){
|
|
|
- let subList = []
|
|
|
- for (var i = this.giftList.length-1; i > 0; i--) {
|
|
|
- subList.unshift(this.giftList[i].route_count - this.giftList[i-1].route_count)
|
|
|
- }
|
|
|
- subList.unshift(this.giftList[0].route_count)
|
|
|
-
|
|
|
- let process = 0
|
|
|
- let count = this.checked
|
|
|
- let per_process = 100/this.giftList.length
|
|
|
- subList.forEach(item => {
|
|
|
- if(count>=item){
|
|
|
- count -= item
|
|
|
- process += per_process
|
|
|
- }else{
|
|
|
- process += per_process*(count/item)
|
|
|
- count = 0
|
|
|
- }
|
|
|
- })
|
|
|
- return process+'%'
|
|
|
+ getProcess() {
|
|
|
+ if (!(this.giftList && this.giftList.length > 0)) {
|
|
|
+ return '0%'
|
|
|
+ }
|
|
|
+ let subList = []
|
|
|
+ for (var i = this.giftList.length - 1; i > 0; i--) {
|
|
|
+ subList.unshift(this.giftList[i].route_count - this.giftList[i - 1].route_count)
|
|
|
+ }
|
|
|
+ subList.unshift(this.giftList[0].route_count)
|
|
|
+
|
|
|
+ let process = 0
|
|
|
+ let count = this.checked
|
|
|
+ let per_process = 100 / this.giftList.length
|
|
|
+ subList.forEach(item => {
|
|
|
+ if (count >= item) {
|
|
|
+ count -= item
|
|
|
+ process += per_process
|
|
|
+ } else {
|
|
|
+ process += per_process * (count / item)
|
|
|
+ count = 0
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return process + '%'
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
- getRouteListInfo() {
|
|
|
+ getRouteListInfo(callback) {
|
|
|
getRouteList().then(res => {
|
|
|
this.is_receipts = res.data.is_receipts
|
|
|
+ if (callback) {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
getActiveInfo() {
|
|
@@ -206,18 +211,27 @@ export default {
|
|
|
this.rule_title = res.data.gifts_rules_name
|
|
|
})
|
|
|
},
|
|
|
- getGiftList() {
|
|
|
- giftList().then(res => {
|
|
|
- console.log(res)
|
|
|
+ getGiftListEvent() {
|
|
|
+ getGiftList().then(res => {
|
|
|
this.giftList = res.data;
|
|
|
+ this.getCheckinCount()
|
|
|
})
|
|
|
},
|
|
|
- getCheckinCount() {
|
|
|
+ getCheckinCount(callback) {
|
|
|
checkInCount().then(res => {
|
|
|
- console.log(res)
|
|
|
this.routes = res.data.routes
|
|
|
this.route_count = res.data.route_count
|
|
|
this.checked = res.data.route_checkin_count
|
|
|
+ console.log(this.checked, 'this.checked')
|
|
|
+ console.log(this.giftList)
|
|
|
+ this.giftList.forEach((item, index) => {
|
|
|
+ if (this.checked >= item.route_count) {
|
|
|
+ this.activeIndex = index
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (callback) {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
gotoCheck() {
|
|
@@ -229,56 +243,53 @@ export default {
|
|
|
this.show_qr = false;
|
|
|
clearTimeout(this.timer)
|
|
|
},
|
|
|
- getGift(item) {
|
|
|
- if (item.route_count > this.checked) {
|
|
|
- uni.showToast({
|
|
|
- title: '不可领取',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.is_receipts) {
|
|
|
- this.current_gift = item
|
|
|
- claim({
|
|
|
- gift_id: item.id,
|
|
|
- }).then(res => {
|
|
|
- if (item.route_count === 9) {
|
|
|
- this.pop_up = true
|
|
|
- } else {
|
|
|
- this.qr_code = res.data.qrcode_url
|
|
|
- this.show_qr = true
|
|
|
- this.checkGiftState()
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.showModal({
|
|
|
- title: '确定领取该奖品吗?',
|
|
|
- content: '领取该礼品后将无法再领取其它礼品',
|
|
|
- success: (res) => {
|
|
|
- if (res.confirm) {
|
|
|
- this.current_gift = item
|
|
|
- console.log(item)
|
|
|
- claim({
|
|
|
- gift_id: item.id,
|
|
|
- }).then(res => {
|
|
|
- console.log(res,'rrrrrrrrr')
|
|
|
- if(res.code === 0) {
|
|
|
- if (item.route_count === 9) {
|
|
|
- this.pop_up = true
|
|
|
- } else {
|
|
|
- this.qr_code = res.data.qrcode_url
|
|
|
- this.show_qr = true
|
|
|
- this.checkGiftState()
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ claimDataEvent() {
|
|
|
+ //生成二维码方法
|
|
|
+ claim({
|
|
|
+ gift_id: this.current_gift.id,
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.qr_code = res.data.qrcode_url
|
|
|
+ this.current_gift.form_id = res.data.id
|
|
|
+ //展示二维码
|
|
|
+ this.show_qr = true
|
|
|
+ this.checkGiftState(() => {
|
|
|
+ if (this.current_gift.route_count === 9) {
|
|
|
+ //轮询确认核销后,展示抽奖环节
|
|
|
+ this.pop_up = true
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getGift(item, index) {
|
|
|
+ //获取当前产品信息
|
|
|
+ if (item.is_receipts > 0 || this.activeIndex !== index) {
|
|
|
+ return false
|
|
|
}
|
|
|
+ this.current_gift = item
|
|
|
+ this.getRouteListInfo(() => {
|
|
|
+ //获取当前是否生成过奖品二维码 is_receipts
|
|
|
+ if (this.is_receipts > 0) {
|
|
|
+ //获取二维码
|
|
|
+ this.claimDataEvent()
|
|
|
+ } else {
|
|
|
+ //确认是否领取奖品
|
|
|
+ uni.showModal({
|
|
|
+ title: '确定领取该奖品吗?',
|
|
|
+ content: '领取该礼品后将无法再领取其它礼品',
|
|
|
+ success: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ //获取二维码
|
|
|
+ this.claimDataEvent()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
- checkGiftState() {
|
|
|
- giftList().then(res => {
|
|
|
+ checkGiftState(callback) {
|
|
|
+ getGiftList().then(res => {
|
|
|
this.giftList = res.data;
|
|
|
this.giftList.forEach(item => {
|
|
|
if (item.id === this.current_gift.id) {
|
|
@@ -286,29 +297,33 @@ export default {
|
|
|
console.log('轮询已核销')
|
|
|
clearTimeout(this.timer)
|
|
|
this.checkAnimation()
|
|
|
+ if (callback) {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
} else {
|
|
|
console.log('轮询未核销')
|
|
|
this.timer = setTimeout(() => {
|
|
|
- this.checkGiftState()
|
|
|
+ this.checkGiftState(callback)
|
|
|
}, 1000)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
- getClass(item) {
|
|
|
+ getClass(item, index) {
|
|
|
if (item.is_receipts)
|
|
|
return 'cheked'
|
|
|
- if (item.route_count > this.checked)
|
|
|
+ if (this.activeIndex !== index)
|
|
|
return 'disable'
|
|
|
},
|
|
|
- getText(item) {
|
|
|
+ getText(item, index) {
|
|
|
if (item.is_receipts)
|
|
|
return '已领取奖品'
|
|
|
- if (item.route_count > this.checked)
|
|
|
- return '不可领取'
|
|
|
- if (item.route_count <= this.checked)
|
|
|
+ if (this.activeIndex === index) {
|
|
|
return '立即领取'
|
|
|
+ } else {
|
|
|
+ return '不可领取'
|
|
|
+ }
|
|
|
},
|
|
|
getNow() {
|
|
|
if (this.verify_note.company_name == '' || this.verify_note.verify_name == '' || this.verify_note.verify_phone == '') {
|
|
@@ -318,15 +333,15 @@ export default {
|
|
|
})
|
|
|
} else {
|
|
|
receiptNote({
|
|
|
- id: this.current_gift.id,
|
|
|
+ id: this.current_gift.form_id,
|
|
|
verify_note: this.verify_note
|
|
|
}).then(res => {
|
|
|
uni.showToast({
|
|
|
- title: '抽奖成功',
|
|
|
+ title: '提交抽奖信息成功',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
this.pop_up = false
|
|
|
- this.getGiftList()
|
|
|
+ this.getGiftListEvent()
|
|
|
this.getCheckinCount()
|
|
|
})
|
|
|
|
|
@@ -686,11 +701,11 @@ export default {
|
|
|
flex-direction: column;
|
|
|
align-items: center;
|
|
|
top: -12rpx;
|
|
|
- transform: translateX(-50%);
|
|
|
+ transform: translateX(-50%);
|
|
|
|
|
|
& > text {
|
|
|
margin-top: 12rpx;
|
|
|
- white-space: nowrap;
|
|
|
+ white-space: nowrap;
|
|
|
font-size: $fontSize1;
|
|
|
}
|
|
|
|