|
@@ -145,7 +145,7 @@
|
|
|
<script>
|
|
|
import AlmostLottery from '@/components/almost-lottery/almost-lottery.vue';
|
|
|
import { clearCacheFile } from '@/almost-utils/almost-utils.js';
|
|
|
-import { findCustomerTimes, buyDrawTimes } from '@/api/luckyDraw.js'
|
|
|
+import { findCustomerTimes, buyDrawTimes, takeOut } from '@/api/luckyDraw.js'
|
|
|
import { existPayPwd } from '@/api/order.js'
|
|
|
export default {
|
|
|
name: 'Home',
|
|
@@ -291,9 +291,9 @@ export default {
|
|
|
let temp = []
|
|
|
prizeList.map(item => {
|
|
|
temp.push({
|
|
|
- prizeId: item.id,
|
|
|
+ prizeId: item.luckyDrawPrizeNo,
|
|
|
name: item.prizeType == 'GOLD' ? (item.prizeDesc + '乐豆') : item.prizeDesc,
|
|
|
- stock: item.prizeNum,
|
|
|
+ stock: item.prizeNum||0,
|
|
|
weight: item.prizeRate,
|
|
|
prizeImage: item.prizeImage,
|
|
|
prizeType: item.prizeType,
|
|
@@ -344,46 +344,37 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
let list = [...this.prizeList];
|
|
|
- // 模拟请求
|
|
|
- let stoTimer = setTimeout(() => {
|
|
|
- clearTimeout(stoTimer);
|
|
|
- stoTimer = null;
|
|
|
- // 这里随机产生的 prizeId 是模拟后端返回的 prizeId
|
|
|
- let prizeId = Math.floor(Math.random() * list.length + 1);
|
|
|
- console.log(prizeId)
|
|
|
- list.forEach((item, index) => {
|
|
|
- if (item.prizeId === ['210509167852392448','210509167852392449','210509167852392450'][prizeId]) {
|
|
|
- // 中奖下标
|
|
|
- this.prizeIndex = index;
|
|
|
+
|
|
|
+ takeOut({id: this.luckDraw.luckyDrawNo}).then(res => {
|
|
|
+ if(res.status == 200){
|
|
|
+ console.log(res)
|
|
|
+ let prizeId = res.data;
|
|
|
+ let index = list.findIndex(item => item.prizeId === prizeId)
|
|
|
+ this.prizeIndex = index;
|
|
|
+ console.log(res, this.prizeIndex)
|
|
|
+ if(this.prizeIndex>=0){
|
|
|
+ console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].name);
|
|
|
+ if (this.onStock) {
|
|
|
+ console.log('本次奖品库存 =>', this.prizeList[this.prizeIndex].stock);
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
- console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].name);
|
|
|
- if (this.onStock) {
|
|
|
- console.log('本次奖品库存 =>', this.prizeList[this.prizeIndex].stock);
|
|
|
+ this.reTimes = this.reTimes -1
|
|
|
}
|
|
|
- this.reTimes = this.reTimes -1
|
|
|
- }, 200);
|
|
|
+ })
|
|
|
},
|
|
|
// 本次抽奖结束
|
|
|
handleDrawEnd() {
|
|
|
let curPrize = this.prizeList[this.prizeIndex]
|
|
|
console.log(curPrize,'curPrize')
|
|
|
this.targetPrize = curPrize
|
|
|
- // 旋转结束后,可以执行拿到结果后的逻辑
|
|
|
- let prizeName = curPrize.name;
|
|
|
- if (this.onStock) {
|
|
|
- let prizeStock = curPrize.stock;
|
|
|
- this.targetName = prizeName === '谢谢参与' ? prizeName : prizeStock ? `恭喜您,获得 ${prizeName}` : '很抱歉,您来晚了,当前奖品已无库存';
|
|
|
- } else {
|
|
|
- this.targetName = prizeName === '谢谢参与' ? prizeName : `恭喜您,获得 ${prizeName}`;
|
|
|
- }
|
|
|
-
|
|
|
+ // 是否未中奖
|
|
|
+ let isNoPrize = curPrize ? curPrize.prizeType == 'NONE' : false
|
|
|
+ console.log(isNoPrize)
|
|
|
if(this.onStock){
|
|
|
- let prizeStock = curPrize.stock;
|
|
|
- if(prizeName === '谢谢参与'){
|
|
|
+ if(isNoPrize){
|
|
|
this.winTypes = 'win_0'
|
|
|
}else{
|
|
|
- if(prizeStock){
|
|
|
+ if(curPrize.stock){
|
|
|
this.winTypes = 'win_2'
|
|
|
}else{
|
|
|
this.targetName = '很抱歉,您来晚了,当前奖品已无库存'
|
|
@@ -391,7 +382,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
- if(prizeName === '谢谢参与'){
|
|
|
+ if(isNoPrize){
|
|
|
this.winTypes = 'win_0'
|
|
|
}else{
|
|
|
this.winTypes = 'win_2'
|