Files
llpreheat/pages/hj-win-records/hj-win-records.vue
T

493 lines
10 KiB
Vue

<template>
<view class="content">
<view class="page-bg" :style="{ position: 'absolute', top: 0, left: 0, width: '750rpx', height: bgHeight + 'px', backgroundImage: 'url(https://aliyunoss.hn12301.net/learnlaw/xfhj_dtbj.jpg)', backgroundSize: 'cover', backgroundPosition: 'top center', backgroundRepeat: 'no-repeat', zIndex: 0 }"></view>
<view class="page-body">
<view class="login-box" v-if="!isLoggedIn">
<text class="login-tip">注册后可查看中奖记录</text>
<button class="login-btn" @tap="goRegister">立即注册</button>
</view>
<template v-if="isLoggedIn">
<view class="empty-box" v-if="!lotteryStarted">
<text class="empty-icon">🎁</text>
<text class="empty-text">暂未开始抽奖</text>
</view>
<template v-else>
<view class="record-list" v-if="list.length > 0">
<view class="record-item" v-for="(item, i) in list" :key="i">
<view class="record-icon">
<text class="iconfont">🎁</text>
</view>
<view class="record-info">
<text class="record-prize">{{ item.title }}</text>
<text class="record-desc">{{ item.is_win_pc_desc }}</text>
<text class="record-status">{{ item.status_desc }}</text>
</view>
<view class="record-right">
<text class="record-time">{{ item.time }}</text>
<view class="btn-row">
<button class="winlist-btn" v-if="isEnded(item)" @tap="showWinList(item)">中奖名单</button>
</view>
</view>
</view>
</view>
<view class="empty-box" v-if="list.length === 0">
<text class="empty-icon">🏆</text>
<text class="empty-text">暂无中奖记录</text>
</view>
</template>
</template>
</view>
<view class="modal-mask" v-if="showWinModal" @tap="closeWinModal"></view>
<view class="modal win-modal" v-if="showWinModal && currentItem">
<view class="modal-header">
<text class="modal-title">中奖名单</text>
<text class="modal-close" @tap="closeWinModal">✕</text>
</view>
<view class="win-search">
<input class="win-search-input" v-model="currentItem.searchKey" placeholder="搜索中奖人姓名或手机号" confirm-type="search" @confirm="searchWinList" />
<view class="win-search-btn" @tap="searchWinList">
<text class="win-search-btn-txt">查询</text>
</view>
</view>
<view class="win-list">
<view class="win-item" v-for="(w, wi) in currentItem.winList" :key="wi">
<view class="win-congrats">
<text>恭喜中奖</text>
</view>
<text class="win-name">{{ w.user_name }}</text>
<text class="win-phone">{{ w.user_phone }}</text>
</view>
<view class="win-empty" v-if="currentItem.winLoading">
<text>名单加载中...</text>
</view>
<view class="win-empty" v-else-if="currentItem.winList.length === 0">
<text>{{ (currentItem.searchKey || '').trim() ? '暂无匹配的中奖人' : '暂无中奖名单' }}</text>
</view>
</view>
</view>
<hj-tabbar current="winRecords"></hj-tabbar>
</view>
</template>
<script>
import hjTabbar from '@/components/hj-tabbar/hj-tabbar.vue'
export default {
components: {
hjTabbar
},
data() {
return {
isLoggedIn: false,
lotteryStarted: true,
list: [],
showWinModal: false,
currentItem: null,
bgHeight: 0
}
},
onLoad() {
const sys = uni.getSystemInfoSync();
this.bgHeight = sys.windowHeight
},
onShow() {
this.checkLogin()
},
methods: {
checkLogin() {
const userId = uni.getStorageSync('userIdHj')
if (userId) {
this.isLoggedIn = true
if (this.lotteryStarted) {
this.fetchList(userId)
}
} else {
this.isLoggedIn = false
}
},
goRegister() {
uni.navigateTo({ url: '/pages/hj-register/hj-register' })
},
fetchList(userId) {
this.$u.api.getChouJiangResult({
user_id: userId,
wenjuan_id: 1007
}).then(res => {
if (res.code === 0) {
const data = res.Data || {}
let arr = data.list || data.records || data || []
if (!Array.isArray(arr)) arr = []
arr.forEach(it => {
it.winList = []
it.winLoading = false
it.winLoaded = false
it.searchKey = ''
})
this.list = arr
} else {
uni.showToast({ title: res.msg || '加载失败', icon: 'none' })
}
}).catch(() => {
uni.showToast({ title: '网络异常', icon: 'none' })
})
},
isEnded(item) {
return String(item.status_desc || '').indexOf('已结束') > -1
},
showWinList(item) {
this.currentItem = item
this.showWinModal = true
if (!item.winLoaded && !item.winLoading) {
this.fetchWinList(item)
}
},
searchWinList() {
if (this.currentItem) {
this.fetchWinList(this.currentItem)
}
},
fetchWinList(item) {
const params = {
wenjuan_id: 1007,
period: item.index,
searchKey: (item.searchKey || '').trim()
}
item.winLoading = true
this.$u.api.getWenjuanWinDetailList(params).then(res => {
let arr = []
if (res && res.code === 0) {
if (Array.isArray(res.Data)) arr = res.Data
else if (res.Data && Array.isArray(res.Data.list)) arr = res.Data.list
} else if (res && res.code !== 0) {
uni.showToast({ title: res.msg || '查询失败', icon: 'none' })
}
item.winList = arr
item.winLoaded = true
}).catch(() => {
item.winList = []
}).finally(() => {
item.winLoading = false
})
},
closeWinModal() {
this.showWinModal = false
}
}
}
</script>
<style lang="scss">
page {
background-color: #B3E9F3;
}
.content {
position: relative;
display: flex;
flex-direction: column;
height: 100vh;
height: 100dvh;
overflow: hidden;
}
.page-body {
position: relative;
z-index: 1;
flex: 1;
display: flex;
flex-direction: column;
padding: 350rpx 30rpx 140rpx;
box-sizing: border-box;
overflow: hidden;
}
.login-box {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
.login-tip {
font-size: 28rpx;
color: rgba(255,255,255,0.85);
margin-bottom: 30rpx;
}
.login-btn {
width: 400rpx;
height: 80rpx;
line-height: 80rpx;
background: linear-gradient(135deg, #FD5401, #FF7A3D);
color: #fff;
font-size: 30rpx;
font-weight: 600;
border: none;
border-radius: 40rpx;
box-shadow: 0 4rpx 16rpx rgba(253,84,1,0.3);
}
.record-list {
flex: 1;
min-height: 0;
overflow-y: auto;
background: rgba(255,255,255,0.95);
border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
}
.record-item {
display: flex;
align-items: center;
padding: 28rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.record-item:last-child {
border-bottom: none;
}
.record-icon {
width: 56rpx;
height: 56rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-right: 16rpx;
background: #fff7e6;
border-radius: 50%;
}
.record-icon .iconfont {
font-size: 32rpx;
}
.record-info {
flex: 1;
min-width: 0;
}
.record-prize {
font-size: 28rpx;
color: #333;
font-weight: 500;
display: block;
}
.record-desc {
font-size: 22rpx;
color: #999;
margin-top: 4rpx;
display: block;
}
.record-status {
font-size: 22rpx;
color: #FD5401;
margin-top: 4rpx;
display: block;
}
.record-right {
display: flex;
flex-direction: column;
align-items: stretch;
flex-shrink: 0;
margin-left: 16rpx;
min-width: 260rpx;
}
.record-time {
font-size: 22rpx;
color: #bbb;
margin-bottom: 8rpx;
text-align: right;
width: 100%;
}
.btn-row {
display: flex;
align-items: center;
gap: 12rpx;
width: 100%;
}
.winlist-btn {
flex: 1;
height: 60rpx;
line-height: 60rpx;
background: linear-gradient(135deg, #E0B866, #F0D08A);
color: #fff;
font-size: 24rpx;
font-weight: 600;
border: none;
border-radius: 30rpx;
padding: 0 12rpx;
margin: 0;
letter-spacing: 0;
text-align: center;
}
.modal-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.5);
z-index: 100;
}
.modal {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 600rpx;
background: #fff;
border-radius: 24rpx;
z-index: 101;
overflow: hidden;
}
.modal-header {
display: flex;
align-items: center;
justify-content: center;
padding: 30rpx 30rpx 20rpx;
position: relative;
}
.modal-title {
font-size: 32rpx;
font-weight: 700;
color: #333;
}
.modal-close {
position: absolute;
right: 30rpx;
top: 30rpx;
font-size: 28rpx;
color: #999;
padding: 8rpx;
}
.win-modal {
max-height: 80vh;
display: flex;
flex-direction: column;
}
.win-search {
display: flex;
align-items: center;
padding: 0 30rpx 20rpx;
}
.win-search-input {
flex: 1;
height: 68rpx;
line-height: 68rpx;
background: #F5F5F5;
border-radius: 34rpx;
padding: 0 28rpx;
font-size: 24rpx;
color: #333;
box-sizing: border-box;
}
.win-search-btn {
flex-shrink: 0;
margin-left: 16rpx;
height: 68rpx;
line-height: 68rpx;
padding: 0 28rpx;
border-radius: 34rpx;
background: linear-gradient(135deg, #FD5401, #FF7A3D);
box-shadow: 0 4rpx 12rpx rgba(253,84,1,0.3);
}
.win-search-btn-txt {
font-size: 24rpx;
color: #fff;
font-weight: 600;
}
.win-list {
flex: 1;
max-height: 60vh;
overflow-y: auto;
padding: 0 30rpx 30rpx;
}
.win-item {
display: flex;
align-items: center;
padding: 22rpx 0;
border-bottom: 1rpx solid #f0f0f0;
}
.win-item:last-child {
border-bottom: none;
}
.win-congrats {
width: 140rpx;
height: 44rpx;
line-height: 44rpx;
text-align: center;
border-radius: 22rpx;
font-size: 22rpx;
color: #fff;
flex-shrink: 0;
margin-right: 16rpx;
background: linear-gradient(135deg, #FD5401, #FF7A3D);
box-shadow: 0 2rpx 8rpx rgba(253,84,1,0.3);
}
.win-name {
flex: 1;
font-size: 28rpx;
color: #333;
font-weight: 500;
min-width: 0;
}
.win-phone {
font-size: 24rpx;
color: #999;
flex-shrink: 0;
margin-left: 16rpx;
}
.win-empty {
text-align: center;
font-size: 26rpx;
color: #999;
padding: 60rpx 0;
}
.empty-box {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 80rpx 0;
}
.empty-icon {
font-size: 80rpx;
margin-bottom: 16rpx;
}
.empty-text {
font-size: 26rpx;
color: rgba(255,255,255,0.7);
}
</style>