Feat:抽奖2.0(部分接口未调通)

This commit is contained in:
LinCyJang
2026-04-27 08:47:33 +08:00
parent 0202f14073
commit d3602c010e
11 changed files with 2718 additions and 29 deletions
+692
View File
@@ -0,0 +1,692 @@
<template>
<view class="winners-page">
<view class="custom-header" :style="{ paddingTop: `${statusBarHeight}px` }">
<view class="header-inner">
<view class="header-back" @click="goBack">
<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="period-side left">
<text class="side-text">第{{ periodLabel }}期</text>
</view>
<view class="period-side right">
<view class="side-text side-text-count">
<text>往</text>
<text>期</text>
<text>中</text>
<text>奖</text>
<text>名</text>
<text>单</text>
</view>
</view>
<view class="draw-main">
<view class="draw-title">本期已开奖</view>
<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-subtitle">
您的抽奖码 <text class="code">{{ userWinList[0].ticketCode }}</text> 获得了
</view>
<view class="prize-card" v-for="(prize, index) in userWinList" :key="index">
<view class="prize-img-wrap">
<image class="prize-img" :src="prize.prizeImage" mode="aspectFill"></image>
</view>
<view class="prize-info">
<view class="prize-name-wrap">
<text class="prize-level">{{ prize.levelName }}:</text>
<text class="prize-name">{{ prize.prizeName }}</text>
</view>
<view class="prize-desc">{{ prize.prizeDesc || "默认" }}</view>
</view>
</view>
<button class="my-tickets-btn" @click="handleClaimNow">
<text class="btn-text">立即领取</text>
</button>
<view class="claim-tip">*请在7天内领取,过期失效</view>
</view>
<view class="winners-list-wrap">
<view class="list-title-badge">
<text class="gift-icon">🎁</text>
<text class="title-text">中奖名单</text>
</view>
<view class="list-content">
<view class="list-item" v-for="(item, index) in activityWinnerList" :key="index">
<view class="item-left">
<view class="item-prize">
<text class="level">{{ item.levelName }}:</text>
<text class="name">{{ item.prizeName }}</text>
</view>
<view class="item-code">
中奖码:<text class="code-text">{{ item.ticketCode }}</text>
</view>
</view>
<view class="item-right">
<view class="user-name">{{ item.realName }}</view>
<view class="user-phone">{{ item.phone }}</view>
</view>
</view>
<view class="empty-text" v-if="activityWinnerList.length === 0">暂无中奖名单</view>
</view>
</view>
</view>
<view class="coupon-popup-mask" v-if="showCouponSuccessPopup" @click="closeCouponSuccessPopup">
<view class="coupon-popup" @click.stop>
<view class="popup-close" @click="closeCouponSuccessPopup">×</view>
<view class="popup-icon-wrap">
<text class="popup-icon">🎉</text>
</view>
<view class="popup-title">领取成功</view>
<view class="popup-desc">您的奖品已经领取成功,请前往“我的优惠券”查看详情</view>
<view class="popup-btn" @click="goMyCoupons">去查看我的优惠券</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
statusBarHeight: 20,
periodLabel: "01",
drawTime: "2026年5月30日",
hasWon: 1,
userWinList: [],
activityWinnerList: [],
loaded: false,
showCouponSuccessPopup: false
}
},
onLoad() {
const systemInfo = uni.getSystemInfoSync()
this.statusBarHeight = systemInfo.statusBarHeight || 20
this.fetchData()
},
methods: {
goBack() {
uni.navigateBack()
},
navToMyTickets() {
uni.navigateTo({
url: '/pkg-video/views/county-my-tickets'
})
},
handleClaimNow() {
if (!this.userWinList.length) return
const allCouponPrize = this.userWinList.every((item) => this.isCouponPrize(item))
if (allCouponPrize) {
this.showCouponSuccessPopup = true
return
}
if (this.userWinList.length === 1) {
this.navToReceiveInfo(this.userWinList[0])
return
}
this.navToMyTickets()
},
isCouponPrize(prize = {}) {
const prizeType = Number(prize.prizeType)
const prizeName = String(prize.prizeName || "")
return prizeType === 3 || prize.prizeType === "coupon" || /券/.test(prizeName)
},
navToReceiveInfo(prize = {}) {
const query = `?source=lottery&ticketCode=${encodeURIComponent(prize.ticketCode || "")}&prizeName=${encodeURIComponent(prize.prizeName || "")}`
uni.navigateTo({
url: `/pages/user/address/AddAddress/index${query}`
})
},
closeCouponSuccessPopup() {
this.showCouponSuccessPopup = false
},
goMyCoupons() {
this.showCouponSuccessPopup = false
uni.navigateTo({
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" }
]
}
this.hasWon = mockData.hasWon
this.userWinList = mockData.userWinList
this.activityWinnerList = mockData.activityWinnerList
this.loaded = true
}
}
}
</script>
<style lang="less" scoped>
.winners-page {
min-height: 100vh;
background: #f4f6f8;
padding-bottom: 48rpx;
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
}
.custom-header {
position: sticky;
top: 0;
left: 0;
right: 0;
z-index: 99;
background-color: #fff;
.header-inner {
height: 44px;
display: flex;
align-items: center;
position: relative;
padding: 0 24rpx;
.header-back {
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 8rpx;
.header-back-icon {
font-size: 60rpx;
color: #333;
margin-top: -4rpx;
}
}
.header-title {
flex: 1;
text-align: center;
font-size: 34rpx;
font-weight: 700;
color: #333;
}
.header-actions {
width: 120rpx;
height: 56rpx;
border-radius: 28rpx;
display: flex;
align-items: center;
justify-content: space-around;
padding: 0 16rpx;
.dot {
font-size: 22rpx;
color: #333;
font-weight: bold;
letter-spacing: 2rpx;
}
.circle-dot {
width: 20rpx;
height: 20rpx;
border: 3rpx solid #333;
border-radius: 50%;
position: relative;
&::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 6rpx;
height: 6rpx;
background: #333;
border-radius: 50%;
}
}
}
}
}
.content-wrap {
padding: 28rpx 24rpx 0;
}
.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;
.period-side {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 54rpx;
height: 152rpx;
border: 4rpx solid #1f1f1f;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
background: #fff4d1;
padding-bottom: 15rpx;
.side-text {
writing-mode: vertical-rl;
font-size: 24rpx;
line-height: 1.1;
font-weight: 900;
letter-spacing: 2rpx;
color: #1f1f1f;
}
.side-text-count {
writing-mode: horizontal-tb;
height: 132rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
letter-spacing: 0;
line-height: 1;
}
&.left {
left: -10rpx;
background: #fff7df;
}
&.right {
right: -10rpx;
background: #ffbe12;
}
}
.draw-main {
flex: 1;
border: 2rpx dashed #bcc3cd;
border-radius: 16rpx;
text-align: center;
padding: 18rpx 12rpx;
}
.draw-title {
font-size: 58rpx;
line-height: 1.05;
color: #d73222;
font-weight: 900;
letter-spacing: 1rpx;
margin-bottom: 8rpx;
}
.draw-time {
font-size: 30rpx;
color: #222;
font-weight: 800;
}
}
.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;
.win-badge {
position: absolute;
top: -34rpx;
left: 50%;
transform: translateX(-50%);
width: 390rpx;
height: 72rpx;
background: #ffca1c;
border: 4rpx solid #1f1f1f;
border-radius: 18rpx;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 5rpx 0 #d49400;
.win-badge-text {
font-size: 52rpx;
font-weight: 900;
color: #fff;
text-shadow: -2rpx -2rpx 0 #1f1f1f, 2rpx -2rpx 0 #1f1f1f, -2rpx 2rpx 0 #1f1f1f, 2rpx 2rpx 0 #1f1f1f, 0 4rpx 0 #1f1f1f;
letter-spacing: 1rpx;
}
}
.win-banner-subtitle {
font-size: 28rpx;
color: #fff;
margin-bottom: 20rpx;
margin-top: 8rpx;
font-weight: 700;
.code {
font-weight: 900;
font-size: 40rpx;
margin: 0 8rpx;
color: #ffe8db;
}
}
.prize-card {
background: #fffdf5;
border: 4rpx solid #1f1f1f;
border-radius: 20rpx;
padding: 12rpx;
display: flex;
align-items: flex-start;
margin-bottom: 18rpx;
text-align: left;
box-shadow: inset 0 0 0 2rpx #fff;
.prize-img-wrap {
width: 132rpx;
height: 132rpx;
border-radius: 12rpx;
border: 2rpx dashed #b3b3b3;
padding: 4rpx;
margin-right: 18rpx;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
.prize-img {
width: 100%;
height: 100%;
border-radius: 8rpx;
}
}
.prize-info {
flex: 1;
padding-top: 8rpx;
.prize-name-wrap {
font-size: 40rpx;
color: #222;
margin-bottom: 10rpx;
line-height: 1.2;
.prize-level {
font-weight: 900;
}
.prize-name {
font-weight: 700;
}
}
.prize-desc {
font-size: 34rpx;
color: #8c8c8c;
font-weight: 600;
}
}
}
.my-tickets-btn {
background: linear-gradient(180deg, #ffd33d 0%, #ffb300 100%);
border: 4rpx solid #1f1f1f;
border-radius: 48rpx;
padding: 0;
height: 90rpx;
width: 92%;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
box-shadow: inset 0 -8rpx 0 rgba(0, 0, 0, 0.12), 0 8rpx 0 #1f1f1f;
transition: all 0.1s;
&:active {
transform: translateY(4rpx);
box-shadow: inset 0 -4rpx 0 rgba(0, 0, 0, 0.12), 0 4rpx 0 #1f1f1f;
}
.btn-text {
font-size: 50rpx;
font-weight: 900;
color: #fff;
text-shadow: -2rpx -2rpx 0 #1f1f1f, 2rpx -2rpx 0 #1f1f1f, -2rpx 2rpx 0 #1f1f1f, 2rpx 2rpx 0 #1f1f1f, 0 4rpx 0 #1f1f1f;
letter-spacing: 2rpx;
}
}
.claim-tip {
margin-top: 16rpx;
color: #fff0de;
font-size: 30rpx;
font-weight: 700;
}
}
.winners-list-wrap {
background: #fff;
border-radius: 28rpx;
padding: 46rpx 24rpx 10rpx;
position: relative;
box-shadow: 0 5rpx 0 #e6e8ec;
.list-title-badge {
position: absolute;
left: 50%;
top: -30rpx;
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;
.gift-icon {
font-size: 28rpx;
margin-right: 8rpx;
}
.title-text {
font-size: 34rpx;
font-weight: 900;
color: #222;
}
}
.list-content {
.list-item {
display: flex;
justify-content: space-between;
align-items: flex-start;
padding: 24rpx 0;
border-bottom: 2rpx solid #f1f1f1;
&:last-child {
border-bottom: none;
}
.item-left {
flex: 1;
.item-prize {
font-size: 36rpx;
color: #333;
margin-bottom: 8rpx;
line-height: 1.25;
.level {
font-weight: 900;
}
.name {
font-weight: 700;
}
}
.item-code {
font-size: 32rpx;
color: #666;
font-weight: 700;
.code-text {
color: #d8392b;
font-weight: 900;
}
}
}
.item-right {
margin-left: 16rpx;
text-align: right;
.user-name {
font-size: 32rpx;
color: #666;
font-weight: 700;
margin-bottom: 8rpx;
}
.user-phone {
font-size: 30rpx;
color: #999;
font-weight: 600;
}
}
}
.empty-text {
text-align: center;
padding: 60rpx 0;
color: #999;
font-size: 28rpx;
}
}
}
.coupon-popup-mask {
position: fixed;
inset: 0;
z-index: 1000;
background: rgba(0, 0, 0, 0.55);
display: flex;
align-items: center;
justify-content: center;
padding: 24rpx;
}
.coupon-popup {
width: 100%;
max-width: 620rpx;
background: #fff;
border-radius: 32rpx;
padding: 26rpx 34rpx 42rpx;
position: relative;
}
.popup-close {
position: absolute;
right: 18rpx;
top: 18rpx;
width: 40rpx;
height: 40rpx;
border-radius: 50%;
border: 2rpx solid #333;
font-size: 40rpx;
font-weight: 700;
color: #333;
line-height: 40rpx;
text-align: center;
}
.popup-icon-wrap {
width: 112rpx;
height: 112rpx;
margin: 20rpx auto 8rpx;
border-radius: 8rpx;
display: flex;
align-items: center;
justify-content: center;
}
.popup-icon {
font-size: 70rpx;
}
.popup-title {
text-align: center;
font-size: 60rpx;
font-weight: 900;
color: #222;
margin-top: 12rpx;
}
.popup-desc {
margin: 38rpx auto 42rpx;
text-align: center;
font-size: 28rpx;
line-height: 1.6;
color: #9a9a9a;
width: 92%;
}
.popup-btn {
width: 86%;
height: 96rpx;
margin: 0 auto;
border-radius: 48rpx;
background: #c43124;
color: #fff;
font-size: 40rpx;
font-weight: 900;
text-align: center;
line-height: 96rpx;
letter-spacing: 2rpx;
}
</style>