This commit is contained in:
zpc 2025-04-09 20:27:40 +08:00
parent de731b9c15
commit 45cc6ce368

View File

@ -6,11 +6,12 @@
<view style="height:52rpx;"></view>
<view class="neiquan">
<view class="grid-container">
<view class="jiangping" v-for="(item, index) in 9"
<view class="jiangping" v-for="(item, index) in prizes"
:class="{ 'xuanzhong': currentIndex === index && !isFinalWin, 'win-flash': currentIndex === index && isFinalWin }"
:key="index">
<!-- 奖品图片将在这里显示 -->
<image src="https://image.zfunbox.cn/huodong/kuang.png" style="width:95%;height:95%;margin-left: 1rpx;border-radius: 25rpx;">
<image :src="item.image"
style="width:95%;height:95%;margin-left: 1rpx;border-radius: 25rpx;">
</image>
</view>
</view>
@ -18,6 +19,17 @@
<view class="draw-btn-container">
<view class="draw-btn" @click="startDraw"></view>
</view>
</view>
<view class="bottom-buttons">
<view class="button-item gzsm" @click="showRules">
<image src="https://image.zfunbox.cn/huodong/gzsm.png" style="width: 136.11rpx;height: 53.47rpx;">
</image>
</view>
<view class="button-item zjjl" @click="showRecords">
<image src="https://image.zfunbox.cn/huodong/zbtn.png" style="width: 136.11rpx;height: 53.47rpx;">
</image>
</view>
</view>
</view>
</page-container>
@ -26,12 +38,14 @@
<script>
import PageContainer from '@/components/page-container/page-container.vue'
export default {
components: {
PageContainer
},
data() {
return {
goods_id: 0,
isDrawing: false,
prizes: [
//
@ -49,10 +63,39 @@ export default {
FIGURE_EIGHT: 2 // 8
},
pathFigureEight: [0, 1, 2, 5, 4, 3, 6, 7, 8, 5, 4, 3], // 8
goods: null,
useMoney: true,
useIntegral: true,
useMoney2: true,
selectPrizes: null
};
},
onLoad() {
this.load();
},
methods: {
startDraw() {
async load() {
let goods_id = this.$config.getAppSetting('daily_free_draw_id');
this.goods_id = goods_id;
//infinite_goodsdetail
const { status, data, msg } = await this.$request.post('infinite_goodsdetail', { goods_id: goods_id });
console.log(status, data, msg);
let { goods, goods_list } = data;
this.goods = goods;
let p = [];
goods_list.data.map(item => {
console.log(item);
p.push({
image: item.imgurl,
title: item.title,
id: item.id
});
});
this.prizes = p;
console.log(goods_list);
},
async startDraw() {
if (this.isDrawing) return;
this.isDrawing = true;
this.isFinalWin = false; //
@ -62,7 +105,35 @@ export default {
clearInterval(this.timer);
this.timer = null;
}
if (this.goods == null && this.goods.price == '') {
this.isDrawing = false;
this.$c.msg('抽奖失败')
return false;
}
console.log('免费');
try {
const goods_list_Id = await this.confirmSubmit([1, 1]);
let targetIndex = 0;
// console.log(goods_list_Id, targetIndex, this.prizes);
let selectPrizes = null;
this.prizes.forEach((item, index, array) => {
// console.log(item); //
// console.log(index); //
// console.log(array); //
if (item.id == goods_list_Id) {
targetIndex = index;
selectPrizes = item;
}
});
this.selectPrizes = selectPrizes;
console.log(this.selectPrizes);
this.targetIndex = targetIndex;
} catch (error) {
this.$c.msg(error)
this.isDrawing = false;
return;
}
//
this.times = 0;
this.speed = 100;
@ -77,7 +148,7 @@ export default {
console.log('抽奖动画类型:', animationName);
// 0-8
this.targetIndex = Math.floor(Math.random() * 9);
// this.targetIndex = Math.floor(Math.random() * 9);
//
this.runAnimation();
@ -133,15 +204,99 @@ export default {
//
setTimeout(() => {
this.isDrawing = false;
if (this.selectPrizes == null) {
uni.showToast({
title: '获取奖品失败',
icon: 'none',
duration: 2000
});
return;
}
uni.showToast({
title: '恭喜获得奖品!',
title: '恭喜获得' + this.selectPrizes.title + '奖品!',
icon: 'none',
duration: 2000
});
//
}, 500);
}
},
//
showRules() {
if (this.isDrawing) {
uni.showToast({
title: '请等待抽奖完成',
icon: 'none'
});
return;
}
uni.showToast({
title: '规则说明功能待实现',
icon: 'none'
});
},
//
showRecords() {
if (this.isDrawing) {
uni.showToast({
title: '请等待抽奖完成',
icon: 'none'
});
return;
}
uni.showToast({
title: '中奖记录功能待实现',
icon: 'none'
});
},
async confirmSubmit([type, num, flag]) {
let url = 'infinite_ordermoney'
if (type == 1) {
url = 'infinite_orderbuy'
}
let psotData = {
goods_id: this.goods_id,
prize_num: num,
use_money_is: 1,
use_integral_is: 2,
use_money2_is: 2,
coupon_id: '',
};
let res = await this.$request.post(url, psotData);
const { status, data, msg } = res;
if (status !== 1) {
// this.$c.msg(msg);
throw msg;
}
console.log(data.order_num);
if (data.order_num != null) {
const prize = await this.getPrize(data.order_num);
console.log(prize);//goodslist_id
if (prize.goodslist_id != null) {
return prize.goodslist_id;
}
}
throw '出现异常';
},
async getPrize(order_num) {
if (!order_num) {
return
}
const res = await this.$request.post('infinite_prizeorderlog', {
order_num
});
let { status, data, msg } = res;
if (status !== 1) {
throw msg;
}
return data.data[0];
},
}
}
</script>
@ -225,6 +380,8 @@ export default {
//box-shadow: 0 2rpx 4rpx rgba(255, 87, 34, 0.3);
}
}
}
.xuanzhong {
@ -242,11 +399,54 @@ export default {
animation: win-blink 0.3s 5 alternate;
}
.bottom-buttons {
position: relative;
top: -20rpx;
width: 100%;
display: flex;
justify-content: space-evenly;
padding: 10rpx;
box-sizing: border-box;
.button-item {
width: 136.11rpx;
height: 53.47rpx;
font-size: 28rpx;
border-radius: 35rpx;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s;
// box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
&:active {
transform: scale(0.95);
// background-color: rgba(255, 255, 255, 0.9);
}
}
}
.gzsm {
animation: pulse 0.3s 5 alternate;
width: 136.11rpx;
height: 53.47rpx;
}
.zjjl {
animation: pulse 0.3s 5 alternate;
width: 136.11rpx;
height: 53.47rpx;
}
@keyframes win-blink {
0% {
opacity: 1;
transform: scale(1);
}
100% {
opacity: 0.5;
transform: scale(1.05);
@ -257,6 +457,7 @@ export default {
from {
opacity: 1;
}
to {
opacity: 0.8;
}