Commit b863ec500af24f4e1d9d5b38ee1c37103b39cf3e

Authored by yiren
1 parent 8c84d21b

提前点餐

@@ -262,12 +262,19 @@ Page({ @@ -262,12 +262,19 @@ Page({
262 } 262 }
263 setTimeout(this.countdown, 1000); 263 setTimeout(this.countdown, 1000);
264 }, 264 },
  265 + // 返回
265 navEvent(){ 266 navEvent(){
  267 + // 1 邀请函 2 提前点餐
266 if(this.data.opt.types=='1'){ 268 if(this.data.opt.types=='1'){
267 - wx.reLaunch({ 269 + return wx.reLaunch({
268 url: '/pages/customer/detail_owner_invitation_new?id='+this.data.opt.detail.oid, 270 url: '/pages/customer/detail_owner_invitation_new?id='+this.data.opt.detail.oid,
269 }) 271 })
270 } 272 }
  273 + if(this.data.opt.types=='2'){
  274 + return wx.reLaunch({
  275 + url: '/pack-cookbook/pages/success_new',
  276 + })
  277 + }
271 }, 278 },
272 /** 279 /**
273 * 生命周期函数--监听页面隐藏 280 * 生命周期函数--监听页面隐藏
@@ -14,18 +14,22 @@ Page({ @@ -14,18 +14,22 @@ Page({
14 /** 14 /**
15 * 生命周期函数--监听页面加载 15 * 生命周期函数--监听页面加载
16 */ 16 */
17 - onLoad(options) {  
18 - console.log('options', options);  
19 - let obj = JSON.parse(options.obj); 17 + onLoad() {
  18 + let obj = JSON.parse(wx.getStorageSync('cookbookObj'));
20 let noData = false; 19 let noData = false;
21 - let cookbooklist = JSON.parse(options.cookbooklist); 20 + let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist'));
22 let probablyPrice = 0; 21 let probablyPrice = 0;
23 cookbooklist.forEach(items => { 22 cookbooklist.forEach(items => {
24 items.is_show = false 23 items.is_show = false
25 items.cookbooklist[0].forEach(item => { 24 items.cookbooklist[0].forEach(item => {
26 - let price = item.quantum * 1 * (item.price * 1);  
27 - probablyPrice += price;  
28 - if (item.quantum > 0) { 25 + console.log({
  26 + ...item
  27 + });
  28 + if (item.isTrue) {
  29 + item.norms.forEach(i => {
  30 + let price = i.quantum * 1 * (i.price * 1);
  31 + probablyPrice += price;
  32 + })
29 noData = true 33 noData = true
30 items.is_show = true 34 items.is_show = true
31 } 35 }
@@ -52,13 +56,19 @@ Page({ @@ -52,13 +56,19 @@ Page({
52 }) 56 })
53 } 57 }
54 }, 58 },
55 - // 加  
56 - addDdish() {  
57 -  
58 - },  
59 - // 减  
60 - reduceDdish() {  
61 - 59 + // 点加减
  60 + count(e) {
  61 + const item = e.currentTarget.dataset['item'];
  62 + const indexs = e.currentTarget.dataset['indexs'];
  63 + const index = e.currentTarget.dataset['index'];
  64 + const type = e.currentTarget.dataset['type'];
  65 + let quantum;
  66 + if (type == '1') quantum = item.quantum * 1 + 1;
  67 + if (type == '0') quantum = item.quantum * 1 - 1;
  68 + let checkObj = `cookbooklist[${indexs}].cookbooklist[0][${index}].quantum`;
  69 + this.setData({
  70 + [checkObj]: quantum,
  71 + })
62 }, 72 },
63 /** 73 /**
64 * 生命周期函数--监听页面初次渲染完成 74 * 生命周期函数--监听页面初次渲染完成
@@ -29,9 +29,9 @@ @@ -29,9 +29,9 @@
29 <view class="single">{{item.name}}<text>({{item.practice}})</text></view> 29 <view class="single">{{item.name}}<text>({{item.practice}})</text></view>
30 <view class="price">{{item.price}}元/{{item.unit}}</view> 30 <view class="price">{{item.price}}元/{{item.unit}}</view>
31 <view class="count flex-cc"> 31 <view class="count flex-cc">
32 - <image bindtap="reduceDdish" src="https://qn.colorcun.com/WechatIMG809.png" class="img1" mode="" /> 32 + <image bindtap="count" data-item="{{item}}" data-type="0" data-indexs="{{indexs}}" data-index="{{index}}" src="https://qn.colorcun.com/WechatIMG809.png" class="img1" mode="" />
33 {{item.quantum}} 33 {{item.quantum}}
34 - <image bindtap="addDdish" src="https://qn.colorcun.com/WechatIMG810.png" class="img2" mode="" /> 34 + <image bindtap="count" data-item="{{item}}" data-type="1" data-indexs="{{indexs}}" data-index="{{index}}" src="https://qn.colorcun.com/WechatIMG810.png" class="img2" mode="" />
35 </view> 35 </view>
36 </view> 36 </view>
37 </block> 37 </block>
@@ -30,7 +30,7 @@ Page({ @@ -30,7 +30,7 @@ Page({
30 order: {}, 30 order: {},
31 orderItemCount: 0, 31 orderItemCount: 0,
32 checkObj: '', 32 checkObj: '',
33 - quantum: '', 33 + normsIndex: '',
34 normsList: [{ 34 normsList: [{
35 text: '做饭', 35 text: '做饭',
36 }, 36 },
@@ -79,30 +79,15 @@ Page({ @@ -79,30 +79,15 @@ Page({
79 }, 79 },
80 // 已选菜单页面跳转 80 // 已选菜单页面跳转
81 gotoShoppingCart() { 81 gotoShoppingCart() {
82 - // let arr = [];  
83 - // this.data.cookbooklist.forEach(item => {  
84 - // let obj = {  
85 - // class_name: item.class_name,  
86 - // id: item.id,  
87 - // status: item.status,  
88 - // class_type: item.class_type,  
89 - // arr: [],  
90 - // }  
91 - // item.cookbooklist[0].forEach(i => {  
92 - // if (i.quantum != '0') {  
93 - // obj.arr.push(i)  
94 - // }  
95 - // })  
96 - // arr.push(obj)  
97 - // })  
98 - // console.log(arr);  
99 let cookbooklist = this.data.cookbooklist; 82 let cookbooklist = this.data.cookbooklist;
100 let obj = { 83 let obj = {
101 sellerName: this.data.options.sellerName, 84 sellerName: this.data.options.sellerName,
102 sellerid: this.data.options.sid, 85 sellerid: this.data.options.sid,
103 } 86 }
  87 + wx.setStorageSync('cookbooklist', JSON.stringify(cookbooklist))
  88 + wx.setStorageSync('cookbookObj', JSON.stringify(obj))
104 wx.navigateTo({ 89 wx.navigateTo({
105 - url: `/pack-cookbook/pages/cart_new?cookbooklist=${JSON.stringify(cookbooklist)}&obj=${JSON.stringify(obj)}`, 90 + url: '/pack-cookbook/pages/cart_new',
106 }) 91 })
107 }, 92 },
108 // 选择规格 93 // 选择规格
@@ -114,7 +99,6 @@ Page({ @@ -114,7 +99,6 @@ Page({
114 }, 99 },
115 // 展示做法规格弹窗 100 // 展示做法规格弹窗
116 showModal() { 101 showModal() {
117 - console.log(this.data.checkItem);  
118 this.checkModal.showModal() 102 this.checkModal.showModal()
119 }, 103 },
120 // 关闭做法规格弹窗 104 // 关闭做法规格弹窗
@@ -137,66 +121,110 @@ Page({ @@ -137,66 +121,110 @@ Page({
137 this.setData({ 121 this.setData({
138 toView: 'inToView' + _id 122 toView: 'inToView' + _id
139 }) 123 })
140 - console.log(_id);  
141 }, 124 },
142 // 选择做法和规格后点击确定 125 // 选择做法和规格后点击确定
143 determineFun() { 126 determineFun() {
144 let index = this.data.checkObj.index; 127 let index = this.data.checkObj.index;
145 let indexs = this.data.checkObj.indexs; 128 let indexs = this.data.checkObj.indexs;
146 - let quantum = this.data.quantum;  
147 - let check1 = this.data.check1;  
148 - let check2 = this.data.check2;  
149 - let checkObj = `cookbooklist[${indexs}].cookbooklist[0][${index}].quantum`;  
150 - let practice = `cookbooklist[${indexs}].cookbooklist[0][${index}].practice`;  
151 - let unit = `cookbooklist[${indexs}].cookbooklist[0][${index}].unit`;  
152 - this.setData({  
153 - [checkObj]: quantum,  
154 - [practice]: check1,  
155 - [unit]: check2, 129 + let price = this.data.checkObj.price;
  130 + let data = this.data.cookbooklist[indexs].cookbooklist[0][index]
  131 + let isAlike = false;
  132 + data.norms.forEach(item => {
  133 + if (this.data.check1 == item.practice && this.data.check2 == item.unit) {
  134 + isAlike = true
  135 + item.quantum = item.quantum * 1 + 1
  136 + }
156 }) 137 })
157 - console.log('cookbooklist', this.data.cookbooklist); 138 + if (isAlike) {
  139 + this.setData({
  140 + cookbooklist: this.data.cookbooklist,
  141 + })
  142 + } else {
  143 + let obj = {
  144 + practice: this.data.check1,
  145 + unit: this.data.check2,
  146 + quantum: 1,
  147 + price
  148 + }
  149 + this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
  150 + this.setData({
  151 + cookbooklist: this.data.cookbooklist,
  152 + })
  153 + }
158 this.closeModal() 154 this.closeModal()
  155 +
159 }, 156 },
160 // 点击加号 157 // 点击加号
161 addition(e) { 158 addition(e) {
162 const item = e.currentTarget.dataset['item']; 159 const item = e.currentTarget.dataset['item'];
163 const index = e.currentTarget.dataset['key']; //菜下标 160 const index = e.currentTarget.dataset['key']; //菜下标
164 const indexs = e.currentTarget.dataset['indexs']; //分类下标 161 const indexs = e.currentTarget.dataset['indexs']; //分类下标
165 - let quantum = item.quantum * 1 + 1; 162 + const type = e.currentTarget.dataset['type']; //1 弹框 0不选规格型号
  163 + const normsIndex = e.currentTarget.dataset['norms']; //菜品点菜的数组下标
166 this.setData({ 164 this.setData({
167 checkObj: { 165 checkObj: {
168 indexs, 166 indexs,
169 index, 167 index,
  168 + price:item.price
170 }, 169 },
171 - quantum, 170 + normsIndex,
172 checkItem: item 171 checkItem: item
173 }) 172 })
174 - console.log('index', index);  
175 - console.log('indexs', indexs);  
176 - console.log('checkItem', this.data.checkItem);  
177 - this.showModal() 173 + let norms = this.data.cookbooklist[indexs].cookbooklist[0][index].norms
  174 + let normsNum;
  175 + if (norms.length != '0' && type == '0') {
  176 + normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 + 1;
  177 + } else {
  178 + normsNum = 1
  179 + }
  180 + if (type == '1') {
  181 + return this.showModal()
  182 + }
  183 + if (type == '0') {
  184 + this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum;
  185 + this.setData({
  186 + cookbooklist: this.data.cookbooklist,
  187 + })
  188 + }
  189 + if(this.data.cookbooklist[indexs].cookbooklist[0][index].norms.length>0){
  190 + this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=true
  191 + }else{
  192 + this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=false
  193 + }
178 }, 194 },
179 // 点击减号 195 // 点击减号
180 subtraction(e) { 196 subtraction(e) {
181 - const item = e.currentTarget.dataset['item'];  
182 const index = e.currentTarget.dataset['key']; //菜下标 197 const index = e.currentTarget.dataset['key']; //菜下标
183 const indexs = e.currentTarget.dataset['indexs']; //分类下标 198 const indexs = e.currentTarget.dataset['indexs']; //分类下标
184 - let quantum = item.quantum * 1 - 1;  
185 - console.log('index', index);  
186 - console.log('indexs', indexs);  
187 - let quantumObj = `cookbooklist[${indexs}].cookbooklist[0][${index}].quantum`;  
188 - let practice = `cookbooklist[${indexs}].cookbooklist[0][${index}].practice`;  
189 - let unit = `cookbooklist[${indexs}].cookbooklist[0][${index}].unit`; 199 + const normsIndex = e.currentTarget.dataset['norms']; //菜品点菜的数组下标
  200 + let normsNum;
  201 + normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 - 1;
  202 + if (normsNum == 0) {
  203 + this.data.cookbooklist[indexs].cookbooklist[0][index].norms.splice(normsIndex, 1)
  204 + } else {
  205 + this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum;
  206 + }
190 this.setData({ 207 this.setData({
191 - checkObj: {  
192 - indexs,  
193 - index  
194 - },  
195 - quantum,  
196 - [quantumObj]: quantum,  
197 - [practice]: this.data.check1,  
198 - [unit]: this.data.check2, 208 + cookbooklist: this.data.cookbooklist,
199 }) 209 })
  210 +
  211 + if(this.data.cookbooklist[indexs].cookbooklist[0][index].norms.length>0){
  212 + this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=true
  213 + }else{
  214 + this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=false
  215 + }
  216 +
  217 +
  218 + // let practice = `cookbooklist[${indexs}].cookbooklist[0][${index}].practice`;
  219 + // let unit = `cookbooklist[${indexs}].cookbooklist[0][${index}].unit`;
  220 + // this.setData({
  221 + // checkObj: {
  222 + // indexs,
  223 + // index
  224 + // },
  225 + // [practice]: this.data.check1,
  226 + // [unit]: this.data.check2,
  227 + // })
200 }, 228 },
201 // 扫桌码点餐 229 // 扫桌码点餐
202 initOrder() { 230 initOrder() {
@@ -284,10 +312,8 @@ Page({ @@ -284,10 +312,8 @@ Page({
284 } 312 }
285 } 313 }
286 cook.item_clear_num = item_clear_num; 314 cook.item_clear_num = item_clear_num;
287 - cook.quantum = 0; //选择的数量  
288 cook.index = n; //分类下菜品的下标 315 cook.index = n; //分类下菜品的下标
289 - cook.practice = ''; //做法  
290 - cook.unit = ''; //规格 316 + cook.norms = []; //做法规格
291 // let type;//模拟种类 1为一行显示1个 2为一行显示2个 317 // let type;//模拟种类 1为一行显示1个 2为一行显示2个
292 // if(n=='0' || n=='3'){ 318 // if(n=='0' || n=='3'){
293 // type='1' 319 // type='1'
@@ -299,6 +325,7 @@ Page({ @@ -299,6 +325,7 @@ Page({
299 cook.arr2 = ['小份', '中份', '份', '例', '两只']; 325 cook.arr2 = ['小份', '中份', '份', '例', '两只'];
300 check1 = cook.arr1[0]; 326 check1 = cook.arr1[0];
301 check2 = cook.arr2[0]; 327 check2 = cook.arr2[0];
  328 + cook.isTrue=false;//是否选了菜
302 if (item_clear_num == 0) { 329 if (item_clear_num == 0) {
303 flag = false; 330 flag = false;
304 } 331 }
@@ -43,18 +43,18 @@ @@ -43,18 +43,18 @@
43 <view class="greens"> 43 <view class="greens">
44 <view class="news">{{item.first_name}}</view> 44 <view class="news">{{item.first_name}}</view>
45 </view> 45 </view>
46 - <view wx:if="{{item.quantum!=0}}" class="algorithmImg flex-lr calculate">  
47 - <image src="https://qn.colorcun.com/WechatIMG697.png" mode="aspectFill" class="reduceImg" bindtap="subtraction" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 46 + <view wx:for="{{item.norms}}" wx:for-index="normsIndex" class="algorithmImg flex-lr calculate">
  47 + <image src="https://qn.colorcun.com/WechatIMG697.png" mode="aspectFill" class="reduceImg" bindtap="subtraction" data-item="{{item}}" data-norms="{{normsIndex}}" data-key="{{index}}" data-indexs="{{indexs}}" />
48 <view class="box flex-cc"> 48 <view class="box flex-cc">
49 <view class="num flex-cc"> 49 <view class="num flex-cc">
50 {{item.quantum}}<view>{{item.unit}}</view> 50 {{item.quantum}}<view>{{item.unit}}</view>
51 </view> 51 </view>
52 <view class="practice">{{item.practice}}</view> 52 <view class="practice">{{item.practice}}</view>
53 </view> 53 </view>
54 - <image src="https://qn.colorcun.com/WechatIMG696.png" mode="aspectFill" class="imgs" bindtap="addition" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 54 + <image id="add" src="https://qn.colorcun.com/WechatIMG696.png" mode="aspectFill" class="imgs" data-type="0" bindtap="addition" data-norms="{{normsIndex}}" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" />
55 </view> 55 </view>
56 <view class="algorithmImg flex-rr"> 56 <view class="algorithmImg flex-rr">
57 - <image src="https://qn.colorcun.com/WechatIMG696.png" class="imgs" mode="aspectFill" bindtap="addition" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 57 + <image src="https://qn.colorcun.com/WechatIMG696.png" class="imgs" mode="aspectFill" bindtap="addition" data-norms="{{normsIndex}}" data-type="1" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" />
58 </view> 58 </view>
59 <view class="wrapIine"></view> 59 <view class="wrapIine"></view>
60 </view> 60 </view>
@@ -91,11 +91,14 @@ page { @@ -91,11 +91,14 @@ page {
91 .algorithmImg .imgs { 91 .algorithmImg .imgs {
92 width: 60rpx; 92 width: 60rpx;
93 height: 100%; 93 height: 100%;
94 - margin-right: 80rpx; 94 + margin-right: 60rpx;
95 } 95 }
96 96
  97 +.algorithmImg .imgs {
  98 + padding: 20rpx;
  99 +}
97 .calculate { 100 .calculate {
98 - padding: 0 80rpx 58rpx 80rpx; 101 + padding: 0 60rpx 58rpx 80rpx;
99 } 102 }
100 103
101 .calculate .imgs { 104 .calculate .imgs {
@@ -168,6 +171,7 @@ page { @@ -168,6 +171,7 @@ page {
168 .reduceImg { 171 .reduceImg {
169 width: 90rpx; 172 width: 90rpx;
170 height: 8rpx !important; 173 height: 8rpx !important;
  174 + padding: 20rpx;
171 } 175 }
172 176
173 .fixedBox { 177 .fixedBox {
@@ -23,9 +23,8 @@ Page({ @@ -23,9 +23,8 @@ Page({
23 * 生命周期函数--监听页面加载 23 * 生命周期函数--监听页面加载
24 */ 24 */
25 onLoad(options) { 25 onLoad(options) {
26 - console.log('options', options);  
27 - let obj = JSON.parse(options.obj);  
28 - let cookbooklist = JSON.parse(options.cookbooklist); 26 + let obj = JSON.parse(wx.getStorageSync('cookbookObj'));
  27 + let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist'));
29 let probablyPrice = 0; 28 let probablyPrice = 0;
30 cookbooklist.forEach(items => { 29 cookbooklist.forEach(items => {
31 items.is_show = false 30 items.is_show = false
@@ -88,9 +87,6 @@ Page({ @@ -88,9 +87,6 @@ Page({
88 let cash = coupon_data.use.cash; 87 let cash = coupon_data.use.cash;
89 let price = coupon_data.price * 1; 88 let price = coupon_data.price * 1;
90 let discount = ((price / cash) * 10).toFixed(2); 89 let discount = ((price / cash) * 10).toFixed(2);
91 - console.log('cash', cash);  
92 - console.log('price', price);  
93 - console.log('discount', discount);  
94 this.setData({ 90 this.setData({
95 discount 91 discount
96 }) 92 })
@@ -62,7 +62,7 @@ @@ -62,7 +62,7 @@
62 会员生日当天可用{{coupon_data.desc?','+coupon_data.desc+'。':'。'}} 62 会员生日当天可用{{coupon_data.desc?','+coupon_data.desc+'。':'。'}}
63 </view> 63 </view>
64 </view> 64 </view>
65 - <navigator url="/pack-activity/pack/buyCoupon?id={{coupon_data.id}}&name={{seller.name}}&use={{stringifyUse}}&sid={{seller.sid}}&oid={{detail.id}}" hover-class="navigator-hover"> 65 + <navigator url="/pack-activity/pack/buyCoupon?id={{coupon_data.id}}&name={{seller.name}}&use={{stringifyUse}}&sid={{seller.sid}}&oid={{detail.id}}&types=2" hover-class="navigator-hover">
66 <view class="font24r orderingFood"> 66 <view class="font24r orderingFood">
67 去抢购 67 去抢购
68 </view> 68 </view>
@@ -84,7 +84,7 @@ @@ -84,7 +84,7 @@
84 {{recharge_data.recharge_list.is_coupons=='1'?'会员充值满'+marketing.recharge_data.recharge_money+'元赠送优惠券':''}}。 84 {{recharge_data.recharge_list.is_coupons=='1'?'会员充值满'+marketing.recharge_data.recharge_money+'元赠送优惠券':''}}。
85 </view> 85 </view>
86 </view> 86 </view>
87 - <navigator url="/pack-activity/pack/vipRecharge?id={{recharge_data.id}}&name={{seller.name}}&sid={{seller.sid}}&oid={{detail.id}}" hover-class="navigator-hover"> 87 + <navigator url="/pack-activity/pack/vipRecharge?id={{recharge_data.id}}&name={{seller.name}}&sid={{seller.sid}}&oid={{detail.id}}&types=2" hover-class="navigator-hover">
88 <view class="font24r orderingFood"> 88 <view class="font24r orderingFood">
89 去充值 89 去充值
90 </view> 90 </view>