fix: 修复预约页脚本语法错误
This commit is contained in:
1 parent
3ddef14c08
commit
5ab8c34a78
1 file changed
+11
-1
@@ -12,7 +12,17 @@ Page({
|
||||
if (!form.customerName || !form.wechatId) return wx.showToast({ title: '请填写称呼和联系方式', icon: 'none' });
|
||||
if (this.data.fulfillment === 'delivery' && !form.deliveryAddress) return wx.showToast({ title: '请填写配送地址', icon: 'none' });
|
||||
this.setData({ submitting: true });
|
||||
const send = () => customerRequest('/customer/bookings', { method: 'POST', data: { requestType: 'package', customerName: form.customerName, wechatId: form.wechatId, contactPreference: 'wechat', fulfillmentType: this.data.fulfillment, deliveryAddress: form.deliveryAddress, requestedTime: form.requestedTime, note: form.note, items: [{ serviceId: this.data.serviceId, quantity: this.data.quantity }] }).then(() => { this.setData({ submitting: false }); wx.showToast({ title: '预约已提交' }); setTimeout(() => wx.navigateTo({ url: '/pages/bookings/index' }), 500); }).catch((error) => { this.setData({ submitting: false }); wx.showToast({ title: error.message || '提交失败', icon: 'none' }); });
|
||||
const send = () => customerRequest('/customer/bookings', {
|
||||
method: 'POST',
|
||||
data: { requestType: 'package', customerName: form.customerName, wechatId: form.wechatId, contactPreference: 'wechat', fulfillmentType: this.data.fulfillment, deliveryAddress: form.deliveryAddress, requestedTime: form.requestedTime, note: form.note, items: [{ serviceId: this.data.serviceId, quantity: this.data.quantity }] },
|
||||
}).then(() => {
|
||||
this.setData({ submitting: false });
|
||||
wx.showToast({ title: '预约已提交' });
|
||||
setTimeout(() => wx.navigateTo({ url: '/pages/bookings/index' }), 500);
|
||||
}).catch((error) => {
|
||||
this.setData({ submitting: false });
|
||||
wx.showToast({ title: error.message || '提交失败', icon: 'none' });
|
||||
});
|
||||
const token = wx.getStorageSync('customerToken');
|
||||
if (token) return send();
|
||||
wx.login({ success: (login) => request('/customer/session/wechat', { method: 'POST', data: { code: login.code } }).then((result) => { wx.setStorageSync('customerToken', result.token); send(); }).catch((error) => { this.setData({ submitting: false }); wx.showToast({ title: error.message || '微信登录失败', icon: 'none' }); }), fail: (error) => { this.setData({ submitting: false }); wx.showToast({ title: error.errMsg || '微信登录失败', icon: 'none' }); } });
|
||||
|
||||
Reference in new issue
Block a user