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: { loading: false, orders: [] }, onLoad() { this.load() }, onShow() { this.load() }, load() { this.setData({ loading: true }) Promise.all([ listGoodsOrders().catch(() => []), listExpressOrders().catch(() => []), listGroupBuyOrders().catch(() => []) ]) .then(([goodsOrders, expressOrders, groupBuyOrders]) => { this.setData({ orders: toOrderCards({ goodsOrders, expressOrders, groupBuyOrders }) }) }) .catch((error) => wx.showToast({ title: error.message, icon: 'none' })) .finally(() => this.setData({ loading: false })) }, goDetail(event) { const { type, id } = event.currentTarget.dataset wx.navigateTo({ url: '/pages/orders/detail?type=' + type + '&id=' + id }) }, statusText(status) { return statusText(status) } })