Showing
6 changed files
with
188 additions
and
129 deletions
| @@ -10,46 +10,70 @@ Page({ | @@ -10,46 +10,70 @@ Page({ | ||
| 10 | sellerid: '', | 10 | sellerid: '', |
| 11 | notes: '', | 11 | notes: '', |
| 12 | noData: false, | 12 | noData: false, |
| 13 | + rid: '', | ||
| 14 | + oid: '', | ||
| 13 | }, | 15 | }, |
| 14 | /** | 16 | /** |
| 15 | * 生命周期函数--监听页面加载 | 17 | * 生命周期函数--监听页面加载 |
| 16 | */ | 18 | */ |
| 17 | onLoad() { | 19 | onLoad() { |
| 18 | let obj = JSON.parse(wx.getStorageSync('cookbookObj')); | 20 | let obj = JSON.parse(wx.getStorageSync('cookbookObj')); |
| 19 | - let noData = false; | ||
| 20 | let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist')); | 21 | let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist')); |
| 22 | + this.formatCookList(cookbooklist); | ||
| 23 | + this.setData({ | ||
| 24 | + sellerName: obj.sellerName, | ||
| 25 | + sellerid: obj.sellerid, | ||
| 26 | + rid: obj.rid, | ||
| 27 | + oid: obj.oid, | ||
| 28 | + }) | ||
| 29 | + }, | ||
| 30 | + formatCookList(cookbooklist) { | ||
| 21 | let probablyPrice = 0; | 31 | let probablyPrice = 0; |
| 32 | + let noData = false; | ||
| 22 | cookbooklist.forEach(items => { | 33 | cookbooklist.forEach(items => { |
| 23 | items.is_show = false | 34 | items.is_show = false |
| 35 | + items.normsLen = 0 | ||
| 24 | items.cookbooklist[0].forEach(item => { | 36 | items.cookbooklist[0].forEach(item => { |
| 25 | - console.log({ | ||
| 26 | - ...item | ||
| 27 | - }); | ||
| 28 | - if (item.isTrue) { | 37 | + item.arr = []; //arr 点菜的菜品列表 |
| 38 | + if (item.norms.length > 0) { | ||
| 29 | item.norms.forEach(i => { | 39 | item.norms.forEach(i => { |
| 40 | + let obj = { | ||
| 41 | + name: item.name, | ||
| 42 | + practice: i.practice, | ||
| 43 | + unit: i.unit, | ||
| 44 | + price: i.price, | ||
| 45 | + quantum: i.quantum, | ||
| 46 | + } | ||
| 47 | + item.arr.push(obj) | ||
| 30 | let price = i.quantum * 1 * (i.price * 1); | 48 | let price = i.quantum * 1 * (i.price * 1); |
| 31 | probablyPrice += price; | 49 | probablyPrice += price; |
| 32 | }) | 50 | }) |
| 33 | noData = true | 51 | noData = true |
| 34 | - items.is_show = true | 52 | + items.is_show = true; //展示不展示 |
| 53 | + items.normsLen += item.arr.length; //菜品数量 | ||
| 35 | } | 54 | } |
| 36 | }) | 55 | }) |
| 37 | }) | 56 | }) |
| 38 | this.setData({ | 57 | this.setData({ |
| 39 | cookbooklist, | 58 | cookbooklist, |
| 40 | - sellerName: obj.sellerName, | ||
| 41 | - sellerid: obj.sellerid, | ||
| 42 | probablyPrice, | 59 | probablyPrice, |
| 43 | noData | 60 | noData |
| 44 | }) | 61 | }) |
| 45 | }, | 62 | }, |
| 63 | + // 继续点菜 | ||
| 64 | + continueOrdering() { | ||
| 65 | + wx.navigateBack(1) | ||
| 66 | + }, | ||
| 46 | // 确认下单 | 67 | // 确认下单 |
| 47 | determineFun() { | 68 | determineFun() { |
| 69 | + // wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist)) | ||
| 48 | if (this.data.noData) { | 70 | if (this.data.noData) { |
| 49 | let obj = { | 71 | let obj = { |
| 50 | sellerName: this.data.sellerName, | 72 | sellerName: this.data.sellerName, |
| 51 | sellerid: this.data.sellerid, | 73 | sellerid: this.data.sellerid, |
| 52 | - notes: this.data.notes | 74 | + notes: this.data.notes, |
| 75 | + rid: this.data.rid, | ||
| 76 | + oid: this.data.oid, | ||
| 53 | } | 77 | } |
| 54 | wx.navigateTo({ | 78 | wx.navigateTo({ |
| 55 | url: `/pack-cookbook/pages/success_new?cookbooklist=${JSON.stringify(this.data.cookbooklist)}&obj=${JSON.stringify(obj)}`, | 79 | url: `/pack-cookbook/pages/success_new?cookbooklist=${JSON.stringify(this.data.cookbooklist)}&obj=${JSON.stringify(obj)}`, |
| @@ -57,18 +81,21 @@ Page({ | @@ -57,18 +81,21 @@ Page({ | ||
| 57 | } | 81 | } |
| 58 | }, | 82 | }, |
| 59 | // 点加减 | 83 | // 点加减 |
| 60 | - count(e) { | ||
| 61 | - const item = e.currentTarget.dataset['item']; | ||
| 62 | - const indexs = e.currentTarget.dataset['indexs']; | ||
| 63 | - const index = e.currentTarget.dataset['index']; | 84 | + countFun(e) { |
| 85 | + const index = e.currentTarget.dataset['index']; //菜下标 | ||
| 86 | + const indexs = e.currentTarget.dataset['indexs']; //分类下标 | ||
| 87 | + const idx = e.currentTarget.dataset['idx']; //菜品点菜的数组下标 | ||
| 64 | const type = e.currentTarget.dataset['type']; | 88 | 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 | - }) | 89 | + let normsNum; |
| 90 | + if (type == '1') normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[idx].quantum * 1 + 1; | ||
| 91 | + if (type == '0') normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[idx].quantum * 1 - 1; | ||
| 92 | + if (normsNum == 0) { | ||
| 93 | + this.data.cookbooklist[indexs].cookbooklist[0][index].norms.splice(idx, 1) | ||
| 94 | + } else { | ||
| 95 | + this.data.cookbooklist[indexs].cookbooklist[0][index].norms[idx].quantum = normsNum; | ||
| 96 | + } | ||
| 97 | + wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist)) | ||
| 98 | + this.formatCookList(this.data.cookbooklist) | ||
| 72 | }, | 99 | }, |
| 73 | /** | 100 | /** |
| 74 | * 生命周期函数--监听页面初次渲染完成 | 101 | * 生命周期函数--监听页面初次渲染完成 |
| @@ -18,22 +18,24 @@ | @@ -18,22 +18,24 @@ | ||
| 18 | <input type="text" model:value="{{notes}}" placeholder="点击录入口味,偏好等要求" placeholder-style="color:#fff" /> | 18 | <input type="text" model:value="{{notes}}" placeholder="点击录入口味,偏好等要求" placeholder-style="color:#fff" /> |
| 19 | </view> | 19 | </view> |
| 20 | <view class="line"></view> | 20 | <view class="line"></view> |
| 21 | - <view class="checkMenu"> | 21 | + <view class="checkMenu" wx:if="{{cookbooklist.length>0}}"> |
| 22 | <block wx:for="{{cookbooklist}}" wx:key="{{item.id}}" wx:for-index="indexs"> | 22 | <block wx:for="{{cookbooklist}}" wx:key="{{item.id}}" wx:for-index="indexs"> |
| 23 | <view wx:if="{{item.is_show}}" class="title flex-lr"> | 23 | <view wx:if="{{item.is_show}}" class="title flex-lr"> |
| 24 | <view class="leftTitle">{{item.class_name}}</view> | 24 | <view class="leftTitle">{{item.class_name}}</view> |
| 25 | - <view class="rightTitle">{{item.arr.length}}道</view> | 25 | + <view class="rightTitle">{{item.normsLen}}道</view> |
| 26 | </view> | 26 | </view> |
| 27 | <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index"> | 27 | <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index"> |
| 28 | - <view wx:if="{{item.quantum>0}}" class="content flex-lr"> | ||
| 29 | - <view class="single">{{item.name}}<text>({{item.practice}})</text></view> | ||
| 30 | - <view class="price">{{item.price}}元/{{item.unit}}</view> | ||
| 31 | - <view class="count flex-cc"> | ||
| 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}} | ||
| 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="" /> | 28 | + <block wx:if="{{item.arr.length>0}}"> |
| 29 | + <view wx:for="{{item.arr}}" wx:for-index="idx" class="content flex-lr"> | ||
| 30 | + <view class="single">{{item.name}}<text>({{item.practice}})</text></view> | ||
| 31 | + <view class="price">{{item.price}}元/{{item.unit}}</view> | ||
| 32 | + <view class="count flex-cc"> | ||
| 33 | + <image bindtap="countFun" data-type="0" data-indexs="{{indexs}}" data-index="{{index}}" data-idx="{{idx}}" src="https://qn.colorcun.com/WechatIMG809.png" class="img1" mode="" /> | ||
| 34 | + {{item.quantum}} | ||
| 35 | + <image bindtap="countFun" data-type="1" data-indexs="{{indexs}}" data-index="{{index}}" data-idx="{{idx}}" src="https://qn.colorcun.com/WechatIMG810.png" class="img2" mode="" /> | ||
| 36 | + </view> | ||
| 35 | </view> | 37 | </view> |
| 36 | - </view> | 38 | + </block> |
| 37 | </block> | 39 | </block> |
| 38 | </block> | 40 | </block> |
| 39 | </view> | 41 | </view> |
| @@ -38,17 +38,27 @@ page { | @@ -38,17 +38,27 @@ page { | ||
| 38 | background: #999999; | 38 | background: #999999; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | -.checkMenu { | ||
| 42 | - border-radius: 10rpx; | ||
| 43 | - background: #ffffff; | ||
| 44 | - padding: 0 40rpx; | 41 | +.content { |
| 42 | + background-color: #fff; | ||
| 43 | + padding: 10rpx 40rpx 20rpx 40rpx; | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +.content:last-of-type { | ||
| 47 | + border-bottom-left-radius: 10rpx; | ||
| 48 | + border-bottom-right-radius: 10rpx; | ||
| 45 | } | 49 | } |
| 46 | 50 | ||
| 47 | .title { | 51 | .title { |
| 48 | - padding: 36rpx 0 4rpx 0; | 52 | + padding: 36rpx 40rpx 4rpx 40rpx; |
| 53 | + background-color: #fff; | ||
| 49 | border-bottom: 2rpx solid #DBDBDB; | 54 | border-bottom: 2rpx solid #DBDBDB; |
| 50 | } | 55 | } |
| 51 | 56 | ||
| 57 | +.title:nth-of-type(1) { | ||
| 58 | + border-top-left-radius: 10rpx; | ||
| 59 | + border-top-right-radius: 10rpx; | ||
| 60 | +} | ||
| 61 | + | ||
| 52 | .leftTitle { | 62 | .leftTitle { |
| 53 | color: #515151; | 63 | color: #515151; |
| 54 | font-family: PingFang SC; | 64 | font-family: PingFang SC; |
| @@ -62,10 +72,6 @@ page { | @@ -62,10 +72,6 @@ page { | ||
| 62 | font-size: 28rpx; | 72 | font-size: 28rpx; |
| 63 | } | 73 | } |
| 64 | 74 | ||
| 65 | -.content { | ||
| 66 | - padding: 20rpx 0; | ||
| 67 | -} | ||
| 68 | - | ||
| 69 | .count text { | 75 | .count text { |
| 70 | font-weight: bold; | 76 | font-weight: bold; |
| 71 | color: #515151; | 77 | color: #515151; |
| @@ -115,5 +121,5 @@ page { | @@ -115,5 +121,5 @@ page { | ||
| 115 | 121 | ||
| 116 | .determine1 { | 122 | .determine1 { |
| 117 | background: #DBDBDB; | 123 | background: #DBDBDB; |
| 118 | - color:#BFC4D4; | 124 | + color: #BFC4D4; |
| 119 | } | 125 | } |
| @@ -16,8 +16,6 @@ Page({ | @@ -16,8 +16,6 @@ Page({ | ||
| 16 | check2: '', //规格 | 16 | check2: '', //规格 |
| 17 | isloading: true, | 17 | isloading: true, |
| 18 | toView: "inToView27", | 18 | toView: "inToView27", |
| 19 | - countPirce: '', | ||
| 20 | - countTotal: '', | ||
| 21 | hasEnter: false, | 19 | hasEnter: false, |
| 22 | totalWidth: getApp().system.windowWidth, | 20 | totalWidth: getApp().system.windowWidth, |
| 23 | singleWidth: parseInt((getApp().system.windowWidth * 0.92 - 16) / 2), | 21 | singleWidth: parseInt((getApp().system.windowWidth * 0.92 - 16) / 2), |
| @@ -31,13 +29,6 @@ Page({ | @@ -31,13 +29,6 @@ Page({ | ||
| 31 | orderItemCount: 0, | 29 | orderItemCount: 0, |
| 32 | checkObj: '', | 30 | checkObj: '', |
| 33 | normsIndex: '', | 31 | normsIndex: '', |
| 34 | - normsList: [{ | ||
| 35 | - text: '做饭', | ||
| 36 | - }, | ||
| 37 | - { | ||
| 38 | - text: '规格', | ||
| 39 | - } | ||
| 40 | - ], | ||
| 41 | assortArr: [], | 32 | assortArr: [], |
| 42 | }, | 33 | }, |
| 43 | checkModal: '', | 34 | checkModal: '', |
| @@ -83,7 +74,10 @@ Page({ | @@ -83,7 +74,10 @@ Page({ | ||
| 83 | let obj = { | 74 | let obj = { |
| 84 | sellerName: this.data.options.sellerName, | 75 | sellerName: this.data.options.sellerName, |
| 85 | sellerid: this.data.options.sid, | 76 | sellerid: this.data.options.sid, |
| 77 | + rid:this.data.options.rid, | ||
| 78 | + oid: this.data.options.oid, | ||
| 86 | } | 79 | } |
| 80 | + console.log('objobjobjobjobj',obj); | ||
| 87 | wx.setStorageSync('cookbooklist', JSON.stringify(cookbooklist)) | 81 | wx.setStorageSync('cookbooklist', JSON.stringify(cookbooklist)) |
| 88 | wx.setStorageSync('cookbookObj', JSON.stringify(obj)) | 82 | wx.setStorageSync('cookbookObj', JSON.stringify(obj)) |
| 89 | wx.navigateTo({ | 83 | wx.navigateTo({ |
| @@ -129,6 +123,7 @@ Page({ | @@ -129,6 +123,7 @@ Page({ | ||
| 129 | let price = this.data.checkObj.price; | 123 | let price = this.data.checkObj.price; |
| 130 | let data = this.data.cookbooklist[indexs].cookbooklist[0][index] | 124 | let data = this.data.cookbooklist[indexs].cookbooklist[0][index] |
| 131 | let isAlike = false; | 125 | let isAlike = false; |
| 126 | + | ||
| 132 | data.norms.forEach(item => { | 127 | data.norms.forEach(item => { |
| 133 | if (this.data.check1 == item.practice && this.data.check2 == item.unit) { | 128 | if (this.data.check1 == item.practice && this.data.check2 == item.unit) { |
| 134 | isAlike = true | 129 | isAlike = true |
| @@ -186,11 +181,6 @@ Page({ | @@ -186,11 +181,6 @@ Page({ | ||
| 186 | cookbooklist: this.data.cookbooklist, | 181 | cookbooklist: this.data.cookbooklist, |
| 187 | }) | 182 | }) |
| 188 | } | 183 | } |
| 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 | - } | ||
| 194 | }, | 184 | }, |
| 195 | // 点击减号 | 185 | // 点击减号 |
| 196 | subtraction(e) { | 186 | subtraction(e) { |
| @@ -207,24 +197,6 @@ Page({ | @@ -207,24 +197,6 @@ Page({ | ||
| 207 | this.setData({ | 197 | this.setData({ |
| 208 | cookbooklist: this.data.cookbooklist, | 198 | cookbooklist: this.data.cookbooklist, |
| 209 | }) | 199 | }) |
| 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 | - // }) | ||
| 228 | }, | 200 | }, |
| 229 | // 扫桌码点餐 | 201 | // 扫桌码点餐 |
| 230 | initOrder() { | 202 | initOrder() { |
| @@ -325,7 +297,6 @@ Page({ | @@ -325,7 +297,6 @@ Page({ | ||
| 325 | cook.arr2 = ['小份', '中份', '份', '例', '两只']; | 297 | cook.arr2 = ['小份', '中份', '份', '例', '两只']; |
| 326 | check1 = cook.arr1[0]; | 298 | check1 = cook.arr1[0]; |
| 327 | check2 = cook.arr2[0]; | 299 | check2 = cook.arr2[0]; |
| 328 | - cook.isTrue=false;//是否选了菜 | ||
| 329 | if (item_clear_num == 0) { | 300 | if (item_clear_num == 0) { |
| 330 | flag = false; | 301 | flag = false; |
| 331 | } | 302 | } |
| @@ -359,39 +330,53 @@ Page({ | @@ -359,39 +330,53 @@ Page({ | ||
| 359 | }, | 330 | }, |
| 360 | // 获取所有分类下所有菜品列表 | 331 | // 获取所有分类下所有菜品列表 |
| 361 | getCookList(orderid) { | 332 | getCookList(orderid) { |
| 362 | - let param = { | ||
| 363 | - sellerid: this.data.options.sid, | ||
| 364 | - identity: this.data.options.identity, | ||
| 365 | - orderid: this.data.options.oid, | ||
| 366 | - status: '0,1', | ||
| 367 | - }; | ||
| 368 | - App.Advance.GetCookbookByClass(param).then(json => { | ||
| 369 | - //菜单分类添加修饰 | ||
| 370 | - let cookbooklist = this.formatCookList(json.data[0].list); | ||
| 371 | - setTimeout(() => { | ||
| 372 | - this.setData({ | ||
| 373 | - cookbooklist: cookbooklist, | ||
| 374 | - countPirce: json.data[0].countPirce ? json.data[0].countPirce : 0, | ||
| 375 | - countTotal: json.data[0].countTotal ? json.data[0].countTotal : 0, | ||
| 376 | - isloading: false, | ||
| 377 | - showSkeleton: false, | ||
| 378 | - }) | ||
| 379 | - }, 0) | ||
| 380 | - | ||
| 381 | - }).catch(res => { | ||
| 382 | - this.selectComponent("#network").show('网络不给力,请检查网络后重试'); | ||
| 383 | - }); | ||
| 384 | - }, | ||
| 385 | - getStatus(e) { | ||
| 386 | - this.setData({ | ||
| 387 | - status: e.currentTarget.dataset.index | ||
| 388 | - }) | 333 | + let cookbooklist=wx.getStorageSync('cookbooklist'); |
| 334 | + console.log(cookbooklist,'cookbooklistcookbooklist'); | ||
| 335 | + let cookbooklistStorage=cookbooklist?JSON.parse(cookbooklist):''; | ||
| 336 | + console.log('cookbooklist历史数据',cookbooklistStorage); | ||
| 337 | + if(cookbooklistStorage.length>0){ | ||
| 338 | + this.setData({ | ||
| 339 | + cookbooklist:cookbooklistStorage, | ||
| 340 | + isloading: false, | ||
| 341 | + showSkeleton: false, | ||
| 342 | + }) | ||
| 343 | + }else{ | ||
| 344 | + let param = { | ||
| 345 | + sellerid: this.data.options.sid, | ||
| 346 | + identity: this.data.options.identity, | ||
| 347 | + orderid: this.data.options.oid, | ||
| 348 | + status: '0,1', | ||
| 349 | + }; | ||
| 350 | + App.Advance.GetCookbookByClass(param).then(json => { | ||
| 351 | + //菜单分类添加修饰 | ||
| 352 | + let cookbooklist = this.formatCookList(json.data[0].list); | ||
| 353 | + setTimeout(() => { | ||
| 354 | + this.setData({ | ||
| 355 | + cookbooklist, | ||
| 356 | + isloading: false, | ||
| 357 | + showSkeleton: false, | ||
| 358 | + }) | ||
| 359 | + }, 0) | ||
| 360 | + }).catch(res => { | ||
| 361 | + this.selectComponent("#network").show('网络不给力,请检查网络后重试'); | ||
| 362 | + }); | ||
| 363 | + } | ||
| 389 | }, | 364 | }, |
| 390 | /** | 365 | /** |
| 391 | * 生命周期函数--监听页面显示 | 366 | * 生命周期函数--监听页面显示 |
| 392 | */ | 367 | */ |
| 393 | onShow() { | 368 | onShow() { |
| 394 | - | 369 | + let cookbooklistStorage=JSON.parse(wx.getStorageSync('cookbooklist')) |
| 370 | + console.log('cookbooklist历史数据',cookbooklistStorage); | ||
| 371 | + if(cookbooklistStorage){ | ||
| 372 | + this.setData({ | ||
| 373 | + cookbooklist:cookbooklistStorage, | ||
| 374 | + isloading: false, | ||
| 375 | + showSkeleton: false, | ||
| 376 | + }) | ||
| 377 | + }else{ | ||
| 378 | + this.getCookList() | ||
| 379 | + } | ||
| 395 | }, | 380 | }, |
| 396 | 381 | ||
| 397 | /** | 382 | /** |
| 1 | // pack-cookbook/pages/success_new.js | 1 | // pack-cookbook/pages/success_new.js |
| 2 | import App from '../../utils/api'; | 2 | import App from '../../utils/api'; |
| 3 | +import util from '../../utils/util'; | ||
| 3 | Page({ | 4 | Page({ |
| 4 | /** | 5 | /** |
| 5 | * 页面的初始数据 | 6 | * 页面的初始数据 |
| @@ -18,37 +19,66 @@ Page({ | @@ -18,37 +19,66 @@ Page({ | ||
| 18 | recharge_data: {}, | 19 | recharge_data: {}, |
| 19 | coupon_data: {}, | 20 | coupon_data: {}, |
| 20 | dataStr: Date.now() * 1 / 1000, | 21 | dataStr: Date.now() * 1 / 1000, |
| 22 | + rid:'', | ||
| 23 | + oid:'', | ||
| 21 | }, | 24 | }, |
| 22 | /** | 25 | /** |
| 23 | * 生命周期函数--监听页面加载 | 26 | * 生命周期函数--监听页面加载 |
| 24 | */ | 27 | */ |
| 25 | - onLoad(options) { | 28 | + onLoad() { |
| 26 | let obj = JSON.parse(wx.getStorageSync('cookbookObj')); | 29 | let obj = JSON.parse(wx.getStorageSync('cookbookObj')); |
| 27 | let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist')); | 30 | let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist')); |
| 31 | + this.formatCookList(cookbooklist); | ||
| 32 | + this.setData({ | ||
| 33 | + sellerName: obj.sellerName, | ||
| 34 | + sellerid: obj.sellerid, | ||
| 35 | + notes: obj.notes, | ||
| 36 | + rid:obj.rid, | ||
| 37 | + oid:obj.oid, | ||
| 38 | + }) | ||
| 39 | + console.log('obj',obj); | ||
| 40 | + this.getSellerTemplateConfFun() | ||
| 41 | + }, | ||
| 42 | + formatCookList(cookbooklist){ | ||
| 28 | let probablyPrice = 0; | 43 | let probablyPrice = 0; |
| 44 | + let noData = false; | ||
| 29 | cookbooklist.forEach(items => { | 45 | cookbooklist.forEach(items => { |
| 30 | items.is_show = false | 46 | items.is_show = false |
| 47 | + items.normsLen=0 | ||
| 31 | items.cookbooklist[0].forEach(item => { | 48 | items.cookbooklist[0].forEach(item => { |
| 32 | - let price = item.quantum * 1 * (item.price * 1); | ||
| 33 | - probablyPrice += price; | ||
| 34 | - if (item.quantum > 0) { | ||
| 35 | - items.is_show = true | 49 | + item.arr=[];//arr 点菜的菜品列表 |
| 50 | + if (item.norms.length>0) { | ||
| 51 | + item.norms.forEach(i => { | ||
| 52 | + let obj={ | ||
| 53 | + name:item.name, | ||
| 54 | + practice:i.practice, | ||
| 55 | + unit:i.unit, | ||
| 56 | + price:i.price, | ||
| 57 | + quantum:i.quantum, | ||
| 58 | + } | ||
| 59 | + item.arr.push(obj) | ||
| 60 | + let price = i.quantum * 1 * (i.price * 1); | ||
| 61 | + probablyPrice += price; | ||
| 62 | + }) | ||
| 63 | + noData = true | ||
| 64 | + items.is_show = true;//展示不展示 | ||
| 65 | + items.normsLen+=item.arr.length;//菜品数量 | ||
| 36 | } | 66 | } |
| 37 | }) | 67 | }) |
| 38 | }) | 68 | }) |
| 69 | + // wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist)) | ||
| 39 | this.setData({ | 70 | this.setData({ |
| 40 | cookbooklist, | 71 | cookbooklist, |
| 41 | - sellerName: obj.sellerName, | ||
| 42 | - sellerid: obj.sellerid, | ||
| 43 | probablyPrice, | 72 | probablyPrice, |
| 44 | - notes: obj.notes | 73 | + noData |
| 45 | }) | 74 | }) |
| 46 | - this.getSellerTemplateConfFun() | ||
| 47 | }, | 75 | }, |
| 48 | - determineFun() { | ||
| 49 | - wx.navigateTo({ | ||
| 50 | - url: `/pack-cookbook/pages/success_new?arr=${JSON.stringify(this.data.checkList)}&sellerName=${this.data.sellerName}`, | ||
| 51 | - }) | 76 | + // 菜品更换 |
| 77 | + continueOrdering(){ | ||
| 78 | + // wx.nextTick(()=>{ | ||
| 79 | + // }) | ||
| 80 | + // wx.navigateBack() | ||
| 81 | + // console.log(getCurrentPages()); | ||
| 52 | }, | 82 | }, |
| 53 | getSellerTemplateConfFun(sid) { | 83 | getSellerTemplateConfFun(sid) { |
| 54 | console.log(sid, 'sidsidsidsid'); | 84 | console.log(sid, 'sidsidsidsid'); |
| @@ -56,7 +86,6 @@ Page({ | @@ -56,7 +86,6 @@ Page({ | ||
| 56 | sid: this.data.sellerid | 86 | sid: this.data.sellerid |
| 57 | }).then(res => { | 87 | }).then(res => { |
| 58 | let data = res.data | 88 | let data = res.data |
| 59 | - console.log('data', data); | ||
| 60 | let marketing, coupon_data, priceInfo, scoreInfo, recharge_list, stringifyUse; | 89 | let marketing, coupon_data, priceInfo, scoreInfo, recharge_list, stringifyUse; |
| 61 | marketing = data.marketing ? JSON.parse(data.marketing) : ''; | 90 | marketing = data.marketing ? JSON.parse(data.marketing) : ''; |
| 62 | console.log('marketing', marketing); | 91 | console.log('marketing', marketing); |
| @@ -101,6 +130,23 @@ Page({ | @@ -101,6 +130,23 @@ Page({ | ||
| 101 | }) | 130 | }) |
| 102 | }, | 131 | }, |
| 103 | /** | 132 | /** |
| 133 | + * 用户点击右上角分享 | ||
| 134 | + */ | ||
| 135 | + onShareAppMessage() { | ||
| 136 | + let options={ | ||
| 137 | + sid:this.data.sellerid, | ||
| 138 | + rid:this.data.rid, | ||
| 139 | + oid:this.data.oid, | ||
| 140 | + identity:'1', | ||
| 141 | + hasOnlyShow:'1' | ||
| 142 | + }; | ||
| 143 | + return { | ||
| 144 | + title:'菜品已点好,快来看看都点了什么~', | ||
| 145 | + path:util.http_build_query(options,'/pack-cookbook/pages/success_new'), | ||
| 146 | + imageUrl:'http://nosqn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148571.jpg', | ||
| 147 | + } | ||
| 148 | + }, | ||
| 149 | + /** | ||
| 104 | * 生命周期函数--监听页面初次渲染完成 | 150 | * 生命周期函数--监听页面初次渲染完成 |
| 105 | */ | 151 | */ |
| 106 | onReady() { | 152 | onReady() { |
| @@ -141,11 +187,4 @@ Page({ | @@ -141,11 +187,4 @@ Page({ | ||
| 141 | onReachBottom() { | 187 | onReachBottom() { |
| 142 | 188 | ||
| 143 | }, | 189 | }, |
| 144 | - | ||
| 145 | - /** | ||
| 146 | - * 用户点击右上角分享 | ||
| 147 | - */ | ||
| 148 | - onShareAppMessage() { | ||
| 149 | - | ||
| 150 | - } | ||
| 151 | }) | 190 | }) |
| @@ -25,16 +25,16 @@ | @@ -25,16 +25,16 @@ | ||
| 25 | <block wx:for="{{cookbooklist}}" wx:key="{{item.id}}" wx:for-index="indexs"> | 25 | <block wx:for="{{cookbooklist}}" wx:key="{{item.id}}" wx:for-index="indexs"> |
| 26 | <view wx:if="{{item.is_show}}" class="title flex-lr"> | 26 | <view wx:if="{{item.is_show}}" class="title flex-lr"> |
| 27 | <view class="leftTitle">{{item.class_name}}</view> | 27 | <view class="leftTitle">{{item.class_name}}</view> |
| 28 | - <view class="rightTitle">{{item.arr.length}}道</view> | 28 | + <view class="rightTitle">{{item.normsLen}}道</view> |
| 29 | </view> | 29 | </view> |
| 30 | <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index"> | 30 | <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index"> |
| 31 | - <view wx:if="{{item.quantum>0}}" class="content flex-lr"> | ||
| 32 | - <view class="single">{{item.name}}<text>({{item.practice}})</text></view> | ||
| 33 | - <view class="price">{{item.price}}元/{{item.unit}}</view> | ||
| 34 | - <view class="count flex-cc"> | 31 | + <block wx:if="{{item.arr.length>0}}"> |
| 32 | + <view wx:for="{{item.arr}}" wx:for-index="idx" class="content flex-lr"> | ||
| 33 | + <view class="single">{{item.name}}<text>({{item.practice}})</text></view> | ||
| 34 | + <view class="price">{{item.price}}元/{{item.unit}}</view> | ||
| 35 | {{item.quantum}} | 35 | {{item.quantum}} |
| 36 | </view> | 36 | </view> |
| 37 | - </view> | 37 | + </block> |
| 38 | </block> | 38 | </block> |
| 39 | </block> | 39 | </block> |
| 40 | <view class="probably flex-ll"> | 40 | <view class="probably flex-ll"> |
| @@ -98,5 +98,5 @@ | @@ -98,5 +98,5 @@ | ||
| 98 | </scroll-view> | 98 | </scroll-view> |
| 99 | <view class="btns flex-cc"> | 99 | <view class="btns flex-cc"> |
| 100 | <button class="font32r continue flex-cc" bindtap="continueOrdering">菜品更换</button> | 100 | <button class="font32r continue flex-cc" bindtap="continueOrdering">菜品更换</button> |
| 101 | - <button class="font32r determine flex-cc" bindtap="determineFun">分享菜单</button> | 101 | + <button class="font32r determine flex-cc" open-type="share">分享菜单</button> |
| 102 | </view> | 102 | </view> |
-
Please register or login to post a comment