Fix:5232 【商城小程序】我的抽奖码页面,缺了状态分类
This commit is contained in:
@@ -1,28 +1,18 @@
|
||||
<template>
|
||||
<view class="county-my-tickets-page">
|
||||
<!-- <view class="custom-header" :style="{ paddingTop: `${statusBarHeight}px` }">
|
||||
<view class="header-inner">
|
||||
<view class="header-back" @click="goBack">
|
||||
<u-icon name="arrow-left" size="24" color="#333" class="header-back-icon"></u-icon>
|
||||
</view>
|
||||
<view class="header-title">我的抽奖码</view>
|
||||
<view class="header-right">
|
||||
<view class="right-dot"></view>
|
||||
<view class="right-ring"></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="custom-header">
|
||||
<view class="tabs">
|
||||
<view
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
class="tab-item"
|
||||
class="tab-item v12-font-bold"
|
||||
:class="{ active: activeTab === tab.key }"
|
||||
@click="onChangeTab(tab.key)"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<scroll-view class="page-body" scroll-y>
|
||||
<view class="tip-bar">
|
||||
@@ -188,6 +178,15 @@ export default {
|
||||
}
|
||||
return map[tab]
|
||||
},
|
||||
mergeTicketListById(list = []) {
|
||||
const map = new Map()
|
||||
list.forEach(item => {
|
||||
if (!item) return
|
||||
const key = item.id || item.ticketId || item.lotteryRecordId || item.recordId || Math.random()
|
||||
map.set(String(key), item)
|
||||
})
|
||||
return Array.from(map.values())
|
||||
},
|
||||
normalizeListData(res) {
|
||||
if (!res) return []
|
||||
if (Array.isArray(res)) return res
|
||||
@@ -243,11 +242,25 @@ export default {
|
||||
async fetchList() {
|
||||
this.loading = true
|
||||
try {
|
||||
const status = this.mapTabToStatus(this.activeTab)
|
||||
const res = await getDrawMyTickets(status)
|
||||
const allList = this.filterByActivity(this.normalizeListData(res).map(this.normalizeTicketItem))
|
||||
this.openedList = allList.filter(item => item.status === 1 || item.status === 2)
|
||||
this.list = this.filterByTab(allList)
|
||||
// 已开奖需要包含:1-已中奖、2-未中奖
|
||||
if (this.activeTab === 'opened') {
|
||||
const [winRes, loseRes] = await Promise.all([
|
||||
getDrawMyTickets(1),
|
||||
getDrawMyTickets(2)
|
||||
])
|
||||
const winList = this.normalizeListData(winRes).map(this.normalizeTicketItem)
|
||||
const loseList = this.normalizeListData(loseRes).map(this.normalizeTicketItem)
|
||||
const merged = this.mergeTicketListById([...winList, ...loseList])
|
||||
const openedAllList = this.filterByActivity(merged)
|
||||
this.openedList = openedAllList
|
||||
this.list = openedAllList
|
||||
} else {
|
||||
const status = this.mapTabToStatus(this.activeTab)
|
||||
const res = await getDrawMyTickets(status)
|
||||
const allList = this.filterByActivity(this.normalizeListData(res).map(this.normalizeTicketItem))
|
||||
this.openedList = allList.filter(item => item.status === 1 || item.status === 2)
|
||||
this.list = this.filterByTab(allList)
|
||||
}
|
||||
} catch (e) {
|
||||
this.list = []
|
||||
this.openedList = []
|
||||
@@ -488,6 +501,7 @@ export default {
|
||||
color: #666;
|
||||
font-size: 26rpx;
|
||||
background: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tab-item.active {
|
||||
|
||||
Reference in New Issue
Block a user