订单排序

This commit is contained in:
wangsongsole 2022-09-28 16:35:26 +08:00
parent cd76c1196b
commit 53cc53ad63
2 changed files with 17 additions and 6 deletions

View File

@ -41,7 +41,7 @@
</p>
</div>
<div class="right-box">
<p class="right-box-title">满{{item.full}}元减{{item.reduce}}券</p>
<p class="right-box-title">满{{item.full}}元减{{item.reduce}}</p>
<p class="right-box-time">{{item.begin_time}} - {{item.end_time}}</p>
<div class="right-box-bottom"
:style="{borderBottom:(more===item.id?'0.01rem solid #D7D7D7':'0')}">
@ -128,6 +128,8 @@
if (code === 200) {
const productArray = []
data.map(item => {
item.full = Number(item.full).toFixed(0)
item.reduce = Number(item.reduce).toFixed(0)
item.product.legal.map(items => {
productArray.push({
name: items.product_name,
@ -147,7 +149,6 @@
item.productArray = productArray
})
this.couponList = data
console.log(data);
}
})
}

View File

@ -25,7 +25,7 @@
<div class="content">
<div class="content-item" v-for="item in orderList" :key="item.order_number">
<div class="top">
<p class="time">{{item.create_time}}</p>
<p class="time">{{item.update_time}}</p>
<p class="status" :style="{color:statusColor(item.status).color}">{{statusColor(item.status).text}}
</p>
</div>
@ -96,7 +96,7 @@
colorValue.color = '#F28542'
colorValue.text = '待支付'
break;
case 3:
case 4:
colorValue.color = '#4193EE'
colorValue.text = '已支付'
break;
@ -119,15 +119,25 @@
/* 去兑换 */
goExchange (item) {
window.location.replace('./couponCollection.html');
console.log(item);
},
/* 请求订单数据 */
getOrderList () {
const key = sessionStorage.getItem('key')
req.axiosGet(`/key/order/${key}`, { page: this.page, limit: this.limit }).then(({ data, code }) => {
if (code === 200) this.orderList = data
if (code === 200) {
const filterData1 = this.sortData(data.filter(item => ![4, 6].includes(item.status)))
const filterData2 = this.sortData(data.filter(item => item.status === 4))
const filterData3 = this.sortData(data.filter(item => item.status === 6))
const newData = [...filterData3, ...filterData2, ...filterData1]
this.orderList = newData
}
})
},
/* 排序 */
sortData (data) {
return data.sort((a, b) => a.update_time - b.update_time)
}
}
})