feat: present miniapp orders with formatted status
This commit is contained in:
@@ -2,6 +2,7 @@ const { listGoodsOrders } = require('../../api/orderApi')
|
||||
const { listExpressOrders } = require('../../api/expressApi')
|
||||
const { listGroupBuyOrders } = require('../../api/groupBuyApi')
|
||||
const { statusText } = require('../../utils/request')
|
||||
const { toOrderCards } = require('../../utils/orderPresenter')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
@@ -25,35 +26,7 @@ Page({
|
||||
listGroupBuyOrders().catch(() => [])
|
||||
])
|
||||
.then(([goodsOrders, expressOrders, groupBuyOrders]) => {
|
||||
const orders = []
|
||||
;(goodsOrders || []).forEach((item) => orders.push({
|
||||
id: item.id,
|
||||
type: 'goods',
|
||||
typeText: '商品订单',
|
||||
orderNo: item.orderNo,
|
||||
title: item.orderNo,
|
||||
amountCent: item.payableAmountCent,
|
||||
status: item.status
|
||||
}))
|
||||
;(expressOrders || []).forEach((item) => orders.push({
|
||||
id: item.id,
|
||||
type: 'express',
|
||||
typeText: '快递代取',
|
||||
orderNo: item.orderNo,
|
||||
title: item.expressCompany + ' ' + item.pickupCode,
|
||||
amountCent: item.feeCent,
|
||||
status: item.status
|
||||
}))
|
||||
;(groupBuyOrders || []).forEach((item) => orders.push({
|
||||
id: item.id,
|
||||
type: 'group',
|
||||
typeText: '团购订单',
|
||||
orderNo: item.orderNo,
|
||||
title: item.groupBuyTitle,
|
||||
amountCent: item.amountCent,
|
||||
status: item.status
|
||||
}))
|
||||
this.setData({ orders })
|
||||
this.setData({ orders: toOrderCards({ goodsOrders, expressOrders, groupBuyOrders }) })
|
||||
})
|
||||
.catch((error) => wx.showToast({ title: error.message, icon: 'none' }))
|
||||
.finally(() => this.setData({ loading: false }))
|
||||
|
||||
Reference in New Issue
Block a user