Feat:抽奖2.0(细节调整,查漏补缺)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
<view class="side-entry rules" @click="openRulesModel">活动规则</view>
|
||||
<view class="side-entry mine" @click="navToLog">我的抽奖码</view>
|
||||
|
||||
<view class="winners-wrap" @click="navToLog">
|
||||
<view class="winners-wrap">
|
||||
<view class="winners-text" v-if="!winnerSortedList.length">暂时无人中奖</view>
|
||||
<view class="winners-text one-t" v-else-if="winnerSortedList.length === 1">
|
||||
恭喜 <text class="blue">{{ winnerSortedList[0].name }}</text>
|
||||
@@ -123,7 +123,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getDrawActivityInfo } from '@/api/lottery'
|
||||
import { getDrawActivityInfo, getDrawLatestWinners } from '@/api/lottery'
|
||||
import { postCartAdd } from '@/api/store'
|
||||
import ProductWindow from '@/components/ProductWindow'
|
||||
import goCartMixin from '@/mixins/goCartMixins'
|
||||
@@ -145,6 +145,7 @@ export default {
|
||||
prizePool: [],
|
||||
products: []
|
||||
},
|
||||
latestWinnerList: [],
|
||||
activityId: 0,
|
||||
linkType: 1,
|
||||
onlyOneToAddCart: false,
|
||||
@@ -184,7 +185,7 @@ export default {
|
||||
}))
|
||||
},
|
||||
winnerSortedList() {
|
||||
const list = this.activityInfo.winnerList || []
|
||||
const list = this.latestWinnerList || []
|
||||
if (!list.length) return []
|
||||
const mapped = list.map(item => ({
|
||||
name: item.realName || item.phone || '用户',
|
||||
@@ -194,7 +195,8 @@ export default {
|
||||
return mapped.sort((a, b) => this.getPeriodNoValue(b.periodNo) - this.getPeriodNoValue(a.periodNo))
|
||||
},
|
||||
buyThresholdText() {
|
||||
return 99
|
||||
const spendThreshold = this.activityInfo.spendThreshold || 0
|
||||
return spendThreshold
|
||||
},
|
||||
openDateText() {
|
||||
const target = this.getTargetDate()
|
||||
@@ -223,9 +225,12 @@ export default {
|
||||
})
|
||||
return
|
||||
}
|
||||
getDrawActivityInfo(this.activityId).then(res => {
|
||||
if (res.success) {
|
||||
const data = res.data || {}
|
||||
Promise.all([
|
||||
getDrawActivityInfo(this.activityId),
|
||||
getDrawLatestWinners()
|
||||
]).then(([activityRes, winnersRes]) => {
|
||||
if (activityRes && activityRes.success) {
|
||||
const data = activityRes.data || {}
|
||||
this.activityInfo = {
|
||||
...this.activityInfo,
|
||||
...data,
|
||||
@@ -234,6 +239,11 @@ export default {
|
||||
this.ready = true
|
||||
this.startCountdown()
|
||||
}
|
||||
const winnersData = winnersRes && winnersRes.data
|
||||
const list = Array.isArray(winnersData)
|
||||
? winnersData
|
||||
: (Array.isArray(winnersData && winnersData.list) ? winnersData.list : [])
|
||||
this.latestWinnerList = list
|
||||
})
|
||||
},
|
||||
getTargetDate() {
|
||||
@@ -291,9 +301,12 @@ export default {
|
||||
uni.navigateTo({ url: '/pkg-video/views/county-lottery-rules' })
|
||||
},
|
||||
navToWinners() {
|
||||
uni.navigateTo({
|
||||
url: `/pkg-video/views/county-winners?activityId=${this.activityId}`
|
||||
})
|
||||
const targetDate = this.getTargetDate()
|
||||
const isNotOpened = targetDate && targetDate.getTime() > Date.now()
|
||||
const url = isNotOpened
|
||||
? '/pkg-video/views/county-winners'
|
||||
: `/pkg-video/views/county-winners?activityId=${this.activityId}`
|
||||
uni.navigateTo({ url })
|
||||
},
|
||||
navToLog() {
|
||||
uni.navigateTo({ url: '/pkg-video/views/county-my-tickets' })
|
||||
|
||||
@@ -288,7 +288,7 @@ export default {
|
||||
this.goMyCoupons()
|
||||
return
|
||||
}
|
||||
if (!item.sourceOrderId) {
|
||||
if (!item.prizeOrderId) {
|
||||
uni.showToast({
|
||||
title: '缺少订单号',
|
||||
icon: 'none'
|
||||
@@ -296,7 +296,7 @@ export default {
|
||||
return
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/order/OrderDetails/index?id=${item.sourceOrderId}`
|
||||
url: `/pages/order/OrderDetails/index?id=${item.prizeOrderId}`
|
||||
})
|
||||
},
|
||||
goBack() {
|
||||
|
||||
@@ -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