Feat:抽奖2.0(抽奖活动无法正常进入到下一个抽奖活动,购买抽奖商品无法获取到抽奖码)

This commit is contained in:
LinCyJang
2026-04-28 01:21:38 +08:00
parent d3602c010e
commit 8f164cc6ef
7 changed files with 1208 additions and 68 deletions
+99 -63
View File
@@ -6,17 +6,15 @@
<text class="header-back-icon"></text>
</view>
<view class="header-title">中奖名单</view>
<view class="header-actions">
<text class="dot">···</text>
<view class="circle-dot"></view>
</view>
</view>
</view>
<view class="content-wrap" v-if="loaded">
<view class="draw-info-wrap">
<view class="draw-info-wrap" :style="{ backgroundImage: `url(${webUrl}/zhongjiang5.png)` }">
<view class="period-side left">
<text class="side-text">{{ periodLabel }}</text>
<text class="side-text"></text>
<text class="side-text">{{ periodLabel }}</text>
<text class="side-text"></text>
</view>
<view class="period-side right">
<view class="side-text side-text-count">
@@ -34,12 +32,7 @@
<view class="draw-time">开奖时间{{ drawTime }}</view>
</view>
</view>
<view class="win-banner" v-if="hasWon === 1 && userWinList.length > 0">
<view class="win-badge">
<text class="win-badge-text">恭喜您中奖了</text>
</view>
<view class="win-banner" v-if="hasWon === 1 && userWinList.length > 0" :style="{ backgroundImage: `url(${webUrl}/zhongjiangn.png)` }">
<view class="win-banner-subtitle">
您的抽奖码 <text class="code">{{ userWinList[0].ticketCode }}</text> 获得了
</view>
@@ -64,9 +57,9 @@
</view>
<view class="winners-list-wrap">
<view class="list-title-badge">
<text class="gift-icon">🎁</text>
<text class="title-text">中奖名单</text>
<view class="list-title-badge" :style="{ backgroundImage: `url(${webUrl}/zhongjiang6.png)` }">
<text class="gift-icon" style="opacity: 0;">🎁</text>
<text class="title-text" style="opacity: 0;">中奖名单</text>
</view>
<view class="list-content">
@@ -105,20 +98,25 @@
</template>
<script>
import { getDrawActivityInfo, getActivityWinRecord, getDrawMyTickets } from '@/api/lottery'
export default {
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
statusBarHeight: 20,
activityId: 0,
periodLabel: "01",
drawTime: "2026年5月30日",
hasWon: 1,
drawTime: "--",
hasWon: 0,
userWinList: [],
activityWinnerList: [],
loaded: false,
showCouponSuccessPopup: false
}
},
onLoad() {
onLoad(options) {
this.activityId = Number(options && options.activityId) || 0
const systemInfo = uni.getSystemInfoSync()
this.statusBarHeight = systemInfo.statusBarHeight || 20
this.fetchData()
@@ -168,32 +166,73 @@ export default {
url: "/pkg_user/views/myCoupons"
})
},
fetchData() {
const mockData = {
hasWon: 1,
userWinList: [
{
levelName: "优惠券奖",
prizeName: "满100减20优惠券",
prizeDesc: "领取后自动发放到我的优惠券",
ticketCode: "A8F92E",
prizeType: 3,
prizeImage:
"https://img0.baidu.com/it/u=1461707600,2879596427&fm=253&fmt=auto&app=138&f=PNG?w=640&h=640"
}
],
activityWinnerList: [
{ levelName: "一等奖", prizeName: "iphone17 pro max手机", ticketCode: "A82F9E", realName: "海*", phone: "123****4567" },
{ levelName: "二等奖", prizeName: "ipad", ticketCode: "A82F9E", realName: "微信*", phone: "123****4567" },
{ levelName: "三等奖", prizeName: "手表", ticketCode: "A82F9E", realName: "微信*", phone: "123****4567" },
{ levelName: "四等奖", prizeName: "运动手环", ticketCode: "A82F9E", realName: "微信*", phone: "123****4567" },
{ levelName: "五等奖", prizeName: "礼盒", ticketCode: "A82F9E", realName: "微信*", phone: "123****4567" }
]
normalizeListData(res) {
if (!res) return []
if (Array.isArray(res)) return res
if (Array.isArray(res.data)) return res.data
if (Array.isArray(res.data && res.data.list)) return res.data.list
if (Array.isArray(res.list)) return res.list
return []
},
formatDrawTime(time) {
if (!time) return "--"
const date = new Date(String(time).replace(/-/g, "/"))
if (Number.isNaN(date.getTime())) return String(time)
const y = date.getFullYear()
const m = String(date.getMonth() + 1).padStart(2, "0")
const d = String(date.getDate()).padStart(2, "0")
return `${y}${m}${d}`
},
parsePeriodLabel(info = {}, winners = []) {
const periodText = String(info.periodNo || info.currentPeriodNo || info.periodLabel || "")
if (periodText) {
const match = periodText.match(/\d+/)
if (match && match[0]) return match[0].padStart(2, "0")
}
const firstWinner = winners[0] || {}
const winnerPeriod = String(firstWinner.periodNo || "")
const winnerMatch = winnerPeriod.match(/\d+/)
if (winnerMatch && winnerMatch[0]) return winnerMatch[0].padStart(2, "0")
return "01"
},
mapUserWinList(ticketList = []) {
return ticketList.map(item => ({
levelName: item.levelName || item.prizeLevelName || "中奖奖品",
prizeName: item.prizeName || item.awardName || "神秘奖品",
prizeDesc: item.prizeDesc || item.remark || "默认",
ticketCode: item.ticketCode || item.code || "--",
prizeType: item.prizeType,
prizeImage: item.prizeImage || item.image || ""
}))
},
async fetchData() {
try {
const [activityRes, winnerRes, myTicketsRes] = await Promise.all([
this.activityId ? getDrawActivityInfo(this.activityId) : Promise.resolve(null),
this.activityId ? getActivityWinRecord(this.activityId) : Promise.resolve(null),
getDrawMyTickets(1)
])
const activityData = (activityRes && activityRes.data) || {}
const winnerList = this.normalizeListData(winnerRes)
const myTicketList = this.normalizeListData(myTicketsRes)
const filteredMyTicketList = this.activityId
? myTicketList.filter(item => Number(item.activityId || item.drawActivityId || 0) === this.activityId)
: myTicketList
this.drawTime = this.formatDrawTime(activityData.drawTime || activityData.openTime || "")
this.activityWinnerList = winnerList
this.userWinList = this.mapUserWinList(filteredMyTicketList)
this.hasWon = this.userWinList.length > 0 ? 1 : 0
this.periodLabel = this.parsePeriodLabel(activityData, winnerList)
} catch (e) {
uni.showToast({
title: "中奖数据加载失败",
icon: "none"
})
} finally {
this.loaded = true
}
this.hasWon = mockData.hasWon
this.userWinList = mockData.userWinList
this.activityWinnerList = mockData.activityWinnerList
this.loaded = true
}
}
}
@@ -288,16 +327,15 @@ export default {
}
.draw-info-wrap {
border: 5rpx solid #1f1f1f;
border-radius: 26rpx;
background: #fff;
position: relative;
margin: 18rpx 0 38rpx;
padding: 24rpx 70rpx;
display: flex;
align-items: center;
min-height: 168rpx;
box-shadow: 0 6rpx 0 #d8d8d8;
background-size: 100% 100%;
background-repeat: no-repeat;
background-color: transparent;
.period-side {
position: absolute;
@@ -305,7 +343,6 @@ export default {
transform: translateY(-50%);
width: 54rpx;
height: 152rpx;
border: 4rpx solid #1f1f1f;
border-radius: 16rpx;
display: flex;
align-items: center;
@@ -313,7 +350,6 @@ export default {
background: #fff4d1;
padding-bottom: 15rpx;
.side-text {
writing-mode: vertical-rl;
font-size: 24rpx;
line-height: 1.1;
font-weight: 900;
@@ -333,19 +369,21 @@ export default {
}
&.left {
left: -10rpx;
background: #fff7df;
left: 8rpx;
background: transparent;
display: flex;
flex-direction: column;
align-items: center;
}
&.right {
right: -10rpx;
background: #ffbe12;
right: 8rpx;
background: transparent;
}
}
.draw-main {
flex: 1;
border: 2rpx dashed #bcc3cd;
border-radius: 16rpx;
text-align: center;
padding: 18rpx 12rpx;
@@ -368,14 +406,13 @@ export default {
}
.win-banner {
background: #d93325;
border: 5rpx solid #1f1f1f;
border-radius: 28rpx;
padding: 54rpx 20rpx 26rpx;
text-align: center;
margin-bottom: 62rpx;
position: relative;
box-shadow: 0 8rpx 0 #9f1e14;
background-size: 100%;
background-repeat: no-repeat;
background-color: transparent;
.win-badge {
position: absolute;
@@ -522,11 +559,10 @@ export default {
transform: translateX(-50%);
display: flex;
align-items: center;
padding: 8rpx 34rpx;
border-radius: 38rpx;
border: 4rpx solid #1f1f1f;
background: #ffd554;
box-shadow: 0 4rpx 0 #d8a61b;
padding: 14rpx 34rpx;
background-size: 100% 100%;
background-repeat: no-repeat;
background-color: transparent;
.gift-icon {
font-size: 28rpx;