feat: add resident miniapp MVP
This commit is contained in:
@@ -1 +1,56 @@
|
||||
Page({})
|
||||
const { getGoodsOrderDetail, cancelGoodsOrder } = require('../../api/orderApi')
|
||||
const { getExpressOrderDetail, cancelExpressOrder, completeExpressOrder } = require('../../api/expressApi')
|
||||
const { getGroupBuyOrderDetail, cancelGroupBuyOrder } = require('../../api/groupBuyApi')
|
||||
const { statusText } = require('../../utils/request')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
type: '',
|
||||
order: null
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.type = options.type
|
||||
this.id = Number(options.id)
|
||||
this.setData({ type: this.type })
|
||||
this.load()
|
||||
},
|
||||
|
||||
load() {
|
||||
const loaders = {
|
||||
goods: getGoodsOrderDetail,
|
||||
express: getExpressOrderDetail,
|
||||
group: getGroupBuyOrderDetail
|
||||
}
|
||||
loaders[this.type](this.id)
|
||||
.then((order) => this.setData({ order }))
|
||||
.catch((error) => wx.showToast({ title: error.message, icon: 'none' }))
|
||||
},
|
||||
|
||||
cancel() {
|
||||
const actions = {
|
||||
goods: () => cancelGoodsOrder(this.id),
|
||||
express: () => cancelExpressOrder(this.id, '用户取消'),
|
||||
group: () => cancelGroupBuyOrder(this.id)
|
||||
}
|
||||
actions[this.type]()
|
||||
.then(() => {
|
||||
wx.showToast({ title: '已取消' })
|
||||
this.load()
|
||||
})
|
||||
.catch((error) => wx.showToast({ title: error.message, icon: 'none' }))
|
||||
},
|
||||
|
||||
completeExpress() {
|
||||
completeExpressOrder(this.id)
|
||||
.then(() => {
|
||||
wx.showToast({ title: '已完成' })
|
||||
this.load()
|
||||
})
|
||||
.catch((error) => wx.showToast({ title: error.message, icon: 'none' }))
|
||||
},
|
||||
|
||||
statusText(status) {
|
||||
return statusText(status)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user