feat: present miniapp orders with formatted status
This commit is contained in:
43
miniapp/miniprogram/utils/orderPresenter.js
Normal file
43
miniapp/miniprogram/utils/orderPresenter.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const { statusText, yuan } = require('./request')
|
||||
|
||||
function toOrderCards({ 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,
|
||||
amountText: '¥' + yuan(item.payableAmountCent),
|
||||
status: item.status,
|
||||
statusText: statusText(item.status)
|
||||
}))
|
||||
;(expressOrders || []).forEach((item) => orders.push({
|
||||
id: item.id,
|
||||
type: 'express',
|
||||
typeText: '快递代取',
|
||||
orderNo: item.orderNo,
|
||||
title: item.expressCompany + ' ' + item.pickupCode,
|
||||
amountCent: item.feeCent,
|
||||
amountText: '¥' + yuan(item.feeCent),
|
||||
status: item.status,
|
||||
statusText: statusText(item.status)
|
||||
}))
|
||||
;(groupBuyOrders || []).forEach((item) => orders.push({
|
||||
id: item.id,
|
||||
type: 'group',
|
||||
typeText: '团购订单',
|
||||
orderNo: item.orderNo,
|
||||
title: item.groupBuyTitle,
|
||||
amountCent: item.amountCent,
|
||||
amountText: '¥' + yuan(item.amountCent),
|
||||
status: item.status,
|
||||
statusText: statusText(item.status)
|
||||
}))
|
||||
return orders
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
toOrderCards
|
||||
}
|
||||
Reference in New Issue
Block a user