fix: 严格区分预约和我的订单页面
This commit is contained in:
1 parent
13ead2d426
commit
21b2262294
5 files changed
+5
-4
No files matched your search
@@ -1,2 +1,2 @@
|
||||
const API='http://localhost:3001';
|
||||
Page({data:{service:{},form:{},serviceId:'',submitting:false},onLoad(q){this.setData({serviceId:q.serviceId||''});wx.request({url:API+'/public/services',success:r=>this.setData({service:r.data.find(x=>x.id===q.serviceId)||{}})})},input(e){this.setData({['form.'+e.currentTarget.dataset.key]:e.detail.value})},submit(){const f=this.data.form;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:1}]},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'})}})})}});
|
||||
Page({data:{service:{},form:{},serviceId:'',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})},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:1}]},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 class="page"><view class="product"><text class="name">{{service.name || '选择预约服务'}}</text><text class="price">{{service.priceText || '人工沟通报价'}}</text></view><view class="form"><label>称呼<input name="customerName" placeholder="怎么称呼你" bindinput="input" data-key="customerName"/></label><label>联系方式<input name="wechatId" placeholder="手机号或微信号" bindinput="input" data-key="wechatId"/></label><label>预约时间<input name="requestedTime" placeholder="例如:今天 12:30" bindinput="input" data-key="requestedTime"/></label><label>备注<textarea placeholder="口味、餐具或其他说明" bindinput="input" data-key="note"></textarea></label></view><view class="notice">提交后由摊主人工确认,确认后再安排制作。</view><button class="submit" loading="{{submitting}}" disabled="{{submitting}}" bindtap="submit">{{submitting ? '提交中...' : '提交预约'}}</button></view>
|
||||
<view class="page"><view class="product"><view><text class="name">{{service.name || '选择预约服务'}}</text><text class="price">{{service.priceText || '人工沟通报价'}}</text></view><text class="available">今日可订</text></view><view class="quantity"><text>数量</text><text class="quantity-value">1 份</text><slider min="1" max="10" value="1" activeColor="#B54A2C"/></view><view class="fulfillment"><text class="field-title">取餐方式</text><view class="choices"><button class="choice active">自取</button><button class="choice">配送</button></view></view><view class="form"><label>联系人<input name="customerName" placeholder="怎么称呼你" bindinput="input" data-key="customerName"/></label><label>联系电话<input name="wechatId" placeholder="手机号或微信号" bindinput="input" data-key="wechatId"/></label><label>预约时间<input name="requestedTime" placeholder="例如:今天 12:30" bindinput="input" data-key="requestedTime"/></label><label>备注<textarea placeholder="口味、餐具或其他说明" bindinput="input" data-key="note"></textarea></label></view><view class="notice">● 提交后由摊主人工确认,确认后再安排制作。</view><button class="submit" loading="{{submitting}}" disabled="{{submitting}}" bindtap="submit">{{submitting ? '提交中...' : '提交预约'}}</button></view>
|
||||
@@ -1 +1 @@
|
||||
.page{min-height:100vh;padding:24rpx 32rpx 60rpx;background:#FBF7F1;color:#2B2B2B}.product{padding:34rpx;background:#F4EBD9;border-radius:32rpx}.name{display:block;font-size:38rpx;font-weight:700}.price{display:block;margin-top:18rpx;color:#B54A2C;font-size:38rpx}.form{margin-top:24rpx;background:#fff;border-radius:28rpx;padding:8rpx 28rpx}.form label{display:flex;justify-content:space-between;gap:20rpx;padding:28rpx 0;border-bottom:1rpx solid #eee;font-size:30rpx}.form input,.form textarea{flex:1;text-align:right}.form textarea{min-height:100rpx}.notice{margin:24rpx 0;padding:24rpx;background:#F4EBD9;border-radius:20rpx;color:#7A4A2B}.submit{background:#B54A2C;color:#fff;border-radius:48rpx;font-size:34rpx}
|
||||
.page{min-height:100vh;padding:24rpx 32rpx 60rpx;background:#FBF7F1;color:#2B2B2B}.product{display:flex;justify-content:space-between;align-items:center;padding:34rpx;background:#F4EBD9;border-radius:16rpx}.name{display:block;font-size:38rpx;font-weight:700}.price{display:block;margin-top:18rpx;color:#B54A2C;font-size:38rpx}.available{color:#7A4A2B;font-size:28rpx}.quantity,.fulfillment{margin-top:20rpx;padding:28rpx;background:#F4EBD9;border-radius:16rpx;font-size:32rpx}.quantity-value{float:right;font-size:34rpx}.quantity slider{margin:26rpx 0 0}.field-title{font-weight:700}.choices{display:flex;gap:16rpx;margin-top:18rpx}.choice{flex:1;border-radius:12rpx;background:#7A4A2B;color:#fff}.choice.active{background:#B54A2C}.form{margin-top:20rpx;background:#fff;border-radius:16rpx;padding:8rpx 28rpx}.form label{display:flex;justify-content:space-between;gap:20rpx;padding:28rpx 0;border-bottom:1rpx solid #eee;font-size:30rpx}.form input,.form textarea{flex:1;text-align:right}.form textarea{min-height:100rpx}.notice{margin:20rpx 0;padding:24rpx;background:#F4EBD9;border-radius:16rpx;color:#7A4A2B}.submit{background:#B54A2C;color:#fff;border-radius:12rpx;font-size:34rpx}
|
||||
@@ -16,6 +16,7 @@ Page({
|
||||
selectService(event) { wx.navigateTo({ url: '/pages/booking/index?serviceId=' + encodeURIComponent(event.currentTarget.dataset.id) }); },
|
||||
goServices() { wx.navigateTo({ url: '/pages/services/index' }); },
|
||||
goPrivateChef() { wx.navigateTo({ url: '/pages/booking/index?type=private_chef' }); },
|
||||
goBooking() { wx.navigateTo({ url: '/pages/booking/index' }); },
|
||||
goBookings() { wx.navigateTo({ url: '/pages/bookings/index' }); },
|
||||
goHome() { wx.reLaunch({ url: '/pages/index/index' }); },
|
||||
});
|
||||
@@ -10,5 +10,5 @@
|
||||
<view class="section-title services-title">今日服务</view>
|
||||
<view wx:for="{{services}}" wx:key="id" class="service" data-id="{{item.id}}" bindtap="selectService"><view><text class="service-name">{{item.name}}</text><text class="description">{{item.description}}</text></view><text class="price">{{item.priceText}}</text></view>
|
||||
</block>
|
||||
<view class="tabbar"><view class="tab active" bindtap="goHome">⌂<text>首页</text></view><view class="tab" bindtap="goServices">▦<text>服务</text></view><view class="tab" bindtap="goBookings">▤<text>预约</text></view><view class="tab" bindtap="goBookings">♙<text>我的</text></view></view>
|
||||
<view class="tabbar"><view class="tab active" bindtap="goHome">⌂<text>首页</text></view><view class="tab" bindtap="goServices">▦<text>服务</text></view><view class="tab" bindtap="goBooking">▤<text>预约</text></view><view class="tab" bindtap="goBookings">♙<text>我的</text></view></view>
|
||||
</view>
|
||||
Reference in new issue
Block a user