fix: 修复小程序取消预约请求体

This commit is contained in:
que01 committed 2026-09-19 11:42:26 +08:00
1 parent e19b6258d7
commit cd242767a6
1 file changed
+1 -1
+1 -1
View File
@@ -1,2 +1,2 @@
const API=getApp().globalData.apiBaseUrl;
Page({data:{loading:true,bookings:[]},onLoad(){this.load()},onShow(){this.load()},load(){const token=wx.getStorageSync('customerToken');if(!token){this.setData({loading:false});return}wx.request({url:API+'/customer/bookings',header:{Authorization:'Bearer '+token},success:r=>this.setData({bookings:r.data,loading:false}),fail:()=>this.setData({loading:false})})},cancel(e){const id=e.currentTarget.dataset.id;wx.showModal({title:'取消预约',content:'确定取消这笔预约吗?',success:r=>{if(!r.confirm)return;wx.request({url:API+'/customer/bookings/'+id+'/cancel',method:'POST',header:{Authorization:'Bearer '+wx.getStorageSync('customerToken')},success:()=>this.load()})}})}});
Page({data:{loading:true,bookings:[]},onLoad(){this.load()},onShow(){this.load()},load(){const token=wx.getStorageSync('customerToken');if(!token){this.setData({loading:false});return}wx.request({url:API+'/customer/bookings',header:{Authorization:'Bearer '+token},success:r=>this.setData({bookings:r.data,loading:false}),fail:()=>this.setData({loading:false})})},cancel(e){const id=e.currentTarget.dataset.id;wx.showModal({title:'取消预约',content:'确定取消这笔预约吗?',success:r=>{if(!r.confirm)return;wx.request({url:API+'/customer/bookings/'+id+'/cancel',method:'POST',header:{Authorization:'Bearer '+wx.getStorageSync('customerToken'),'content-type':'application/json'},data:{},success:res=>{if(res.statusCode<300)this.load();else wx.showToast({title:res.data?.error?.message||'取消失败',icon:'none'})},fail:err=>wx.showToast({title:err.errMsg||'网络请求失败',icon:'none'})})}})}});