Commit 22e80ef3a4981416ceff088da621d2b320b8557c

Authored by wangfan
1 parent 64a4ae05

快速预定

1 // pack-cookbook/components/cart/cart.js 1 // pack-cookbook/components/cart/cart.js
  2 +import util from '../../../utils/util';
  3 +import App from '../../../utils/api';
  4 +const {regeneratorRuntime} = global
2 Component({ 5 Component({
3 /** 6 /**
4 * 组件的属性列表 7 * 组件的属性列表
@@ -60,5 +63,14 @@ Component({ @@ -60,5 +63,14 @@ Component({
60 let opt=e.detail; 63 let opt=e.detail;
61 this.triggerEvent('foodCardCallback',opt); 64 this.triggerEvent('foodCardCallback',opt);
62 }, 65 },
  66 + RemoveCart(){
  67 + App.Advance.RemoveCart({
  68 + orderid:this.data.order.id,
  69 + identity:this.data.identity,
  70 + }).then(res=>{
  71 + this.hide();
  72 + this.triggerEvent('foodCardCallback',{type:'flushOrder',num:0});
  73 + })
  74 + },
63 }, 75 },
64 }) 76 })
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <view class="icon"> 5 <view class="icon">
6 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/empty.png"></image> 6 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/empty.png"></image>
7 </view> 7 </view>
8 - <view class="text">清空购物车</view> 8 + <view class="text" bindtap="RemoveCart">清空购物车</view>
9 </view> 9 </view>
10 <view class="cart-body"> 10 <view class="cart-body">
11 <view class="cart-item flex-lr" wx:for="{{order.cookbooklist}}" wx:key="item.key"> 11 <view class="cart-item flex-lr" wx:for="{{order.cookbooklist}}" wx:key="item.key">
@@ -223,18 +223,27 @@ Page({ @@ -223,18 +223,27 @@ Page({
223 } 223 }
224 return; 224 return;
225 } 225 }
  226 +
226 let books = this.data.cookbooklist; 227 let books = this.data.cookbooklist;
227 books.forEach(menu => { 228 books.forEach(menu => {
228 menu.cookbooklist[0].forEach(book => { 229 menu.cookbooklist[0].forEach(book => {
229 - if (book.id == opt.cookbookid) { 230 + if (book.id == opt.cookbookid || 'flushOrder'==opt.type) {
230 book.num = opt.num; 231 book.num = opt.num;
231 } 232 }
232 }) 233 })
233 }) 234 })
234 - this.setData({  
235 - countTotal: this.data.countTotal + opt.type,  
236 - cookbooklist: books  
237 - }); 235 + if('flushOrder'==opt.type){
  236 + this.setData({
  237 + countTotal: 0,
  238 + cookbooklist: books
  239 + });
  240 + }else{
  241 + this.setData({
  242 + countTotal: this.data.countTotal + opt.type,
  243 + cookbooklist: books
  244 + });
  245 + }
  246 +
238 setTimeout(()=>{ 247 setTimeout(()=>{
239 this.initOrder(); 248 this.initOrder();
240 },100) 249 },100)
@@ -132,7 +132,9 @@ export default { @@ -132,7 +132,9 @@ export default {
132 //设置人数,设置备注 132 //设置人数,设置备注
133 'App.Advance.SetOrderById':null, 133 'App.Advance.SetOrderById':null,
134 //清空购物车 134 //清空购物车
135 - 'App.Orders.ClearCookById': null, 135 + 'App.Advance.RemoveCart': {
  136 + silence: false,
  137 + },
136 //菜品备注tags 138 //菜品备注tags
137 'App.Orders.GetRemarkBySellerid':{ 139 'App.Orders.GetRemarkBySellerid':{
138 cachetime: 300, 140 cachetime: 300,