Files
frontend-app/pages/other_package/nine-grid/nine-grid.vue
T

213 lines
4.9 KiB
Vue
Raw Normal View History

2025-08-13 09:20:29 +08:00
<template>
<view class="lottery-page">
2025-08-15 00:35:43 +08:00
<view class="back" style="width:100rpx;height:100rpx;" @click="jumpMine">
<up-image src="/static/common/left_b.png" width="22" height="22" bgColor="#f1f6ff00"></up-image>
</view>
<!-- 中奖记录 -->
<view class="history" @click="jumpWinningRecord">中奖记录
</view>
<view class="remain-count"> 剩余抽奖次数: {{ prizesObj.times }} </view>
2025-08-13 09:20:29 +08:00
<!-- 九宫格抽奖组件 -->
2025-08-15 14:13:02 +08:00
<LotteryGrid :prizesObj="prizesObj" :is-disabled="isRotating" @start="handleStartLottery"
@complete="handleLotteryComplete" :targetIndex="targetIndex" />
2025-08-15 00:35:43 +08:00
<!-- 规则 -->
<view class="rule">
<view class="rule-title"> 活动规则</view>
<view class="rule_content" v-html="prizesObj.ruleDescr"></view>
</view>
2025-08-13 09:20:29 +08:00
<!-- 中奖结果弹窗 -->
<ResultModal :visible="showResult" :prize="currentPrize" @close="showResult = false" />
</view>
</template>
<script>
import LotteryGrid from './components/LotteryGrid.vue'
import ResultModal from './components/ResultModal.vue'
import { getActivityList, raffleExecute } from '@/api/raffle.js';
export default {
components: {
LotteryGrid,
ResultModal
},
data() {
return {
// 奖品配置数据
2025-08-15 00:35:43 +08:00
prizesObj: {
prizes: [],
},
2025-08-13 09:20:29 +08:00
// 状态管理
remainCount: 3, // 剩余抽奖次数
isRotating: false, // 是否正在抽奖
showResult: false, // 是否显示结果弹窗
2025-08-15 00:35:43 +08:00
currentPrize: [],// 当前中奖奖品
targetIndex: 0,
backPath: null,
}
},
onLoad(option) {
const backPath = option.backPath;
console.log("option backPath", backPath);
if (backPath && backPath !== 'null') {
this.backPath = backPath;
2025-08-13 09:20:29 +08:00
}
},
mounted() {
this.getActivityList();
},
methods: {
2025-08-15 00:35:43 +08:00
2025-08-13 09:20:29 +08:00
/**
* 查询活动详情
*/
2025-08-15 00:35:43 +08:00
async getActivityList() {
2025-08-13 09:20:29 +08:00
const { bizcode, data } = await getActivityList();
2025-08-15 00:35:43 +08:00
if (bizcode === 100) {
this.prizesObj = data || { prizes: [] };
console.log('查询活动详情-1', this.prizesObj)
this.prizesObj.prizes.splice(4, 0, { iconUrl: 'https://cex-pub.s3.ap-southeast-1.amazonaws.com/static/activity-button.png', })
}
},
2025-08-13 09:20:29 +08:00
/**
* 处理开始抽奖事件
*/
2025-08-15 00:35:43 +08:00
async handleStartLottery(num) {
if (this.prizesObj.times <= 0) {
uni.showToast({
title: `您当前未获取到抽奖次数,快去获取吧~`,
icon: 'none'
});
return;
}
if (this.prizesObj.times < num) {
return;
}
const params = {
id: this.prizesObj.id,
times: num,
}
2025-08-15 14:13:02 +08:00
const { data } = await raffleExecute(params);
this.targetIndex = this.prizesObj.prizes.findIndex(ele => ele.id === data.idList[0].id);
2025-08-15 00:35:43 +08:00
2025-08-15 14:13:02 +08:00
this.currentPrize = data.prizeList;
console.log("0------", this.currentPrize)
2025-08-15 00:35:43 +08:00
2025-08-15 14:13:02 +08:00
// 减少抽奖次数并标记为正在抽奖
2025-08-13 09:20:29 +08:00
2025-08-15 14:13:02 +08:00
this.isRotating = true
2025-08-13 09:20:29 +08:00
2025-08-15 14:13:02 +08:00
const total = this.prizesObj.times;
this.prizesObj.times = total - num;// 减去次数
2025-08-13 09:20:29 +08:00
},
2025-08-15 14:13:02 +08:00
2025-08-13 09:20:29 +08:00
/**
* 处理抽奖完成事件
* @param {Object} prize - 中奖奖品
*/
2025-08-15 00:35:43 +08:00
handleLotteryComplete() {
2025-08-13 09:20:29 +08:00
this.isRotating = false
this.showResult = true
2025-08-15 00:35:43 +08:00
},
/**
* 跳转到中奖记录
*/
jumpWinningRecord() {
uni.navigateTo({
url: '/pages/mine_package/mine_winning_record/mine_winning_record',
})
},
jumpMine() {
const backPath = this.backPath;
console.log("backPath", backPath);
if (backPath) {
uni.switchTab({
url: '/pages/home/home',
})
} else {
uni.switchTab({
url: '/pages/mine/mine',
})
}
},
2025-08-13 09:20:29 +08:00
}
}
</script>
<style scoped>
.lottery-page {
display: flex;
flex-direction: column;
align-items: center;
2025-08-15 00:35:43 +08:00
width: 100vw;
height: 1927rpx;
background: url('https://cex-pub.s3.ap-southeast-1.amazonaws.com/static/activity-bg.png') no-repeat center center;
background-size: 100% auto;
position: relative;
2025-08-13 09:20:29 +08:00
}
.remain-count {
font-size: 30rpx;
2025-08-15 00:35:43 +08:00
color: #FFFAE3;
2025-08-13 09:20:29 +08:00
border-radius: 20rpx;
2025-08-15 00:35:43 +08:00
margin-top: 430rpx;
width: 340rpx;
height: 44rpx;
text-align: center;
line-height: 44rpx;
background: linear-gradient(180deg, #F33838 0%, #FF4F28 100%);
}
.rule {
width: 670rpx;
background: linear-gradient(180deg, #FF8876 0%, #FF3D36 17%, #FF4646 85%, #FF8978 100%);
border-radius: 24rpx;
padding: 50rpx 24rpx;
margin: 50rpx auto 0;
font-size: 34rpx;
color: #FFFAE3;
line-height: 54rpx;
.rule-title {
text-align: center;
margin-bottom: 30rpx;
}
}
.history {
width: 130rpx;
height: 64rpx;
line-height: 64rpx;
background: #000000;
border-top-left-radius: 100rpx;
border-bottom-left-radius: 100rpx;
opacity: 0.4;
font-size: 26rpx;
color: #FFFFFF;
position: absolute;
right: 0;
top: 80rpx;
text-align: end;
}
.back {
position: absolute;
left: 40rpx;
top: 40rpx;
2025-08-13 09:20:29 +08:00
}
</style>