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