Task:抽奖
This commit is contained in:
@@ -99,14 +99,14 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="popup-mask" v-if="showSubmitSuccessPopup" @click="closePopup">
|
||||
<view class="popup-mask" v-if="showSubmitSuccessPopup" @click="confirmSuccess">
|
||||
<view class="popup-panel success-panel" @click.stop>
|
||||
<view class="popup-close" @click="closePopup">×</view>
|
||||
<view class="popup-close" @click="confirmSuccess">×</view>
|
||||
<view class="popup-icon-wrap">
|
||||
<image class="popup-success-icon" :src="webUrl + '/home/qingzhu.png'" mode="aspectFit" />
|
||||
</view>
|
||||
<view class="popup-title">提交成功</view>
|
||||
<view class="popup-desc">奖品将在7个工作日内寄出</view>
|
||||
<view class="popup-desc">奖品将在{{ shipDayText }}个工作日内寄出</view>
|
||||
<view class="popup-actions">
|
||||
<view class="popup-btn btn-ghost" @click="confirmSuccess">返回</view>
|
||||
<view class="popup-btn btn-confirm" @click="goMyTicket">查看</view>
|
||||
@@ -150,6 +150,8 @@ export default {
|
||||
},
|
||||
showRealnamePopup: false,
|
||||
showSubmitSuccessPopup: false,
|
||||
shipDay: 7,
|
||||
prizeOrderId: '',
|
||||
userInfo: {},
|
||||
realnameStatus: 0,
|
||||
waitSubmitAfterRealname: false,
|
||||
@@ -159,6 +161,11 @@ export default {
|
||||
computed: {
|
||||
prizeImage() {
|
||||
return this.form.prizeImage || ''
|
||||
},
|
||||
shipDayText() {
|
||||
const day = Number(this.shipDay)
|
||||
if (!day || Number.isNaN(day) || day < 1) return 7
|
||||
return day
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@@ -273,6 +280,8 @@ export default {
|
||||
return
|
||||
}
|
||||
await claimCoupon(ticketId)
|
||||
this.shipDay = 7
|
||||
this.prizeOrderId = ''
|
||||
this.showSubmitSuccessPopup = true
|
||||
},
|
||||
async submitPhysicalClaim() {
|
||||
@@ -295,7 +304,10 @@ export default {
|
||||
}
|
||||
}
|
||||
const addressId = await this.createAddress()
|
||||
await claimPrize(ticketId, addressId)
|
||||
const res = await claimPrize(ticketId, addressId)
|
||||
const data = (res && res.data) || {}
|
||||
this.shipDay = Number(data.shipDay || 0) || 7
|
||||
this.prizeOrderId = String(data.orderId || '')
|
||||
this.waitSubmitAfterRealname = false
|
||||
this.showSubmitSuccessPopup = true
|
||||
} catch (e) {
|
||||
@@ -398,12 +410,14 @@ export default {
|
||||
},
|
||||
confirmSuccess() {
|
||||
this.showSubmitSuccessPopup = false
|
||||
uni.navigateBack()
|
||||
uni.redirectTo({
|
||||
url: '/pkg-video/views/county-my-tickets'
|
||||
})
|
||||
},
|
||||
goMyTicket() {
|
||||
this.showSubmitSuccessPopup = false
|
||||
uni.navigateTo({
|
||||
url: '/pkg-video/views/county-my-tickets'
|
||||
uni.redirectTo({
|
||||
url: `/pages/order/OrderDetails/index?id=${this.prizeOrderId}`
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +99,14 @@
|
||||
:key="index"
|
||||
class="goods-item"
|
||||
>
|
||||
<image
|
||||
v-if="Number(item.isGiftCard) === 1"
|
||||
class="goods-gift-tag"
|
||||
:src="webUrl + '/home/gift-tag.png'"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<image class="goods-image" :src="item.image" mode="aspectFill" @click="goGoodsDetail(item)" />
|
||||
<view class="goods-name more-t">{{ item.name }}</view>
|
||||
<view class="goods-name more-t">{{ item.storeName }}</view>
|
||||
<view class="goods-bottom">
|
||||
<text class="goods-price">¥{{ item.price }}</text>
|
||||
<view class="goods-cart" @click.stop="openGoodsSku(item)">购</view>
|
||||
@@ -114,7 +120,7 @@
|
||||
:attr="attr"
|
||||
:cartNum="cart_num"
|
||||
:showOk="true"
|
||||
okText="立即下单"
|
||||
:okText="currentGoodsItem && Number(currentGoodsItem.isGiftCard) === 1 ? '送给朋友' : '立即下单'"
|
||||
@changeFun="changeFun"
|
||||
@ok="submitFromSku()"
|
||||
/>
|
||||
@@ -155,7 +161,9 @@ export default {
|
||||
time: '--:--:--'
|
||||
},
|
||||
countdownTimer: null,
|
||||
currentSwiperIndex: 0
|
||||
currentSwiperIndex: 0,
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
currentGoodsItem: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -173,15 +181,18 @@ export default {
|
||||
return list.map(item => ({
|
||||
id: item.productId || item.id || 0,
|
||||
image: item.productImage || item.image || item.pic || '',
|
||||
name: item.productName || item.name || item.prizeName || '',
|
||||
price: item.productPrice || item.price || item.salePrice || 0
|
||||
storeName: item.storeName || '',
|
||||
productName: item.productName || item.name || item.prizeName || '',
|
||||
price: item.productPrice || item.price || item.salePrice || 0,
|
||||
isGiftCard: Number(item.isGiftCard || 0)
|
||||
}))
|
||||
}
|
||||
return this.prizeList.map(item => ({
|
||||
id: item.productId || 0,
|
||||
image: item.prizeImage || '',
|
||||
name: item.prizeName || '',
|
||||
price: item.productPrice || item.price || 0
|
||||
price: item.productPrice || item.price || 0,
|
||||
isGiftCard: Number(item.isGiftCard || 0)
|
||||
}))
|
||||
},
|
||||
winnerSortedList() {
|
||||
@@ -329,11 +340,13 @@ export default {
|
||||
},
|
||||
openGoodsSku(item) {
|
||||
if (!item.id) return
|
||||
this.currentGoodsItem = item
|
||||
this.addToCart(item)
|
||||
},
|
||||
submitFromSku() {
|
||||
const productSelect = this.getAttrItemData(this.attrValue)
|
||||
const currentSelect = productSelect || this.attr.productSelect || {}
|
||||
const isGiftOrder = Number(this.currentGoodsItem && this.currentGoodsItem.isGiftCard) === 1
|
||||
const stock = Number(currentSelect.stock || 0)
|
||||
const hasNo = (this.attr.productAttr.length && !productSelect && this.isOpen) || stock <= 0
|
||||
if (hasNo) {
|
||||
@@ -360,6 +373,12 @@ export default {
|
||||
this.cart_num = 1
|
||||
const cartId = (res.data && res.data.cartId) || ''
|
||||
if (!cartId) return
|
||||
if (isGiftOrder) {
|
||||
uni.navigateTo({
|
||||
url: `/pkg_user/views/gift/gift?cartId=${cartId}&from=countyLottery&drawActivityId=${this.activityId || 0}`
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/order/OrderSubmission/index?id=${cartId}`
|
||||
})
|
||||
@@ -786,6 +805,16 @@ export default {
|
||||
width: 316rpx;
|
||||
background: #fff;
|
||||
margin-bottom: 30rpx;
|
||||
position: relative;
|
||||
|
||||
.goods-gift-tag {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 120rpx;
|
||||
z-index: 2;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.goods-image {
|
||||
width: 100%;
|
||||
|
||||
@@ -25,9 +25,31 @@
|
||||
</view> -->
|
||||
|
||||
<scroll-view class="page-body" scroll-y>
|
||||
<view class="tip-bar" v-if="summaryText">
|
||||
<view class="tip-text one-t">{{ summaryText }}</view>
|
||||
<view class="tip-btn" @click="goWinnersPage">查看全部 <text class="icon-expand">⤢</text></view>
|
||||
<view class="tip-bar">
|
||||
<view class="tip-text" v-if="!winnerSortedList.length">暂时无人中奖</view>
|
||||
<view class="tip-text one-t" v-else-if="winnerSortedList.length === 1">
|
||||
恭喜 <text class="blue">{{ winnerSortedList[0].name }}</text>
|
||||
在第 <text class="blue">{{ winnerSortedList[0].periodNo }}</text> 期抽奖活动中获得
|
||||
<text class="red">{{ winnerSortedList[0].prizeName }}</text>
|
||||
</view>
|
||||
<swiper
|
||||
v-else
|
||||
class="winner-swiper"
|
||||
vertical
|
||||
circular
|
||||
autoplay
|
||||
:interval="3000"
|
||||
:duration="500"
|
||||
>
|
||||
<swiper-item v-for="(winner, index) in winnerSortedList" :key="index">
|
||||
<view class="tip-text one-t">
|
||||
恭喜 <text class="blue">{{ winner.name }}</text>
|
||||
在第 <text class="blue">{{ winner.periodNo }}</text> 期抽奖活动中获得
|
||||
<text class="red">{{ winner.prizeName }}</text>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view class="tip-btn" @click="goWinnersPage">查看全部 <text class="icon-expand">➔</text></view>
|
||||
</view>
|
||||
|
||||
<view class="ticket-list" v-if="displayList.length">
|
||||
@@ -56,7 +78,7 @@
|
||||
|
||||
<view class="ticket-footer" v-if="item.status === 1">
|
||||
<template v-if="item.claimStatus === 0">
|
||||
<view class="footer-note">注意:请在7天内领取,过期不予发放</view>
|
||||
<view class="footer-note">注意:请在{{ getClaimDaysText(item) }}内领取,过期不予发放</view>
|
||||
<view class="footer-btn btn-claim" @click="onClaim(item)">立 即 领 取</view>
|
||||
</template>
|
||||
<template v-else-if="item.claimStatus === 1">
|
||||
@@ -91,7 +113,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { claimCoupon, getDrawMyTickets } from '@/api/lottery'
|
||||
import { claimCoupon, getDrawLatestWinners, getDrawMyTickets } from '@/api/lottery'
|
||||
|
||||
export default {
|
||||
name: 'CountyMyTicketsPage',
|
||||
@@ -110,6 +132,7 @@ export default {
|
||||
],
|
||||
list: [],
|
||||
openedList: [],
|
||||
latestWinnerList: [],
|
||||
showCouponSuccessPopup: false,
|
||||
claiming: false
|
||||
}
|
||||
@@ -118,8 +141,15 @@ export default {
|
||||
displayList() {
|
||||
return this.activeTab === 'opened' ? this.openedList : this.list
|
||||
},
|
||||
summaryText() {
|
||||
return `恭喜海*在第01期抽奖活动中获得 iPhone17 pro 手机`
|
||||
winnerSortedList() {
|
||||
const list = this.latestWinnerList || []
|
||||
if (!list.length) return []
|
||||
const mapped = list.map(item => ({
|
||||
name: item.realName || item.phone || '用户',
|
||||
periodNo: item.periodNo || '-',
|
||||
prizeName: item.prizeName || '神秘奖品'
|
||||
}))
|
||||
return mapped.sort((a, b) => this.getPeriodNoValue(b.periodNo) - this.getPeriodNoValue(a.periodNo))
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@@ -129,9 +159,28 @@ export default {
|
||||
},
|
||||
onShow() {
|
||||
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 20
|
||||
this.fetchLatestWinners()
|
||||
this.fetchList()
|
||||
},
|
||||
methods: {
|
||||
getPeriodNoValue(periodNo) {
|
||||
const text = String(periodNo || '')
|
||||
const match = text.match(/\d+/g)
|
||||
if (!match || !match.length) return 0
|
||||
return Number(match.join('')) || 0
|
||||
},
|
||||
async fetchLatestWinners() {
|
||||
try {
|
||||
const res = await getDrawLatestWinners()
|
||||
const winnersData = res && res.data
|
||||
const list = Array.isArray(winnersData)
|
||||
? winnersData
|
||||
: (Array.isArray(winnersData && winnersData.list) ? winnersData.list : [])
|
||||
this.latestWinnerList = list
|
||||
} catch (e) {
|
||||
this.latestWinnerList = []
|
||||
}
|
||||
},
|
||||
mapTabToStatus(tab) {
|
||||
const map = {
|
||||
wait: 0,
|
||||
@@ -158,6 +207,7 @@ export default {
|
||||
claimStatus: Number.isNaN(claimStatusNum) ? 0 : claimStatusNum,
|
||||
sourceOrderId: item.sourceOrderId || item.orderId || item.orderNo || '',
|
||||
drawTime: item.drawTime || item.openTime || '',
|
||||
claimDeadline: item.claimDeadline || '',
|
||||
prizeName: item.prizeName || item.awardName || '',
|
||||
prizeType: item.prizeType || item.awardType || '',
|
||||
prizeTypeName: item.prizeTypeName || item.awardTypeName || ''
|
||||
@@ -241,6 +291,34 @@ export default {
|
||||
const mm = String(date.getMinutes()).padStart(2, '0')
|
||||
return `${y}年${m}月${d}日 ${hh}:${mm}`
|
||||
},
|
||||
formatDateTime(time) {
|
||||
if (!time) return '--'
|
||||
const text = String(time).trim()
|
||||
const date = new Date(text.replace(/-/g, '/'))
|
||||
if (Number.isNaN(date.getTime())) return text
|
||||
const y = date.getFullYear()
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const d = String(date.getDate()).padStart(2, '0')
|
||||
const hh = String(date.getHours()).padStart(2, '0')
|
||||
const mm = String(date.getMinutes()).padStart(2, '0')
|
||||
const ss = String(date.getSeconds()).padStart(2, '0')
|
||||
return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
|
||||
},
|
||||
getClaimDeadlineText(item = {}) {
|
||||
return this.formatDateTime(item.claimDeadline || '')
|
||||
},
|
||||
getClaimDaysText(item = {}) {
|
||||
const drawTime = String(item.drawTime || '').trim()
|
||||
const claimDeadline = String(item.claimDeadline || '').trim()
|
||||
if (!drawTime || !claimDeadline) return '--'
|
||||
const drawDate = new Date(drawTime.replace(/-/g, '/'))
|
||||
const deadlineDate = new Date(claimDeadline.replace(/-/g, '/'))
|
||||
if (Number.isNaN(drawDate.getTime()) || Number.isNaN(deadlineDate.getTime())) return '--'
|
||||
const diff = deadlineDate.getTime() - drawDate.getTime()
|
||||
if (diff <= 0) return '0天'
|
||||
const days = Math.ceil(diff / (24 * 60 * 60 * 1000))
|
||||
return `${days}天`
|
||||
},
|
||||
async onClaim(item) {
|
||||
if (!item.id) return
|
||||
if (this.claiming) return
|
||||
@@ -428,6 +506,20 @@ export default {
|
||||
flex: 1;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
|
||||
.blue {
|
||||
color: #3b7cf6;
|
||||
}
|
||||
|
||||
.red {
|
||||
color: #cb302c;
|
||||
}
|
||||
}
|
||||
|
||||
.winner-swiper {
|
||||
flex: 1;
|
||||
height: 36rpx;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.tip-btn {
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<button v-else class="my-tickets-btn" @click="navToMyTickets">
|
||||
<text class="btn-text">我的抽奖码</text>
|
||||
</button>
|
||||
<view class="claim-tip">*请在7天内领取,过期失效</view>
|
||||
<view class="claim-tip">*请在{{ remainingClaimDays }}天内领取,过期失效</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -180,7 +180,8 @@ export default {
|
||||
showCouponSuccessPopup: false,
|
||||
showHistory: false,
|
||||
entryWithoutActivityId: false,
|
||||
historyList: []
|
||||
historyList: [],
|
||||
remainingClaimDays: 7
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@@ -364,6 +365,7 @@ export default {
|
||||
this.userWinList = this.mapUserWinList(filteredMyTicketList)
|
||||
this.hasWon = this.userWinList.length > 0 ? 1 : 0
|
||||
this.periodLabel = winnerData.periodNo || "01"
|
||||
this.remainingClaimDays = winnerData.remainingClaimDays || 7
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: "中奖数据加载失败",
|
||||
|
||||
Reference in New Issue
Block a user