fix: 配置局域网 API 地址用于真机调试

This commit is contained in:
que01 committed 2026-09-19 11:09:25 +08:00
1 parent 60cac4155a
commit 5db15538ad
5 files changed
+5 -5

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
App({
onLaunch() {
this.globalData = { apiBaseUrl: 'http://localhost:3001' };
this.globalData = { apiBaseUrl: 'http://192.168.88.29:3001' };
},
globalData: {},
});
+1 -1
View File
@@ -1,2 +1,2 @@
const API='http://localhost:3001';
const API=getApp().globalData.apiBaseUrl;
Page({data:{service:{},form:{},serviceId:'',quantity:1,submitting:false},onLoad(q){wx.request({url:API+'/public/services',success:r=>{const service=r.data.find(x=>x.id===q.serviceId)||r.data.find(x=>x.priceAmount!==null)||{};this.setData({service,serviceId:service.id||''})}})},input(e){this.setData({['form.'+e.currentTarget.dataset.key]:e.detail.value})},increase(){if(this.data.quantity<50)this.setData({quantity:this.data.quantity+1})},decrease(){if(this.data.quantity>1)this.setData({quantity:this.data.quantity-1})},submit(){const f=this.data.form;if(!this.data.serviceId){wx.showToast({title:'请先选择服务',icon:'none'});return}if(!f.customerName||!f.wechatId){wx.showToast({title:'请填写称呼和联系方式',icon:'none'});return}this.setData({submitting:true});const send=token=>wx.request({url:API+'/customer/bookings',method:'POST',header:{Authorization:'Bearer '+token},data:{requestType:'package',customerName:f.customerName,wechatId:f.wechatId,contactPreference:'wechat',requestedTime:f.requestedTime,note:f.note,items:[{serviceId:this.data.serviceId,quantity:this.data.quantity}]},success:r=>{this.setData({submitting:false});if(r.statusCode<300){wx.showToast({title:'预约已提交'});setTimeout(()=>wx.navigateTo({url:'/pages/bookings/index'}),500)}else wx.showToast({title:'提交失败',icon:'none'})},fail:()=>this.setData({submitting:false})});const existing=wx.getStorageSync('customerToken');if(existing){send(existing);return}wx.login({success:l=>wx.request({url:API+'/customer/session/wechat',method:'POST',data:{code:l.code},success:r=>{wx.setStorageSync('customerToken',r.data.token);send(r.data.token)},fail:()=>{this.setData({submitting:false});wx.showToast({title:'登录失败',icon:'none'})}})})}});
+1 -1
View File
@@ -1,2 +1,2 @@
const API='http://localhost:3001';
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()})}})}});
+1 -1
View File
@@ -1,4 +1,4 @@
const API_BASE_URL = 'http://localhost:3001';
const API_BASE_URL = getApp().globalData.apiBaseUrl;
Page({
data: { loading: true, error: '', brand: {}, services: [] },
+1 -1
View File
@@ -1,2 +1,2 @@
const API = 'http://localhost:3001';
const API = getApp().globalData.apiBaseUrl;
Page({data:{loading:true,services:[],filtered:[],category:'package'},onLoad(){wx.request({url:API+'/public/services',success:res=>this.setData({services:res.data,filtered:res.data.filter(x=>x.priceAmount!==null),loading:false}),fail:()=>this.setData({loading:false})})},switchCategory(e){const category=e.currentTarget.dataset.category;const filtered=category==='package'?this.data.services.filter(x=>x.priceAmount!==null):this.data.services.filter(x=>x.priceAmount===null);this.setData({category,filtered})},book(e){wx.navigateTo({url:'/pages/booking/index?serviceId='+e.currentTarget.dataset.id})}});