Commit 6642a3b0b22243e60710eb18e4f9838a2951e84e

Authored by wangfan
1 parent bfd95d75

快速预定

@@ -11,6 +11,10 @@ Component({ @@ -11,6 +11,10 @@ Component({
11 order:{ 11 order:{
12 type:Object, 12 type:Object,
13 value:{}, 13 value:{},
  14 + },
  15 + identity:{
  16 + type:String,
  17 + value:"",
14 } 18 }
15 }, 19 },
16 20
@@ -51,5 +55,10 @@ Component({ @@ -51,5 +55,10 @@ Component({
51 55
52 }) 56 })
53 }, 57 },
54 - } 58 + //规格 增加/减少 回调
  59 + foodSpecCallback(e){
  60 + let opt=e.detail;
  61 + this.triggerEvent('foodCardCallback',opt);
  62 + },
  63 + },
55 }) 64 })
@@ -13,13 +13,13 @@ @@ -13,13 +13,13 @@
13 <view class="price">¥{{item.price}}/份</view> 13 <view class="price">¥{{item.price}}/份</view>
14 <view class="flex-lr opt"> 14 <view class="flex-lr opt">
15 <foodSpec item="{{item}}" type="-" id="foodSpecDel" 15 <foodSpec item="{{item}}" type="-" id="foodSpecDel"
16 - sellerid="{{order.sellerid}}" orderid="{{order.id}}" 16 + sellerid="{{order.sellerid}}" orderid="{{order.id}}" identity="{{identity}}"
17 bindfoodSpecCallback="foodSpecCallback"> 17 bindfoodSpecCallback="foodSpecCallback">
18 <view class='jian'></view> 18 <view class='jian'></view>
19 </foodSpec> 19 </foodSpec>
20 - <view class="t-align-c">{{item.num||10}}</view> 20 + <view class="t-align-c">{{item.num}}</view>
21 <foodSpec item="{{item}}" type="+" 21 <foodSpec item="{{item}}" type="+"
22 - sellerid="{{order.sellerid}}" orderid="{{order.id}}" 22 + sellerid="{{order.sellerid}}" orderid="{{order.id}}" identity="{{identity}}"
23 bindfoodSpecCallback="foodSpecCallback"> 23 bindfoodSpecCallback="foodSpecCallback">
24 <view class='add'></view> 24 <view class='add'></view>
25 </foodSpec> 25 </foodSpec>
@@ -216,7 +216,7 @@ Component({ @@ -216,7 +216,7 @@ Component({
216 //加菜面板 216 //加菜面板
217 addCook:function(e){ 217 addCook:function(e){
218 console.log('addCook',this.data.item,e); 218 console.log('addCook',this.data.item,e);
219 - var cookbookid = this.data.item.id 219 + var cookbookid = this.data.item.cookbookid
220 var price=this.data.item.price; 220 var price=this.data.item.price;
221 221
222 this.initKindMenu().then(res=>{ 222 this.initKindMenu().then(res=>{
@@ -258,7 +258,7 @@ Component({ @@ -258,7 +258,7 @@ Component({
258 //减菜面板 258 //减菜面板
259 subtractCook(){ 259 subtractCook(){
260 console.log('addFunction',this.data.item); 260 console.log('addFunction',this.data.item);
261 - var cookbookid = this.data.item.id 261 + var cookbookid = this.data.item.cookbookid
262 var price=this.data.item.price; 262 var price=this.data.item.price;
263 this.initKindMenu().then(res=>{ 263 this.initKindMenu().then(res=>{
264 //打开了规格窗口 264 //打开了规格窗口
@@ -22,6 +22,7 @@ Page({ @@ -22,6 +22,7 @@ Page({
22 cookbooklist: [{}, {}, {}, {}, {}, {}, {},], 22 cookbooklist: [{}, {}, {}, {}, {}, {}, {},],
23 showSkeleton: true, 23 showSkeleton: true,
24 order: {}, 24 order: {},
  25 + orderItemCount:0,
25 }, 26 },
26 27
27 /** 28 /**
@@ -40,8 +41,13 @@ Page({ @@ -40,8 +41,13 @@ Page({
40 identity:this.data.options.identity, 41 identity:this.data.options.identity,
41 status:'0,1' 42 status:'0,1'
42 }).then(res => { 43 }).then(res => {
  44 + let orderItemCount=0;
  45 + res.data.cookbooklist.forEach(cb=>{
  46 + orderItemCount+=parseInt(cb.num)
  47 + })
43 this.setData({ 48 this.setData({
44 order: res.data, 49 order: res.data,
  50 + orderItemCount:orderItemCount,
45 }) 51 })
46 }) 52 })
47 }, 53 },
@@ -233,7 +239,7 @@ Page({ @@ -233,7 +239,7 @@ Page({
233 },100) 239 },100)
234 }, 240 },
235 gotoCart(){ 241 gotoCart(){
236 - if(this.data.order.cookbooklist.length<1){ 242 + if(this.data.orderItemCount<1){
237 return util.toast('请添加菜品','none'); 243 return util.toast('请添加菜品','none');
238 } 244 }
239 //购物车 245 //购物车
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 <view class="cart flex-ll" bindtap="dispalyCart"> 39 <view class="cart flex-ll" bindtap="dispalyCart">
40 <view class="icon"> 40 <view class="icon">
41 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/cart.png"/> 41 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/cart.png"/>
42 - <view class="dot" wx:if="{{order.cookbooklist.length>0}}">{{order.cookbooklist.length}}</view> 42 + <view class="dot" wx:if="{{orderItemCount>0}}">{{orderItemCount}}</view>
43 </view> 43 </view>
44 <view class="text Semibold">¥{{order.price}}</view> 44 <view class="text Semibold">¥{{order.price}}</view>
45 </view> 45 </view>
@@ -50,4 +50,4 @@ @@ -50,4 +50,4 @@
50 <cookClass id="menu" bind:changeList="changeList" 50 <cookClass id="menu" bind:changeList="changeList"
51 cooklist="{{cookbooklist}}" hasListModel="{{hasListModel}}"> 51 cooklist="{{cookbooklist}}" hasListModel="{{hasListModel}}">
52 </cookClass> 52 </cookClass>
53 -<cart rid="{{options.rid}}" id="cart" order="{{order}}"></cart>  
  53 +<cart rid="{{options.rid}}" id="cart" order="{{order}}" identity="{{options.identity}}" bindfoodCardCallback="foodCardCallback"></cart>