Feat:抽奖2.0(细节调整,查漏补缺)
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
</view> -->
|
||||
|
||||
<view class="content-wrap" v-if="loaded">
|
||||
<view v-if="!showHistory" class="draw-info-wrap" :style="{ backgroundImage: `url(${webUrl}/zhongjiang5.png)` }">
|
||||
<view v-if="!useHistoryHeader" class="draw-info-wrap" :style="{ backgroundImage: `url(${webUrl}/zhongjiang5.png)` }">
|
||||
<view class="period-side left">
|
||||
<text class="side-text v12-font-36">第</text>
|
||||
<text class="side-text v12-font-36">{{ periodLabel }}</text>
|
||||
@@ -74,10 +74,10 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button v-if="!showHistory" class="my-tickets-btn" @click="handleClaimNow">
|
||||
<button v-if="showClaimNowBtn" class="my-tickets-btn" @click="handleClaimNow">
|
||||
<text class="btn-text">立即领取</text>
|
||||
</button>
|
||||
<button v-if="showHistory" class="my-tickets-btn" @click="navToMyTickets">
|
||||
<button v-else class="my-tickets-btn" @click="navToMyTickets">
|
||||
<text class="btn-text">我的抽奖码</text>
|
||||
</button>
|
||||
<view class="claim-tip">*请在7天内领取,过期失效</view>
|
||||
@@ -147,10 +147,22 @@ export default {
|
||||
return this.historyList.findIndex(item => Number(item.id) === Number(this.activityId))
|
||||
},
|
||||
canSwitchPrev() {
|
||||
return this.currentHistoryIndex > -1 && this.currentHistoryIndex < this.historyList.length - 1
|
||||
if (!this.historyList.length) return false
|
||||
if (this.currentHistoryIndex < 0) return true
|
||||
return this.currentHistoryIndex < this.historyList.length - 1
|
||||
},
|
||||
canSwitchNext() {
|
||||
if (!this.historyList.length) return false
|
||||
if (this.currentHistoryIndex < 0) return true
|
||||
return this.currentHistoryIndex > 0
|
||||
},
|
||||
useHistoryHeader() {
|
||||
return this.showHistory || this.entryWithoutActivityId
|
||||
},
|
||||
showClaimNowBtn() {
|
||||
if (this.userWinList.length !== 1) return false
|
||||
const prize = this.userWinList[0] || {}
|
||||
return Number(prize.claimStatus) === 0
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -167,25 +179,24 @@ export default {
|
||||
loaded: false,
|
||||
showCouponSuccessPopup: false,
|
||||
showHistory: false,
|
||||
entryWithoutActivityId: false,
|
||||
historyList: []
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.activityId = Number(options && options.activityId) || 0
|
||||
const incomingActivityId = Number(options && options.activityId) || 0
|
||||
this.entryWithoutActivityId = !incomingActivityId
|
||||
this.activityId = incomingActivityId
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
this.statusBarHeight = systemInfo.statusBarHeight || 20
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
async handleShowHistory() {
|
||||
uni.showLoading({
|
||||
mask: true
|
||||
})
|
||||
async loadHistoryList() {
|
||||
const historyRes = await getDrawHistoryActivities()
|
||||
const {data, success} = historyRes || {}
|
||||
uni.hideLoading()
|
||||
if(!success) return
|
||||
this.historyList = (data || [])
|
||||
const { data, success } = historyRes || {}
|
||||
if (!success) return []
|
||||
const list = (data || [])
|
||||
.map(item => ({
|
||||
id: Number(item.id || item.activityId || item.drawActivityId || 0),
|
||||
periodNo: item.periodNo || '',
|
||||
@@ -193,6 +204,16 @@ export default {
|
||||
}))
|
||||
.filter(item => item.id > 0)
|
||||
.sort((a, b) => this.getPeriodNoValue(b.periodNo) - this.getPeriodNoValue(a.periodNo))
|
||||
this.historyList = list
|
||||
return list
|
||||
},
|
||||
async handleShowHistory() {
|
||||
uni.showLoading({
|
||||
mask: true
|
||||
})
|
||||
const list = await this.loadHistoryList()
|
||||
uni.hideLoading()
|
||||
if (!list.length) return
|
||||
this.showHistory = true
|
||||
},
|
||||
async handleSwitchHistory(direction) {
|
||||
@@ -204,14 +225,9 @@ export default {
|
||||
return
|
||||
}
|
||||
const currentIndex = this.currentHistoryIndex
|
||||
if (currentIndex < 0) {
|
||||
uni.showToast({
|
||||
title: "当前期数不在历史列表中",
|
||||
icon: "none"
|
||||
})
|
||||
return
|
||||
}
|
||||
const targetIndex = direction === 'prev' ? currentIndex + 1 : currentIndex - 1
|
||||
const targetIndex = currentIndex < 0
|
||||
? (direction === 'prev' ? 0 : this.historyList.length - 1)
|
||||
: (direction === 'prev' ? currentIndex + 1 : currentIndex - 1)
|
||||
if (targetIndex < 0 || targetIndex >= this.historyList.length) return
|
||||
const target = this.historyList[targetIndex]
|
||||
if (!target || Number(target.id) === Number(this.activityId)) return
|
||||
@@ -229,6 +245,10 @@ export default {
|
||||
},
|
||||
handleClaimNow() {
|
||||
if (!this.userWinList.length) return
|
||||
if (!this.showClaimNowBtn) {
|
||||
this.navToMyTickets()
|
||||
return
|
||||
}
|
||||
|
||||
if (this.userWinList.length > 1) {
|
||||
this.navToMyTickets()
|
||||
@@ -308,6 +328,7 @@ export default {
|
||||
prizeName: item.prizeName || item.awardName || "神秘奖品",
|
||||
prizeDesc: item.prizeDesc || item.remark || "默认",
|
||||
ticketCode: item.ticketCode || item.code || "--",
|
||||
claimStatus: Number(item.claimStatus),
|
||||
prizeType: item.prizeType,
|
||||
prizeTypeName: item.prizeTypeName || item.prizeCategoryName || "",
|
||||
prizeImage: item.prizeImage || item.image || ""
|
||||
@@ -315,24 +336,34 @@ export default {
|
||||
},
|
||||
async fetchData() {
|
||||
try {
|
||||
let targetActivityId = Number(this.activityId) || 0
|
||||
if (!targetActivityId) {
|
||||
const historyList = await this.loadHistoryList()
|
||||
this.showHistory = true
|
||||
targetActivityId = (historyList[0] && Number(historyList[0].id)) || 0
|
||||
if (targetActivityId) {
|
||||
this.activityId = targetActivityId
|
||||
}
|
||||
}
|
||||
const [activityRes, winnerRes, myTicketsRes] = await Promise.all([
|
||||
this.activityId ? getDrawActivityInfo(this.activityId) : Promise.resolve(null),
|
||||
this.activityId ? getActivityWinRecord(this.activityId) : Promise.resolve(null),
|
||||
targetActivityId ? getDrawActivityInfo(targetActivityId) : Promise.resolve(null),
|
||||
targetActivityId ? getActivityWinRecord(targetActivityId) : Promise.resolve(null),
|
||||
getDrawMyTickets(1)
|
||||
])
|
||||
const activityData = (activityRes && activityRes.data) || {}
|
||||
const winnerList = winnerRes.data.activityWinnerList || []
|
||||
const winnerData = (winnerRes && winnerRes.data) || {}
|
||||
const winnerList = winnerData.activityWinnerList || []
|
||||
const myTicketList = this.normalizeListData(myTicketsRes)
|
||||
|
||||
const filteredMyTicketList = this.activityId
|
||||
? myTicketList.filter(item => Number(item.activityId || item.drawActivityId || 0) === this.activityId)
|
||||
const filteredMyTicketList = targetActivityId
|
||||
? myTicketList.filter(item => Number(item.activityId || item.drawActivityId || 0) === targetActivityId)
|
||||
: 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 = winnerRes.data.periodNo || "01"
|
||||
this.periodLabel = winnerData.periodNo || "01"
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: "中奖数据加载失败",
|
||||
@@ -659,11 +690,11 @@ export default {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
border: 4rpx solid #333;
|
||||
box-shadow: inset 0 -12rpx 0 #FAA100, inset 0 12rpx 0 #FAA100, inset -12rpx 0rpx 0rpx #FAA100, inset 12rpx 0rpx 0 #FAA100;
|
||||
transition: all 0.1s;
|
||||
background: #FDB400;
|
||||
|
||||
color: #333;
|
||||
&:active {
|
||||
transform: translateY(4rpx);
|
||||
box-shadow: inset 0 -4rpx 0 #FAA100;
|
||||
@@ -732,7 +763,7 @@ export default {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 280rpx; /* 根据实际标题框宽度设定,让它包裹住背景图 */
|
||||
height: 80rpx;
|
||||
height: 85rpx;
|
||||
z-index: 3;
|
||||
|
||||
/* 主背景图,层级2,盖住半圆的一部分 */
|
||||
|
||||
Reference in New Issue
Block a user