fix: restore lottery draw history list
This commit is contained in:
@@ -13,16 +13,24 @@
|
||||
</view>
|
||||
|
||||
<!-- 开奖列表 -->
|
||||
<z-paging ref="paging" v-model="drawList" @query="queryList" :fixed="false">
|
||||
<z-paging ref="paging" v-model="drawList" @query="queryList" :fixed="false" height="calc(100vh - 44px)">
|
||||
<view v-if="!drawList.length && !listLoading" class="draw-list__empty">
|
||||
<text class="draw-list__empty-icon">⌑</text>
|
||||
<text class="draw-list__empty-title">暂无开奖记录</text>
|
||||
<text class="draw-list__empty-desc">该彩种的历史开奖数据暂时不可用</text>
|
||||
<view v-if="listError" class="draw-list__retry" @tap="reloadList">
|
||||
<text>重新加载</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-for="item in drawList" :key="item.code + item.issue" class="draw-card">
|
||||
<view class="draw-card__header">
|
||||
<text class="draw-card__period">第 {{ item.issue }} 期</text>
|
||||
<text class="draw-card__date">{{ item.draw_time }}</text>
|
||||
<view class="draw-card__badge" :class="{ 'draw-card__badge--pending': item.status !== 1 }">
|
||||
<text>{{ item.status === 1 ? '已开奖' : '待开奖' }}</text>
|
||||
<view class="draw-card__badge" :class="{ 'draw-card__badge--pending': Number(item.status) !== 1 }">
|
||||
<text>{{ Number(item.status) === 1 ? '已开奖' : '待开奖' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="item.status === 1 && item.numbers?.length" class="draw-card__balls">
|
||||
<view v-if="Number(item.status) === 1 && item.numbers?.length" class="draw-card__balls">
|
||||
<template v-for="(ball, i) in item.numbers" :key="i">
|
||||
<text v-if="i === item.numbers.length - 1" class="ball__plus">+</text>
|
||||
<view class="ball-wrap">
|
||||
@@ -34,7 +42,7 @@
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
<view v-if="item.status !== 1" class="draw-card__pending">
|
||||
<view v-if="Number(item.status) !== 1" class="draw-card__pending">
|
||||
<text>等待开奖...</text>
|
||||
<view class="ai-predict-btn" @tap.stop="openAiPopup(item)">
|
||||
<view class="ai-predict-btn__pulse" />
|
||||
@@ -153,6 +161,8 @@ const gameTemplate = ref('')
|
||||
const categoryName = ref('')
|
||||
const drawList = ref<any[]>([])
|
||||
const latestDraw = ref<any>(null)
|
||||
const listLoading = ref(false)
|
||||
const listError = ref(false)
|
||||
const paging = shallowRef()
|
||||
|
||||
uni.getSystemInfo({
|
||||
@@ -171,6 +181,25 @@ const formatNum = (n: any) => {
|
||||
return num < 10 ? '0' + num : String(num)
|
||||
}
|
||||
|
||||
const decodeQueryValue = (value: any, fallback = '') => {
|
||||
let result = String(value ?? fallback)
|
||||
for (let i = 0; i < 3 && /%[0-9a-f]{2}/i.test(result); i++) {
|
||||
try {
|
||||
const decoded = decodeURIComponent(result)
|
||||
if (decoded === result) break
|
||||
result = decoded
|
||||
} catch {
|
||||
break
|
||||
}
|
||||
}
|
||||
return result || fallback
|
||||
}
|
||||
|
||||
const normalizeDrawList = (res: any) => {
|
||||
const source = res?.lists ?? res?.data?.lists ?? res?.records ?? res?.data?.records ?? res?.data
|
||||
return Array.isArray(source) ? source : []
|
||||
}
|
||||
|
||||
const fetchLatest = async () => {
|
||||
try {
|
||||
const data = await getLatestDrawResult({ code: gameCode.value })
|
||||
@@ -181,20 +210,42 @@ const fetchLatest = async () => {
|
||||
}
|
||||
|
||||
const queryList = async (pageNo: number, pageSize: number) => {
|
||||
listLoading.value = true
|
||||
listError.value = false
|
||||
try {
|
||||
if (!gameCode.value) {
|
||||
listError.value = true
|
||||
paging.value?.complete(false)
|
||||
return
|
||||
}
|
||||
const res = await getDrawResultList({
|
||||
code: gameCode.value,
|
||||
page_no: pageNo,
|
||||
page_size: pageSize
|
||||
})
|
||||
const lists = res?.lists || []
|
||||
const lists = normalizeDrawList(res).map((item: any) => ({
|
||||
...item,
|
||||
code: item.code || gameCode.value,
|
||||
status: Number(item.status) === 1 || Boolean(item.draw_code) ? 1 : 0,
|
||||
numbers: Array.isArray(item.numbers)
|
||||
? item.numbers
|
||||
: String(item.draw_code || '').split(',').filter(Boolean)
|
||||
}))
|
||||
lists.forEach((item: any) => { item.game_name = categoryName.value })
|
||||
paging.value?.complete(lists)
|
||||
} catch (e) {
|
||||
listError.value = true
|
||||
paging.value?.complete(false)
|
||||
} finally {
|
||||
listLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const reloadList = () => {
|
||||
listError.value = false
|
||||
paging.value?.reload()
|
||||
}
|
||||
|
||||
const goDetail = (item: any) => {
|
||||
uni.navigateTo({ url: `/packages_lottery/pages/detail?code=${item.code}&issue=${item.issue}` })
|
||||
}
|
||||
@@ -257,9 +308,9 @@ const goBack = () => {
|
||||
}
|
||||
|
||||
onLoad((options: any) => {
|
||||
gameCode.value = options.code || ''
|
||||
gameCode.value = decodeQueryValue(options.code)
|
||||
gameTemplate.value = options.template || ''
|
||||
categoryName.value = decodeURIComponent(options.name || '开奖记录')
|
||||
categoryName.value = decodeQueryValue(options.name, '开奖记录')
|
||||
fetchLatest()
|
||||
})
|
||||
</script>
|
||||
@@ -270,6 +321,49 @@ onLoad((options: any) => {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.draw-list__empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 180rpx 40rpx 120rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.draw-list__empty-icon {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 24rpx;
|
||||
border-radius: 50%;
|
||||
background: #e9edf5;
|
||||
color: #9aa4b2;
|
||||
font-size: 56rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.draw-list__empty-title {
|
||||
color: #4b5563;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.draw-list__empty-desc {
|
||||
margin-top: 12rpx;
|
||||
color: #9ca3af;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.draw-list__retry {
|
||||
margin-top: 28rpx;
|
||||
padding: 14rpx 40rpx;
|
||||
border-radius: 32rpx;
|
||||
background: #185dff;
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.page-no-scroll {
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
|
||||
Reference in New Issue
Block a user