@@ -44,11 +44,11 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
updateStatus(orderId, status) {
|
||||
updateStatus(orderId, status, cancelReason) {
|
||||
return request({
|
||||
url: `/manager/planning/appointments/${orderId}/status`,
|
||||
method: 'PUT',
|
||||
data: { status }
|
||||
data: { status, cancelReason }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ Page({
|
||||
return
|
||||
}
|
||||
try {
|
||||
await planningApi.updateStatus(this.data.appointment.orderId, status)
|
||||
await planningApi.updateStatus(this.data.appointment.orderId, status, this._cancelReason || '')
|
||||
markPlanningRefresh()
|
||||
wx.showToast({ title: '已更新' })
|
||||
this.loadDetail()
|
||||
@@ -65,7 +65,18 @@ Page({
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.updateStatus(3)
|
||||
wx.showModal({
|
||||
title: '取消预约',
|
||||
editable: true,
|
||||
placeholderText: '可填写取消原因',
|
||||
content: '',
|
||||
confirmText: '确认取消',
|
||||
success: result => {
|
||||
if (!result.confirm) return
|
||||
this._cancelReason = result.content || ''
|
||||
this.updateStatus(3)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
goTransfer() {
|
||||
|
||||
@@ -2,6 +2,7 @@ const authApi = require('../../api/auth')
|
||||
const auth = require('../../utils/auth')
|
||||
const { BRAND_CONFIG } = require('../../utils/config')
|
||||
const loginFlow = require('../../utils/login-flow')
|
||||
const { requestSubscribeMessages } = require('../../utils/subscribe-message')
|
||||
|
||||
function wxLoginCode() {
|
||||
return new Promise((resolve, reject) => wx.login({
|
||||
@@ -146,6 +147,8 @@ Page({
|
||||
async quickLogin() {
|
||||
if (this.data.loading || !(await this.ensureCanLogin())) return
|
||||
this._presentedLoginState = ''
|
||||
// 订阅授权是可选的,拒绝时仍继续登录;调用必须发生在用户点击登录链路中。
|
||||
await requestSubscribeMessages()
|
||||
const rememberMe = await this.chooseRememberMode()
|
||||
if (rememberMe === null) return
|
||||
this.setData({ rememberMe, loading: true })
|
||||
|
||||
@@ -835,18 +835,21 @@ Page({
|
||||
if (!appointment) return
|
||||
wx.showModal({
|
||||
title: '取消预约',
|
||||
content: '确定取消这条预约吗?',
|
||||
editable: true,
|
||||
placeholderText: '可填写取消原因',
|
||||
content: '',
|
||||
confirmText: '确认取消',
|
||||
success: result => {
|
||||
if (result.confirm) {
|
||||
this.updateAppointmentStatus(appointment.orderId, 3)
|
||||
this.updateAppointmentStatus(appointment.orderId, 3, result.content || '')
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async updateAppointmentStatus(orderId, status) {
|
||||
async updateAppointmentStatus(orderId, status, cancelReason) {
|
||||
try {
|
||||
await planningApi.updateStatus(orderId, status)
|
||||
await planningApi.updateStatus(orderId, status, cancelReason)
|
||||
wx.showToast({ title: '预约已取消', icon: 'success' })
|
||||
this.loadCalendar()
|
||||
} catch (error) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
const TEMPLATE_IDS = [
|
||||
'jURyVPL52qyUhm_c_OyvED5zivUZr_3LfAXjfV-KOJc',
|
||||
'0v80O2xaOS8D_aSrurqTo4fds8FmyMlEOsy66LXsjNQ',
|
||||
'Dmebp1afiB9U5rw_ASKiMEQWIqYNF8bSM4JPR4PZ5eo'
|
||||
]
|
||||
|
||||
function requestSubscribeMessages() {
|
||||
return new Promise(resolve => {
|
||||
if (!wx.requestSubscribeMessage) {
|
||||
resolve({})
|
||||
return
|
||||
}
|
||||
wx.requestSubscribeMessage({
|
||||
tmplIds: TEMPLATE_IDS,
|
||||
success: resolve,
|
||||
fail: () => resolve({})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { TEMPLATE_IDS, requestSubscribeMessages }
|
||||
@@ -0,0 +1,32 @@
|
||||
const assert = require('assert')
|
||||
|
||||
let requestOptions
|
||||
global.wx = {
|
||||
requestSubscribeMessage(options) {
|
||||
requestOptions = options
|
||||
options.success({
|
||||
[options.tmplIds[0]]: 'accept',
|
||||
[options.tmplIds[1]]: 'reject',
|
||||
[options.tmplIds[2]]: 'accept'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const { TEMPLATE_IDS, requestSubscribeMessages } = require('./subscribe-message')
|
||||
|
||||
async function run() {
|
||||
const result = await requestSubscribeMessages()
|
||||
assert.deepStrictEqual(requestOptions.tmplIds, TEMPLATE_IDS)
|
||||
assert.strictEqual(TEMPLATE_IDS.length, 3)
|
||||
assert.strictEqual(result[TEMPLATE_IDS[0]], 'accept')
|
||||
assert.strictEqual(result[TEMPLATE_IDS[1]], 'reject')
|
||||
assert.strictEqual(result[TEMPLATE_IDS[2]], 'accept')
|
||||
|
||||
global.wx.requestSubscribeMessage = options => options.fail(new Error('user cancelled'))
|
||||
assert.deepStrictEqual(await requestSubscribeMessages(), {})
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
Reference in New Issue
Block a user