feat: present miniapp orders with formatted status

This commit is contained in:
王鹏
2026-07-07 17:56:56 +08:00
parent 48dc5a0c13
commit 18bd5497cd
4 changed files with 65 additions and 32 deletions

View File

@@ -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 }))

View File

@@ -6,11 +6,11 @@
<view>{{item.title}}</view>
<view class="muted">{{item.typeText}} {{item.orderNo}}</view>
</view>
<view class="tag">{{item.status}}</view>
<view class="tag">{{item.statusText}}</view>
</view>
<view class="row between">
<view class="muted">状态:{{item.status}}</view>
<view class="price">¥{{item.amountCent / 100}}</view>
<view class="muted">状态:{{item.statusText}}</view>
<view class="price">{{item.amountText}}</view>
</view>
</view>
<view wx:if="{{!orders.length && !loading}}" class="card muted">暂无订单</view>