feat: add resident miniapp MVP
This commit is contained in:
@@ -1 +1,70 @@
|
||||
Page({})
|
||||
const { listGoodsOrders } = require('../../api/orderApi')
|
||||
const { listExpressOrders } = require('../../api/expressApi')
|
||||
const { listGroupBuyOrders } = require('../../api/groupBuyApi')
|
||||
const { statusText } = require('../../utils/request')
|
||||
|
||||
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]) => {
|
||||
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 })
|
||||
})
|
||||
.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)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user