Commit 055f15a25bfa00a8513074629a37ee63a8f23616

Authored by yiren
1 parent 94ca23fe

提前点餐

@@ -105,7 +105,7 @@ Page({ @@ -105,7 +105,7 @@ Page({
105 icon:'none' 105 icon:'none'
106 }) 106 })
107 } 107 }
108 - if((this.data.detail.grant_num*1)<(this.data.num*1)){ 108 + if(this.data.detail.grant_num && (this.data.detail.grant_num*1)<(this.data.num*1)){
109 return wx.showToast({ 109 return wx.showToast({
110 title:'优惠券剩余数量不足!', 110 title:'优惠券剩余数量不足!',
111 duration:2000, 111 duration:2000,
@@ -82,6 +82,6 @@ @@ -82,6 +82,6 @@
82 <view class="content font24r"> 82 <view class="content font24r">
83 总计:<text>¥{{totalize}}</text>元 83 总计:<text>¥{{totalize}}</text>元
84 </view> 84 </view>
85 - <button class="font32r {{detail.grant_num=='0' || (detail.grant_num*1)<(num*1)?'btns btnsDisabled':'btns'}}" bindtap="submitOrder">提交订单 85 + <button class="font32r {{(detail.grant_num=='0' || (this.data.detail.grant_num && (detail.grant_num*1)<(num*1)))?'btns btnsDisabled':'btns'}}" bindtap="submitOrder">提交订单
86 </button> 86 </button>
87 </view> 87 </view>
1 // pack-cookbook/pages/cart_new.js 1 // pack-cookbook/pages/cart_new.js
  2 +import App from '../../utils/api';
  3 +import util from '../../utils/util';
2 Page({ 4 Page({
3 /** 5 /**
4 * 页面的初始数据 6 * 页面的初始数据
5 */ 7 */
6 data: { 8 data: {
7 cookbooklist: [], 9 cookbooklist: [],
8 - sellerName: '', 10 + options: {
  11 + sellerName: '',
  12 + sellerid: '',
  13 + rid: '',
  14 + oid: '', //订单id
  15 + sellerDate: '',
  16 + region: '',
  17 + tableNum: '',
  18 + soltName: '',
  19 + identity: '',
  20 + },
9 probablyPrice: '', 21 probablyPrice: '',
10 vipProbablyPrice: '', 22 vipProbablyPrice: '',
11 - sellerid: '',  
12 notes: '', 23 notes: '',
13 noData: false, 24 noData: false,
14 - rid: '',  
15 - oid: '',  
16 - sellerDate: '',  
17 - region: '',  
18 - tableNum: '',  
19 - soltName: '',  
20 }, 25 },
21 /** 26 /**
22 * 生命周期函数--监听页面加载 27 * 生命周期函数--监听页面加载
23 */ 28 */
24 - onLoad() {  
25 - let obj = JSON.parse(wx.getStorageSync('cookbookObj'));  
26 - let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist'));  
27 - this.formatCookList(cookbooklist); 29 + onLoad(options) {
  30 + let obj = JSON.parse(options.cookbookObj);
  31 + console.log('options', {...obj});
28 this.setData({ 32 this.setData({
29 - sellerName: obj.sellerName,  
30 - sellerid: obj.sellerid,  
31 - rid: obj.rid,  
32 - oid: obj.oid,  
33 - sellerDate: obj.sellerDate,  
34 - region: obj.region,  
35 - tableNum: obj.tableNum,  
36 - soltName: obj.soltName 33 + options: obj,
37 }) 34 })
  35 + this.setData({
  36 + options: obj,
  37 + })
  38 + this.getCheckCookList(obj);
38 }, 39 },
39 - formatCookList(cookbooklist) { 40 + // 获取点菜列表
  41 + getCheckCookList(obj) {
  42 + let param = {
  43 + sellerid: obj.sid,
  44 + identity: obj.identity,
  45 + orderid: obj.oid,
  46 + status: '0,1',
  47 + };
40 let probablyPrice = 0; 48 let probablyPrice = 0;
41 let vipProbablyPrice = 0; 49 let vipProbablyPrice = 0;
42 - let noData = false;  
43 - cookbooklist.forEach(items => {  
44 - items.is_show = false  
45 - items.normsLen = 0  
46 - items.cookbooklist[0].forEach(item => {  
47 - if (item.norms && item.norms.length > 0) {  
48 - item.norms.forEach(i => {  
49 - let price = i.quantum * 1 * (i.price * 1);  
50 - let vipPrice = i.quantum * 1 * (i.member_price * 1);  
51 - probablyPrice += price;  
52 - vipProbablyPrice += vipPrice; 50 + App.Cookbook.GetCookbookByClass(param).then(json => {
  51 + let cookbooklist = this.formatCookList(json.data[0].list)
  52 + let newArr = JSON.parse(JSON.stringify(cookbooklist))
  53 + let num = 0
  54 + for (let i = 0; i < newArr.length; i++) {
  55 + if (newArr[i].cookbooklist.length == 0) {
  56 + continue;
  57 + }
  58 + for (let j = 0; j < newArr[i].cookbooklist[0].length; j++) {
  59 + let cook_style = newArr[i].cookbooklist[0][j].cook_style
  60 + if (cook_style.image_type == 2) {
  61 + num++
  62 + } else {
  63 + if (num % 2 != 0) {
  64 + let k = cookbooklist[i].cookbooklist[0].findIndex((item) => {
  65 + return newArr[i].cookbooklist[0][j].id == item.id
  66 + })
  67 + if (k != -1) {
  68 + let temp = {
  69 + boderNone: true,
  70 + image_type: '2',
  71 + }
  72 + cookbooklist[i].cookbooklist[0].splice(k, 0, temp)
  73 + }
  74 + }
  75 + num = 0
  76 + }
  77 + }
  78 + }
  79 + cookbooklist.forEach(item => {
  80 + item.normsLen = 0
  81 + item.cookbooklist[0].forEach((cooks, idx) => {
  82 + if (cooks.order_xx && cooks.order_xx.length > 0) {
  83 + let arr = cooks.order_xx
  84 + let result = arr.reduce((obj, item) => {
  85 + let find = obj.find(i => (i.practiceid === item.practiceid && i.specid === item.specid));
  86 + let _d = {
  87 + ...item,
  88 + count: 1
  89 + };
  90 + find ? find.count++ : obj.push(_d);
  91 + return obj;
  92 + }, []);
  93 + cooks.norms = result
  94 + cooks.norms.forEach(n => {
  95 + let obj = cooks.specArr.filter(i => {
  96 + return i.id == n.specid
  97 + })
  98 + n.price = (obj[0] && obj[0].price) ? obj[0].price : cooks.price;
  99 + n.member_price = (obj[0] && obj[0].member_price) ? obj[0].member_price : cooks.member_price;
  100 + n.id = cooks.id;
  101 + n.check2 = cooks.check2;
  102 + n.cookName = cooks.name;
  103 + n.check1 = cooks.check1;
  104 + let price = n.count * 1 * (n.price * 1);
  105 + let vipPrice = n.count * 1 * (n.member_price * 1);
  106 + probablyPrice += price;
  107 + vipProbablyPrice += vipPrice;
  108 + })
  109 + item.is_show = true
  110 + item.normsLen += cooks.norms.length
  111 + } else {
  112 + cooks.norms = []
  113 + }
  114 + })
  115 + })
  116 + this.setData({
  117 + cookbooklist,
  118 + noData: true,
  119 + probablyPrice,
  120 + vipProbablyPrice
  121 + })
  122 + })
  123 + },
  124 + // 过滤数据
  125 + formatCookList(list) {
  126 + // 获取所有的规格
  127 + list.forEach(item => {
  128 + item.cookbooklist[0].forEach((i, idx) => {
  129 + i.specArr = []
  130 + let obj = {}
  131 + if (i.spec && i.spec.length > 0) {
  132 + i.spec.forEach(single => {
  133 + if (single.status == '1') {
  134 + obj = {
  135 + cid: single.cid,
  136 + clear_num: single.clear_num,
  137 + id: single.id,
  138 + member_price: single.member_price,
  139 + price: single.price,
  140 + specid: single.specid,
  141 + specs: single.specs,
  142 + status: single.status,
  143 + str: '¥' + single.price + '/' + single.specs,
  144 + member_str: single.member_price ? '会员 ¥' + single.member_price + '/' + single.specs : '',
  145 + }
  146 + i.specArr.push(obj)
  147 + }
53 }) 148 })
54 - noData = true  
55 - items.is_show = true; //展示不展示  
56 - items.normsLen += item.norms.length; //菜品数量  
57 } 149 }
58 }) 150 })
59 }) 151 })
  152 + // 排序
  153 + let sortArr = []
  154 + list.forEach(item => {
  155 + item.cookbooklist[0].sort((a, b) => {
  156 + return a.order_o - b.order_o
  157 + })
  158 + sortArr.push(item)
  159 + })
  160 + //原栏目下显示
  161 + let hasShowClass = false;
  162 + //菜单中展示沽清的菜品
  163 + let hasClearCookbook = false;
  164 + //十道必选菜
  165 + let has10CaiOpen = false;
  166 + let flist = [];
  167 + let assortArr = [];
  168 + let check1 = '';
  169 + let check2 = '';
  170 + let that = this;
  171 + let complete = false
  172 + let complete1 = false
  173 + if (sortArr.length > 0) {
  174 + has10CaiOpen = list[0].status == 1;
  175 + sortArr.forEach(function (cate, i) {
  176 + let num = 0;
  177 + let obj = {
  178 + class_name: cate.class_name,
  179 + class_type: cate.class_type,
  180 + id: cate.id,
  181 + order: cate.order,
  182 + status: cate.status,
  183 + }
  184 + if (cate.status == 1 && cate.cookbooklist[0].length > 0) {
  185 + assortArr.push(obj)
  186 + let cooks = [];
  187 + cate.cookbooklist[0].forEach(function (cook, n) {
  188 + if (cook.status == 1) {
  189 + let flag = true;
  190 + if (has10CaiOpen) {
  191 + if (cate.class_type == 2 && !hasShowClass && flist.length > 0 && flist[0].class_type == 1) {
  192 + for (let fi = 0; fi < flist[0].cookbooklist[0].length; fi++) {
  193 + if (flist[0].cookbooklist[0][fi].id == cook.id) {
  194 + flag = false;
  195 + break;
  196 + }
  197 + }
  198 + }
  199 + }
  200 + cook.item_clear_num = cook.clear_num;
  201 + if (!hasClearCookbook) { //不显示卖光了
  202 + let item_clear_num = cook.clear_num;
  203 + if (cook.specArr) {
  204 + let clear_num = null;
  205 + cook.specArr.forEach(spec => {
  206 + if (spec.clear_num == 0) {
  207 + clear_num = 0;
  208 + } else {
  209 + clear_num = null;
  210 + }
  211 + })
  212 + if (clear_num == 0) {
  213 + item_clear_num = 0;
  214 + }
  215 + }
  216 + cook.item_clear_num = item_clear_num;
  217 + cook.index = n; //分类下菜品的下标
  218 + if (!cook.order_xx || cook.order_xx.length == 0) {
  219 + cook.norms = []; //做法规格
  220 + }
  221 + cook.type = '1';
  222 + let cook_style = cook.cook_style ? util.determine(cook.cook_style) : {
  223 + image_type: '1',
  224 + name_type: ''
  225 + }; //判断是不是json,是json在转换为对象
  226 + cook.cook_style = cook_style;
  227 + cook.image_type = cook_style && cook_style.image_type ? cook_style.image_type : '1'; //1大图,2小图 默认大图
  228 + cook.name_type = cook_style && cook_style.name_type ? cook_style.name_type : '3'; //1左侧,2右侧,3顶部分开 默认分开
  229 + cook.check1 = cook.practice.length > 0 ? cook.practice[0].id : '';
  230 + cook.check2 = cook.specArr.length > 0 ? cook.specArr[0].id : '';
  231 + cook.price = cook.specArr.length > 0 ? cook.specArr[0].price : '';
  232 + cook.member_price = cook.specArr.length > 0 ? cook.specArr[0].member_price : '';
  233 + if (item_clear_num == 0) {
  234 + flag = false;
  235 + }
  236 + }
  237 + if (flag) {
  238 + cooks.push(cook);
  239 + }
  240 + }
  241 + })
  242 + if (cooks.length > 0) {
  243 + cate.cookbooklist[0] = cooks;
  244 + flist.push(cate)
  245 + }
  246 + }
  247 + })
  248 + }
60 this.setData({ 249 this.setData({
61 - cookbooklist,  
62 - probablyPrice,  
63 - vipProbablyPrice,  
64 - noData 250 + check1,
  251 + check2,
  252 + assortArr
65 }) 253 })
  254 + return flist;
  255 +
66 }, 256 },
67 // 继续点菜 257 // 继续点菜
68 continueOrdering() { 258 continueOrdering() {
@@ -71,39 +261,41 @@ Page({ @@ -71,39 +261,41 @@ Page({
71 // 确认下单 261 // 确认下单
72 determineFun() { 262 determineFun() {
73 if (this.data.noData) { 263 if (this.data.noData) {
74 - let data = {  
75 - sellerName: this.data.sellerName,  
76 - sellerid: this.data.sellerid,  
77 - notes: this.data.notes,  
78 - rid: this.data.rid,  
79 - oid: this.data.oid,  
80 - sellerDate: this.data.sellerDate,  
81 - region: this.data.region,  
82 - tableNum: this.data.tableNum,  
83 - soltName: this.data.soltName 264 + let cookbookObj = {
  265 + ...this.data.options
84 } 266 }
85 - wx.setStorageSync('cookbookObj', JSON.stringify(data))  
86 wx.navigateTo({ 267 wx.navigateTo({
87 - url: '/pack-cookbook/pages/success_new', 268 + url: `/pack-cookbook/pages/success_new?cookbookObj=${JSON.stringify(cookbookObj)}`,
88 }) 269 })
89 } 270 }
90 }, 271 },
91 // 点加减 272 // 点加减
92 countFun(e) { 273 countFun(e) {
93 - const index = e.currentTarget.dataset['index']; //菜下标  
94 - const indexs = e.currentTarget.dataset['indexs']; //分类下标  
95 - const idx = e.currentTarget.dataset['idx']; //菜品点菜的数组下标  
96 const type = e.currentTarget.dataset['type']; 274 const type = e.currentTarget.dataset['type'];
97 - let normsNum;  
98 - if (type == '1') normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[idx].quantum * 1 + 1;  
99 - if (type == '0') normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[idx].quantum * 1 - 1;  
100 - if (normsNum == 0) {  
101 - this.data.cookbooklist[indexs].cookbooklist[0][index].norms.splice(idx, 1)  
102 - } else {  
103 - this.data.cookbooklist[indexs].cookbooklist[0][index].norms[idx].quantum = normsNum; 275 + const item = e.currentTarget.dataset['item'];
  276 + let params = {
  277 + orderid: this.data.options.oid * 1,
  278 + cookbookid: item.id,
  279 + source: type,
  280 + openid: getApp().openid,
  281 + specid: item.specid,
  282 + practiceid: item.practiceid,
  283 + request_uri: this.data.request_uri == true ? 1 : '', //服务员通过消息通知进来 又加菜的标识
  284 + fromSoucre: this.data.fromSoucre ? this.data.fromSoucre : '',
  285 + identity: this.data.options.identity
  286 + }
  287 + if(type=='1'){
  288 + App.Advance.AddCart(params).then(res => {
  289 + this.getCheckCookList(this.data.options);
  290 + })
  291 + return
  292 + }
  293 + if(type=='2'){
  294 + App.Advance.ReduceOrder(params).then(res => {
  295 + this.getCheckCookList(this.data.options);
  296 + })
  297 + return
104 } 298 }
105 - wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist))  
106 - this.formatCookList(this.data.cookbooklist)  
107 }, 299 },
108 /** 300 /**
109 * 生命周期函数--监听页面初次渲染完成 301 * 生命周期函数--监听页面初次渲染完成
1 <!--pack-cookbook/pages/cart_new.wxml--> 1 <!--pack-cookbook/pages/cart_new.wxml-->
2 -<nav backgroundColor="#4d4e50" color="#fff">{{sellerName||'提交订单'}}</nav> 2 +<nav backgroundColor="#4d4e50" color="#fff">{{options.sellerName||'提交订单'}}</nav>
3 <scroll-view class="main"> 3 <scroll-view class="main">
4 <view class="info flex-lr"> 4 <view class="info flex-lr">
5 <view class="texts font28r">就餐时间:</view> 5 <view class="texts font28r">就餐时间:</view>
6 - <view class="texts_right font28r">{{sellerDate}} {{soltName}}</view> 6 + <view class="texts_right font28r">{{options.sellerDate}} {{options.soltName}}</view>
7 </view> 7 </view>
8 <view class="info flex-lr"> 8 <view class="info flex-lr">
9 <view class="texts font28r">桌位台号:</view> 9 <view class="texts font28r">桌位台号:</view>
10 - <view class="texts_right font28r">{{region}}</view> 10 + <view class="texts_right font28r">{{options.region}}</view>
11 </view> 11 </view>
12 <view class="info flex-lr"> 12 <view class="info flex-lr">
13 <view class="texts font28r">就餐人数:</view> 13 <view class="texts font28r">就餐人数:</view>
14 - <view class="texts font28r">{{tableNum}}</view> 14 + <view class="texts font28r">{{options.tableNum}}</view>
15 </view> 15 </view>
16 <view class="info flex-lr"> 16 <view class="info flex-lr">
17 <view class="texts font28r">备注信息:</view> 17 <view class="texts font28r">备注信息:</view>
@@ -27,12 +27,12 @@ @@ -27,12 +27,12 @@
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 <block wx:if="{{item.norms.length>0}}"> 28 <block wx:if="{{item.norms.length>0}}">
29 <view wx:for="{{item.norms}}" wx:for-index="idx" class="content flex-lr"> 29 <view wx:for="{{item.norms}}" wx:for-index="idx" class="content flex-lr">
30 - <view class="single">{{item.name}}<text wx:if="{{item.practiceName}}">({{item.practiceName}})</text></view>  
31 - <view class="price">{{item.price}}元/{{item.unitName}}</view> 30 + <view class="single">{{item.cookName}}<text wx:if="{{item.name}}">({{item.name}})</text></view>
  31 + <view class="price">{{item.price}}元{{item.specs?'/'+item.specs:''}}</view>
32 <view class="count flex-cc"> 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="" /> 33 + <image bindtap="countFun" data-type="2" data-item="{{item}}" src="https://qn.colorcun.com/WechatIMG809.png" class="img1" mode="" />
  34 + {{item.count}}
  35 + <image bindtap="countFun" data-type="1" data-item="{{item}}" src="https://qn.colorcun.com/WechatIMG810.png" class="img2" mode="" />
36 </view> 36 </view>
37 </view> 37 </view>
38 </block> 38 </block>
@@ -14,10 +14,8 @@ Page({ @@ -14,10 +14,8 @@ Page({
14 options: {}, 14 options: {},
15 check1: '', //做法 15 check1: '', //做法
16 check2: '', //规格 16 check2: '', //规格
17 - check1Name: '',  
18 - check2Name: '',  
19 - price:'',  
20 - member_price:'', 17 + price: '',
  18 + member_price: '',
21 isloading: true, 19 isloading: true,
22 toView: "inToView27", 20 toView: "inToView27",
23 hasEnter: false, 21 hasEnter: false,
@@ -29,28 +27,30 @@ Page({ @@ -29,28 +27,30 @@ Page({
29 cookbooklist: [], 27 cookbooklist: [],
30 checkItem: {}, 28 checkItem: {},
31 showSkeleton: true, 29 showSkeleton: true,
  30 + request_uri: false,
  31 + fromSoucre: 0,
32 order: {}, 32 order: {},
33 orderItemCount: 0, 33 orderItemCount: 0,
34 checkObj: '', 34 checkObj: '',
35 - normsIndex: '',  
36 assortArr: [], 35 assortArr: [],
  36 + checkCookbooklist: [],
37 themeColor: '', 37 themeColor: '',
38 textColor: '', 38 textColor: '',
39 navColor: '', 39 navColor: '',
40 }, 40 },
41 checkModal: '', 41 checkModal: '',
42 classifyModal: '', 42 classifyModal: '',
43 - normsLen: '',  
44 /** 43 /**
45 * 生命周期函数--监听页面加载 44 * 生命周期函数--监听页面加载
46 */ 45 */
47 onLoad: function (options) { 46 onLoad: function (options) {
48 - console.log('options', {...options}); 47 + console.log('options', {
  48 + ...options
  49 + });
49 this.setData({ 50 this.setData({
50 options: options, 51 options: options,
51 }) 52 })
52 - this.getCookList();  
53 - this.initOrder(); 53 + this.getCookList()
54 mta.Page.init({ 54 mta.Page.init({
55 "appID": "500667280", 55 "appID": "500667280",
56 "eventID": "500667287", 56 "eventID": "500667287",
@@ -64,21 +64,12 @@ Page({ @@ -64,21 +64,12 @@ Page({
64 }, 64 },
65 // 已选菜单页面跳转 65 // 已选菜单页面跳转
66 gotoShoppingCart() { 66 gotoShoppingCart() {
67 - let cookbooklist = this.data.cookbooklist;  
68 - let obj = {  
69 - sellerName: this.data.options.sellerName,  
70 - sellerid: this.data.options.sid,  
71 - rid: this.data.options.rid,  
72 - oid: this.data.options.oid,  
73 - sellerDate: this.data.options.sellerDate,  
74 - region: this.data.options.region,  
75 - tableNum: this.data.options.tableNum,  
76 - soltName: this.data.options.soltName, 67 + let cookbookObj = {
  68 + ...this.data.options
77 } 69 }
78 - wx.setStorageSync('cookbooklist', JSON.stringify(cookbooklist))  
79 - wx.setStorageSync('cookbookObj', JSON.stringify(obj)) 70 + wx.setStorageSync('cookbookObj',JSON.stringify(cookbookObj));
80 wx.navigateTo({ 71 wx.navigateTo({
81 - url: '/pack-cookbook/pages/cart_new', 72 + url: `/pack-cookbook/pages/cart_new?cookbookObj=${JSON.stringify(cookbookObj)}`,
82 }) 73 })
83 }, 74 },
84 // 选择做法 75 // 选择做法
@@ -105,19 +96,76 @@ Page({ @@ -105,19 +96,76 @@ Page({
105 checkItem, 96 checkItem,
106 }) 97 })
107 }, 98 },
108 - // 获取点菜数量  
109 - getNormsLen() {  
110 - let cookbooklist = this.data.cookbooklist;  
111 - let normsLen = 0;  
112 - cookbooklist.forEach(items => {  
113 - items.cookbooklist[0].forEach(item => {  
114 - if (item.norms && item.norms.length > 0) {  
115 - normsLen += item.norms.length 99 + // 获取点菜列表
  100 + getCheckCookList() {
  101 + let param = {
  102 + sellerid: this.data.options.sid,
  103 + identity: this.data.options.identity,
  104 + orderid: this.data.options.oid,
  105 + status: '0,1',
  106 + };
  107 + App.Cookbook.GetCookbookByClass(param).then(json => {
  108 + let cookbooklist = this.formatCookList(json.data[0].list)
  109 + let newArr = JSON.parse(JSON.stringify(cookbooklist))
  110 + let num = 0
  111 + for (let i = 0; i < newArr.length; i++) {
  112 + if (newArr[i].cookbooklist.length == 0) {
  113 + continue;
116 } 114 }
  115 + for (let j = 0; j < newArr[i].cookbooklist[0].length; j++) {
  116 + let cook_style = newArr[i].cookbooklist[0][j].cook_style
  117 + if (cook_style.image_type == 2) {
  118 + num++
  119 + } else {
  120 + if (num % 2 != 0) {
  121 + let k = cookbooklist[i].cookbooklist[0].findIndex((item) => {
  122 + return newArr[i].cookbooklist[0][j].id == item.id
  123 + })
  124 + if (k != -1) {
  125 + let temp = {
  126 + boderNone: true,
  127 + image_type: '2',
  128 + }
  129 + cookbooklist[i].cookbooklist[0].splice(k, 0, temp)
  130 + }
  131 + }
  132 + num = 0
  133 + }
  134 + }
  135 + }
  136 + cookbooklist.forEach(item => {
  137 + item.cookbooklist[0].forEach((cooks, idx) => {
  138 + if (cooks.order_xx && cooks.order_xx.length > 0) {
  139 + let arr = cooks.order_xx;
  140 + let result = arr.reduce((obj, item) => {
  141 + let find = obj.find(i => (i.practiceid === item.practiceid && i.specid === item.specid));
  142 + let _d = {
  143 + ...item,
  144 + count: 1
  145 + };
  146 + find ? find.count++ : obj.push(_d);
  147 + return obj;
  148 + }, []);
  149 + cooks.norms = result
  150 + cooks.norms.forEach(n => {
  151 + n.id = cooks.id;
  152 + n.check2 = cooks.check2;
  153 + n.cookName = cooks.name;
  154 + n.check1 = cooks.check1;
  155 + let obj = cooks.specArr.filter(i => {
  156 + return i.id == n.specid
  157 + })
  158 + n.price = (obj[0] && obj[0].price) ? obj[0].price : cooks.price;
  159 + n.member_price = (obj[0] && obj[0].member_price) ? obj[0].member_price : cooks.member_price;
  160 + })
  161 + } else {
  162 + cooks.norms = []
  163 + }
  164 + })
  165 + })
  166 + this.setData({
  167 + cookbooklist
117 }) 168 })
118 - })  
119 - this.setData({  
120 - normsLen  
121 }) 169 })
122 }, 170 },
123 // 选择菜品分类 171 // 选择菜品分类
@@ -133,37 +181,26 @@ Page({ @@ -133,37 +181,26 @@ Page({
133 determineFun() { 181 determineFun() {
134 let index = this.data.checkObj.index; 182 let index = this.data.checkObj.index;
135 let indexs = this.data.checkObj.indexs; 183 let indexs = this.data.checkObj.indexs;
136 - let data = this.data.cookbooklist[indexs].cookbooklist[0][index]  
137 - let isAlike = false;  
138 -  
139 - data.norms.forEach(item => {  
140 - if (this.data.check1 == item.practice && this.data.check2 == item.unit) {  
141 - isAlike = true  
142 - item.quantum = item.quantum * 1 + 1  
143 - }  
144 - })  
145 - if (isAlike) {  
146 - this.setData({  
147 - cookbooklist: this.data.cookbooklist,  
148 - })  
149 - } else {  
150 - let obj = {  
151 - quantum: 1,  
152 - name: data.name,  
153 - practice: this.data.check1 ? this.data.check1 : data.check1,  
154 - unit: this.data.check2 ? this.data.check2 : data.check2,  
155 - practiceName: this.data.check1Name ? this.data.check1Name : data.check1Name,  
156 - unitName: this.data.check2Name ? this.data.check2Name : data.check2Name,  
157 - price: this.data.price ? this.data.price : data.price,  
158 - member_price: this.data.member_price ? this.data.member_price : data.member_price,  
159 - }  
160 - this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj) 184 + let item = this.data.cookbooklist[indexs].cookbooklist[0][index]
  185 + let params = {
  186 + orderid: this.data.options.oid * 1,
  187 + cookbookid: item.id,
  188 + source: 1,
  189 + openid: getApp().openid,
  190 + specid: this.data.check2 ? this.data.check2 : item.check2,
  191 + practiceid: this.data.check1 ? this.data.check1 : item.check1,
  192 + request_uri: this.data.request_uri == true ? 1 : '', //服务员通过消息通知进来 又加菜的标识
  193 + fromSoucre: this.data.fromSoucre ? this.data.fromSoucre : '',
  194 + identity: this.data.options.identity
  195 + }
  196 + App.Advance.AddCart(params).then(res => {
  197 + this.closeModal()
  198 + this.getCheckCookList();
  199 + let orderItemCount = this.data.orderItemCount * 1 + 1
161 this.setData({ 200 this.setData({
162 - cookbooklist: this.data.cookbooklist, 201 + orderItemCount
163 }) 202 })
164 - }  
165 - this.closeModal()  
166 - this.getNormsLen() 203 + })
167 }, 204 },
168 // 点击加号 205 // 点击加号
169 addition(e) { 206 addition(e) {
@@ -171,7 +208,6 @@ Page({ @@ -171,7 +208,6 @@ Page({
171 const index = e.currentTarget.dataset['key']; //菜下标 208 const index = e.currentTarget.dataset['key']; //菜下标
172 const indexs = e.currentTarget.dataset['indexs']; //分类下标 209 const indexs = e.currentTarget.dataset['indexs']; //分类下标
173 const type = e.currentTarget.dataset['type']; //1 弹框 0不选规格型号 210 const type = e.currentTarget.dataset['type']; //1 弹框 0不选规格型号
174 - const normsIndex = e.currentTarget.dataset['norms']; //菜品点菜的数组下标  
175 this.setData({ 211 this.setData({
176 checkObj: { 212 checkObj: {
177 indexs, 213 indexs,
@@ -179,65 +215,65 @@ Page({ @@ -179,65 +215,65 @@ Page({
179 price: this.data.price ? this.data.price : '', 215 price: this.data.price ? this.data.price : '',
180 member_price: this.data.member_price ? this.data.member_price : '', 216 member_price: this.data.member_price ? this.data.member_price : '',
181 }, 217 },
182 - normsIndex,  
183 checkItem: item 218 checkItem: item
184 }) 219 })
185 - let norms = this.data.cookbooklist[indexs].cookbooklist[0][index].norms  
186 - let normsNum;  
187 - // 点击下面的加号并且有规格或者做法的,弹框选规格 下面的直接加 220 + // 点击下面的加号并且有规格或者做法的,弹框选规格
188 if (type == '1' && (item.practice.length > 1 || item.specArr.length > 1)) { 221 if (type == '1' && (item.practice.length > 1 || item.specArr.length > 1)) {
189 this.setData({ 222 this.setData({
190 check1: item.practice[0].id, 223 check1: item.practice[0].id,
191 check2: item.specArr[0].id, 224 check2: item.specArr[0].id,
192 - check1Name: item.practice[0].name,  
193 - check2Name: item.specArr[0].spec,  
194 - price: item.specArr[0].price,  
195 - member_price: item.specArr[0].member_price,  
196 }) 225 })
197 return this.showCheckModal() 226 return this.showCheckModal()
198 - } else {  
199 - normsNum = 1;  
200 - let obj = {  
201 - quantum: normsNum,  
202 - practice: item.check1Name,  
203 - unit: item.unit,  
204 - practiceName: item.check1Name,  
205 - unitName: item.check2Name,  
206 - name: item.name,  
207 - price: this.data.price ? this.data.price :item.price,  
208 - member_price: this.data.member_price ? this.data.member_price : item.member_price,  
209 - }  
210 - if (!normsIndex && norms.length == '0') {  
211 - this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)  
212 - }  
213 } 227 }
214 - if (type == '0' && norms.length != '0') {  
215 - normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 + 1;  
216 - this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum; 228 + //点击下面的加号,并且没有规格和做法没有多选
  229 + let practiceid, specid;
  230 + if (type == '0') {
  231 + practiceid = item.practiceid;
  232 + specid = item.specid;
217 } else { 233 } else {
218 - normsNum = 1 234 + practiceid = this.data.check1 ? this.data.check1 : item.check1;
  235 + specid = this.data.check2 ? this.data.check2 : item.check2;
219 } 236 }
220 - this.setData({  
221 - cookbooklist: this.data.cookbooklist, 237 + let params = {
  238 + orderid: this.data.options.oid * 1,
  239 + cookbookid: item.id,
  240 + source: 1,
  241 + openid: getApp().openid,
  242 + specid,
  243 + practiceid,
  244 + request_uri: this.data.request_uri == true ? 1 : '', //服务员通过消息通知进来 又加菜的标识
  245 + fromSoucre: this.data.fromSoucre ? this.data.fromSoucre : '',
  246 + identity: this.data.options.identity
  247 + }
  248 + App.Advance.AddCart(params).then(res => {
  249 + this.getCheckCookList();
  250 + let orderItemCount = this.data.orderItemCount * 1 + 1
  251 + this.setData({
  252 + orderItemCount
  253 + })
222 }) 254 })
223 - this.getNormsLen()  
224 }, 255 },
225 // 点击减号 256 // 点击减号
226 subtraction(e) { 257 subtraction(e) {
227 - const index = e.currentTarget.dataset['key']; //菜下标  
228 - const indexs = e.currentTarget.dataset['indexs']; //分类下标  
229 - const normsIndex = e.currentTarget.dataset['norms']; //菜品点菜的数组下标  
230 - let normsNum;  
231 - normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 - 1;  
232 - if (normsNum == 0) {  
233 - this.data.cookbooklist[indexs].cookbooklist[0][index].norms.splice(normsIndex, 1)  
234 - } else {  
235 - this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum; 258 + const item = e.currentTarget.dataset['item']; //菜下标
  259 + let params = {
  260 + orderid: this.data.options.oid * 1,
  261 + cookbookid: item.id,
  262 + source: 2,
  263 + openid: getApp().openid,
  264 + specid: item.specid,
  265 + practiceid: item.practiceid,
  266 + request_uri: this.data.request_uri == true ? 1 : '', //服务员通过消息通知进来 又加菜的标识
  267 + fromSoucre: this.data.fromSoucre ? this.data.fromSoucre : '',
  268 + identity: this.data.options.identity
236 } 269 }
237 - this.setData({  
238 - cookbooklist: this.data.cookbooklist, 270 + App.Advance.ReduceOrder(params).then(res => {
  271 + this.getCheckCookList();
  272 + let orderItemCount = this.data.orderItemCount * 1 - 1
  273 + this.setData({
  274 + orderItemCount
  275 + })
239 }) 276 })
240 - this.getNormsLen()  
241 }, 277 },
242 // 扫桌码点餐 278 // 扫桌码点餐
243 initOrder() { 279 initOrder() {
@@ -250,23 +286,24 @@ Page({ @@ -250,23 +286,24 @@ Page({
250 let orderItemCount = 0; 286 let orderItemCount = 0;
251 res.data.cookbooklist.forEach(cb => { 287 res.data.cookbooklist.forEach(cb => {
252 if (this.data.options.identity == 1 && cb.status > 0) { 288 if (this.data.options.identity == 1 && cb.status > 0) {
  289 + let cookbookObj = {
  290 + ...this.data.options
  291 + }
253 wx.redirectTo({ 292 wx.redirectTo({
254 - url: util.http_build_query({  
255 - rid: this.data.options.rid,  
256 - oid: res.data.id,  
257 - identity: 1,  
258 - sellerid: this.data.options.sid,  
259 - }, '/pack-cookbook/pages/success')  
260 - }); 293 + url: `/pack-cookbook/pages/success_new?cookbookObj=${JSON.stringify(cookbookObj)}`,
  294 + })
261 return false; 295 return false;
262 } 296 }
263 orderItemCount += parseInt(cb.num) 297 orderItemCount += parseInt(cb.num)
264 }) 298 })
265 this.setData({ 299 this.setData({
266 [`options.oid`]: res.data.id, 300 [`options.oid`]: res.data.id,
  301 + [`options.sellerName`]: res.data.seller.sellername,
267 order: res.data, 302 order: res.data,
268 orderItemCount: orderItemCount, 303 orderItemCount: orderItemCount,
  304 + checkCookbooklist: res.data.cookbooklist,
269 }) 305 })
  306 + this.getCheckCookList();
270 }) 307 })
271 }, 308 },
272 // 过滤数据 309 // 过滤数据
@@ -280,14 +317,14 @@ Page({ @@ -280,14 +317,14 @@ Page({
280 i.spec.forEach(single => { 317 i.spec.forEach(single => {
281 if (single.status == '1') { 318 if (single.status == '1') {
282 obj = { 319 obj = {
283 - cid:single.cid,  
284 - clear_num:single.clear_num,  
285 - id:single.id,  
286 - member_price:single.member_price,  
287 - price:single.price,  
288 - specid:single.specid,  
289 - specs:single.specs,  
290 - status:single.status, 320 + cid: single.cid,
  321 + clear_num: single.clear_num,
  322 + id: single.id,
  323 + member_price: single.member_price,
  324 + price: single.price,
  325 + specid: single.specid,
  326 + specs: single.specs,
  327 + status: single.status,
291 str: '¥' + single.price + '/' + single.specs, 328 str: '¥' + single.price + '/' + single.specs,
292 member_str: single.member_price ? '会员 ¥' + single.member_price + '/' + single.specs : '', 329 member_str: single.member_price ? '会员 ¥' + single.member_price + '/' + single.specs : '',
293 } 330 }
@@ -297,6 +334,14 @@ Page({ @@ -297,6 +334,14 @@ Page({
297 } 334 }
298 }) 335 })
299 }) 336 })
  337 + // 排序
  338 + let sortArr = []
  339 + list.forEach(item => {
  340 + item.cookbooklist[0].sort((a, b) => {
  341 + return a.order_o - b.order_o
  342 + })
  343 + sortArr.push(item)
  344 + })
300 //原栏目下显示 345 //原栏目下显示
301 let hasShowClass = false; 346 let hasShowClass = false;
302 //菜单中展示沽清的菜品 347 //菜单中展示沽清的菜品
@@ -308,9 +353,12 @@ Page({ @@ -308,9 +353,12 @@ Page({
308 let check1 = ''; 353 let check1 = '';
309 let check2 = ''; 354 let check2 = '';
310 let that = this; 355 let that = this;
311 - if (list.length > 0) { 356 + let complete = false
  357 + let complete1 = false
  358 + if (sortArr.length > 0) {
312 has10CaiOpen = list[0].status == 1; 359 has10CaiOpen = list[0].status == 1;
313 - list.forEach(function (cate, i) { 360 + sortArr.forEach(function (cate, i) {
  361 + let num = 0;
314 let obj = { 362 let obj = {
315 class_name: cate.class_name, 363 class_name: cate.class_name,
316 class_type: cate.class_type, 364 class_type: cate.class_type,
@@ -321,7 +369,6 @@ Page({ @@ -321,7 +369,6 @@ Page({
321 if (cate.status == 1 && cate.cookbooklist[0].length > 0) { 369 if (cate.status == 1 && cate.cookbooklist[0].length > 0) {
322 assortArr.push(obj) 370 assortArr.push(obj)
323 let cooks = []; 371 let cooks = [];
324 - //let cooks_order=[];  
325 cate.cookbooklist[0].forEach(function (cook, n) { 372 cate.cookbooklist[0].forEach(function (cook, n) {
326 if (cook.status == 1) { 373 if (cook.status == 1) {
327 let flag = true; 374 let flag = true;
@@ -353,18 +400,19 @@ Page({ @@ -353,18 +400,19 @@ Page({
353 } 400 }
354 cook.item_clear_num = item_clear_num; 401 cook.item_clear_num = item_clear_num;
355 cook.index = n; //分类下菜品的下标 402 cook.index = n; //分类下菜品的下标
356 - if (!cook.norms || cook.norms.length == 0) { 403 + if (!cook.order_xx || cook.order_xx.length == 0) {
357 cook.norms = []; //做法规格 404 cook.norms = []; //做法规格
358 } 405 }
359 cook.type = '1'; 406 cook.type = '1';
360 - let cook_style = cook.cook_style ? util.determine(cook.cook_style) : ''; //判断是不是json,是json在转换为对象 407 + let cook_style = cook.cook_style ? util.determine(cook.cook_style) : {
  408 + image_type: '1',
  409 + name_type: ''
  410 + }; //判断是不是json,是json在转换为对象
361 cook.cook_style = cook_style; 411 cook.cook_style = cook_style;
362 cook.image_type = cook_style && cook_style.image_type ? cook_style.image_type : '1'; //1大图,2小图 默认大图 412 cook.image_type = cook_style && cook_style.image_type ? cook_style.image_type : '1'; //1大图,2小图 默认大图
363 cook.name_type = cook_style && cook_style.name_type ? cook_style.name_type : '3'; //1左侧,2右侧,3顶部分开 默认分开 413 cook.name_type = cook_style && cook_style.name_type ? cook_style.name_type : '3'; //1左侧,2右侧,3顶部分开 默认分开
364 cook.check1 = cook.practice.length > 0 ? cook.practice[0].id : ''; 414 cook.check1 = cook.practice.length > 0 ? cook.practice[0].id : '';
365 cook.check2 = cook.specArr.length > 0 ? cook.specArr[0].id : ''; 415 cook.check2 = cook.specArr.length > 0 ? cook.specArr[0].id : '';
366 - cook.check1Name = cook.practice.length > 0 ? cook.practice[0].name : '';  
367 - cook.check2Name = cook.specArr.length > 0 ? cook.specArr[0].specs : '';  
368 cook.price = cook.specArr.length > 0 ? cook.specArr[0].price : ''; 416 cook.price = cook.specArr.length > 0 ? cook.specArr[0].price : '';
369 cook.member_price = cook.specArr.length > 0 ? cook.specArr[0].member_price : ''; 417 cook.member_price = cook.specArr.length > 0 ? cook.specArr[0].member_price : '';
370 if (item_clear_num == 0) { 418 if (item_clear_num == 0) {
@@ -373,102 +421,70 @@ Page({ @@ -373,102 +421,70 @@ Page({
373 } 421 }
374 if (flag) { 422 if (flag) {
375 cooks.push(cook); 423 cooks.push(cook);
376 - //cooks_order.push(cook.order_o);  
377 } 424 }
378 -  
379 } 425 }
380 }) 426 })
381 if (cooks.length > 0) { 427 if (cooks.length > 0) {
382 - //cooks 排序...  
383 cate.cookbooklist[0] = cooks; 428 cate.cookbooklist[0] = cooks;
384 flist.push(cate) 429 flist.push(cate)
385 } 430 }
386 } 431 }
387 }) 432 })
388 } 433 }
389 - // 排序  
390 - let sortArr = []  
391 - flist.forEach(item => {  
392 - item.cookbooklist[0].sort((a, b) => {  
393 - return a.order_o - b.order_o  
394 - })  
395 - sortArr.push(item) 434 + this.setData({
  435 + check1,
  436 + check2,
  437 + assortArr
396 }) 438 })
  439 + return flist;
397 440
398 - let image_typeArr = [];  
399 - // 大小图设置边框  
400 - sortArr.forEach(item => {  
401 - let num = 0;  
402 - item.cookbooklist[0].forEach((i, idx) => {  
403 - if (i.image_type == '1') {  
404 - i.index = 0  
405 - num = 0 441 + },
  442 + // 获取所有分类下所有菜品列表
  443 + getCookList() {
  444 + let param = {
  445 + sellerid: this.data.options.sid,
  446 + identity: this.data.options.identity,
  447 + orderid: this.data.options.oid,
  448 + status: '0,1',
  449 + };
  450 + App.Cookbook.GetCookbookByClass(param).then(json => {
  451 + let cookbooklist = this.formatCookList(json.data[0].list)
  452 + let newArr = JSON.parse(JSON.stringify(cookbooklist))
  453 + let num = 0
  454 + for (let i = 0; i < newArr.length; i++) {
  455 + if (newArr[i].cookbooklist.length == 0) {
  456 + continue;
406 } 457 }
407 - if (i.image_type == '2') {  
408 - num++  
409 - i.index = num;  
410 - if (i.index % 2 != 0) {  
411 - i.boderNone = false; 458 + for (let j = 0; j < newArr[i].cookbooklist[0].length; j++) {
  459 + let cook_style = newArr[i].cookbooklist[0][j].cook_style
  460 + if (cook_style.image_type == 2) {
  461 + num++
412 } else { 462 } else {
413 - i.boderNone = true;  
414 - }  
415 - // 下一个是大图 不是最后一个  
416 - if (item.cookbooklist[0][idx + 1].image_type == '1' && idx != item.cookbooklist[0].length - 1) {  
417 - // 是奇数  
418 if (num % 2 != 0) { 463 if (num % 2 != 0) {
419 - let s = i.index * 1 + 1;  
420 - item.cookbooklist[0].splice(idx + 1, 0, {  
421 - index: s,  
422 - boderNone: true,  
423 - image_type: '2', 464 + let k = cookbooklist[i].cookbooklist[0].findIndex((item) => {
  465 + return newArr[i].cookbooklist[0][j].id == item.id
424 }) 466 })
  467 + if (k != -1) {
  468 + let temp = {
  469 + boderNone: true,
  470 + image_type: '2',
  471 + }
  472 + cookbooklist[i].cookbooklist[0].splice(k, 0, temp)
  473 + }
425 } 474 }
  475 + num = 0
426 } 476 }
427 } 477 }
428 - })  
429 - image_typeArr.push(item)  
430 - })  
431 - setTimeout(() => {  
432 - this.setData({  
433 - check1,  
434 - check2,  
435 - assortArr  
436 - })  
437 - }, 1);  
438 - return image_typeArr;  
439 - },  
440 - // 获取所有分类下所有菜品列表  
441 - getCookList() {  
442 - let cookbooklist = wx.getStorageSync('cookbooklist');  
443 - let cookbooklistStorage = cookbooklist ? JSON.parse(cookbooklist) : '';  
444 - console.log('cookbooklist历史数据', cookbooklistStorage);  
445 - if (cookbooklistStorage.length > 0) { 478 + }
446 this.setData({ 479 this.setData({
447 - cookbooklist: this.formatCookList(cookbooklistStorage), 480 + cookbooklist,
448 isloading: false, 481 isloading: false,
449 showSkeleton: false, 482 showSkeleton: false,
450 }) 483 })
451 - } else {  
452 - let param = {  
453 - sellerid: this.data.options.sid,  
454 - identity: this.data.options.identity,  
455 - orderid: this.data.options.oid,  
456 - status: '0,1',  
457 - };  
458 - App.Cookbook.GetCookbookByClass(param).then(json => {  
459 - let cookbooklist = this.formatCookList(json.data[0].list)  
460 - console.log('cookbooklist', cookbooklist);  
461 - setTimeout(() => {  
462 - this.setData({  
463 - cookbooklist,  
464 - isloading: false,  
465 - showSkeleton: false,  
466 - })  
467 - }, 1)  
468 - }).catch(res => {  
469 - console.log(res);  
470 - });  
471 - } 484 + this.getCheckCookList()
  485 + }).catch(res => {
  486 + console.log(res);
  487 + });
472 this.GetDzSellerConfFun() 488 this.GetDzSellerConfFun()
473 }, 489 },
474 // 获取主题色 490 // 获取主题色
@@ -509,20 +525,7 @@ Page({ @@ -509,20 +525,7 @@ Page({
509 * 生命周期函数--监听页面显示 525 * 生命周期函数--监听页面显示
510 */ 526 */
511 onShow() { 527 onShow() {
512 - let cookbooklist = wx.getStorageSync('cookbooklist')  
513 - let cookbooklistStorage = cookbooklist ? JSON.parse(cookbooklist) : ''  
514 - console.log('cookbooklist历史数据', cookbooklistStorage);  
515 - if (cookbooklistStorage) {  
516 - this.setData({  
517 - cookbooklist: cookbooklistStorage,  
518 - isloading: false,  
519 - showSkeleton: false,  
520 - })  
521 - this.getNormsLen()  
522 - } else {  
523 - this.getCookList()  
524 - this.getNormsLen()  
525 - } 528 + this.initOrder()
526 }, 529 },
527 // 展示做法规格弹窗 530 // 展示做法规格弹窗
528 showCheckModal() { 531 showCheckModal() {
@@ -565,6 +568,9 @@ Page({ @@ -565,6 +568,9 @@ Page({
565 * 用户点击右上角分享 568 * 用户点击右上角分享
566 */ 569 */
567 onShareAppMessage() { 570 onShareAppMessage() {
568 - 571 + return {
  572 + title: '一起来点菜啦!',
  573 + imageUrl: 'http://nosqn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20191115114857.jpg',
  574 + }
569 } 575 }
570 }) 576 })
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 </block> 19 </block>
20 <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index"> 20 <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index">
21 <!-- name_type 1左侧,2右侧,3顶部分开 image_type 1大图,2小图 --> 21 <!-- name_type 1左侧,2右侧,3顶部分开 image_type 1大图,2小图 -->
22 - <view wx:if="{{item.image_type=='1'}}" class="oneBox" data-idx="{{item.index}}" data-nameType="{{item.name_type}}"> 22 + <view wx:if="{{item.image_type=='1'}}" class="oneBox" data-idx="{{item.image_type}}" data-nameType="{{item.name_type}}">
23 <block wx:if="{{item.name_type!='3'}}"> 23 <block wx:if="{{item.name_type!='3'}}">
24 <view class="dishItem {{item.name_type=='2'?'typeB':''}}"> 24 <view class="dishItem {{item.name_type=='2'?'typeB':''}}">
25 <view class="dishLeft dishTexts" style="color:rgba({{textColor}})"> 25 <view class="dishLeft dishTexts" style="color:rgba({{textColor}})">
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 </view> 31 </view>
32 </view> 32 </view>
33 <view wx:if="{{item.specArr.length>0}}" class="norms {{item.name_type=='2'?'normsB':''}}" style="color:rgba({{navColor}})"> 33 <view wx:if="{{item.specArr.length>0}}" class="norms {{item.name_type=='2'?'normsB':''}}" style="color:rgba({{navColor}})">
34 - <view wx:for="{{item.specArr}}"> 34 + <view wx:for="{{item.specArr}}" wx:key="{{item.id}}">
35 {{item.str}} 35 {{item.str}}
36 {{item.member_str}} 36 {{item.member_str}}
37 </view> 37 </view>
@@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
47 {{item.name}} 47 {{item.name}}
48 </view> 48 </view>
49 <view wx:if="{{item.specArr.length>0}}" style="color:rgba({{textColor}})" class="norms {{item.name_type=='2'?'normsB':''}}" style="color:rgba({{navColor}})"> 49 <view wx:if="{{item.specArr.length>0}}" style="color:rgba({{textColor}})" class="norms {{item.name_type=='2'?'normsB':''}}" style="color:rgba({{navColor}})">
50 - <view wx:for="{{item.specArr}}"> 50 + <view wx:for="{{item.specArr}}" wx:key="{{item.id}}">
51 {{item.str}} 51 {{item.str}}
52 {{item.member_str}} 52 {{item.member_str}}
53 </view> 53 </view>
@@ -66,21 +66,21 @@ @@ -66,21 +66,21 @@
66 <view class="greens" wx:if="{{item.desc}}"> 66 <view class="greens" wx:if="{{item.desc}}">
67 <view class="news" style="color:rgba({{textColor}})">{{item.desc}}</view> 67 <view class="news" style="color:rgba({{textColor}})">{{item.desc}}</view>
68 </view> 68 </view>
69 - <view wx:for="{{item.norms}}" wx:for-index="normsIndex" class="algorithmImg flex-lr calculate">  
70 - <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG697.png':'https://qn.colorcun.com/Line2.png'}}" mode="aspectFill" class="reduceImg" bindtap="subtraction" data-item="{{item}}" data-norms="{{normsIndex}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 69 + <view wx:for="{{item.norms}}" wx:key="{{item.id}}" wx:for-index="normsIndex" class="algorithmImg flex-lr calculate">
  70 + <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG697.png':'https://qn.colorcun.com/Line2.png'}}" mode="aspectFill" class="reduceImg" bindtap="subtraction" data-item="{{item}}"/>
71 <view class="box flex-cc"> 71 <view class="box flex-cc">
72 <view class="num flex-cc"> 72 <view class="num flex-cc">
73 - {{item.quantum}}<view style="color:rgba({{textColor}})">{{item.unitName}}</view> 73 + {{item.count}}<view wx:if="{{item.name}}" style="color:rgba({{textColor}})">{{item.name}}</view>
74 </view> 74 </view>
75 - <view class="practice" style="color:rgba({{textColor}})">{{item.practiceName}}</view> 75 + <view class="practice" wx:if="{{item.specs}}" style="color:rgba({{textColor}})">{{item.specs}}</view>
76 </view> 76 </view>
77 - <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG696.png':'https://qn.colorcun.com/Line1.png'}}" mode="aspectFill" class="imgs" data-type="0" bindtap="addition" data-norms="{{normsIndex}}" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 77 + <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG696.png':'https://qn.colorcun.com/Line1.png'}}" mode="aspectFill" class="imgs" data-type="0" bindtap="addition" data-item="{{item}}"/>
78 </view> 78 </view>
79 <view wx:if="{{(item.specArr.length>1 || item.practice.length>1) || item.norms.length=='0'}}" class="algorithmImg flex-rr imgbox"> 79 <view wx:if="{{(item.specArr.length>1 || item.practice.length>1) || item.norms.length=='0'}}" class="algorithmImg flex-rr imgbox">
80 - <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG696.png':'https://qn.colorcun.com/Line1.png'}}" class="imgs" mode="aspectFill" bindtap="addition" data-norms="{{normsIndex}}" data-type="1" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 80 + <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG696.png':'https://qn.colorcun.com/Line1.png'}}" class="imgs" mode="aspectFill" bindtap="addition" data-type="1" data-item="{{item}}"/>
81 </view> 81 </view>
82 </view> 82 </view>
83 - <view wx:else class="twoBox" data-idx="{{item.index}}" data-nameType="{{item.name_type}}"> 83 + <view wx:else class="twoBox" data-idx="{{item.image_type}}" data-nameType="{{item.name_type}}">
84 <view class="{{item.boderNone?'borderNone twoItem':'twoItem'}}"> 84 <view class="{{item.boderNone?'borderNone twoItem':'twoItem'}}">
85 <view class="twoTitle" style="color:rgba({{textColor}})">{{item.name}}</view> 85 <view class="twoTitle" style="color:rgba({{textColor}})">{{item.name}}</view>
86 <view class="twoInfo dishTexts" wx:if="{{item.taste}}"> 86 <view class="twoInfo dishTexts" wx:if="{{item.taste}}">
@@ -88,7 +88,7 @@ @@ -88,7 +88,7 @@
88 <text wx:if="{{item.cooks}}">烹调:{{item.cooks}}</text> 88 <text wx:if="{{item.cooks}}">烹调:{{item.cooks}}</text>
89 </view> 89 </view>
90 <view wx:if="{{item.specArr.length>0}}" class="twoInfo twoSingle" style="color:rgba({{textColor}})"> 90 <view wx:if="{{item.specArr.length>0}}" class="twoInfo twoSingle" style="color:rgba({{textColor}})">
91 - <view wx:for="{{item.specArr}}"> 91 + <view wx:for="{{item.specArr}}" wx:key="{{item.id}}">
92 {{item.str}} 92 {{item.str}}
93 {{item.member_str}} 93 {{item.member_str}}
94 </view> 94 </view>
@@ -101,18 +101,18 @@ @@ -101,18 +101,18 @@
101 <view class="greens" wx:if="{{item.desc}}"> 101 <view class="greens" wx:if="{{item.desc}}">
102 <view class="news" style="color:rgba({{textColor}})">{{item.desc}}</view> 102 <view class="news" style="color:rgba({{textColor}})">{{item.desc}}</view>
103 </view> 103 </view>
104 - <view wx:for="{{item.norms}}" wx:for-index="normsIndex" class="algorithmImg flex-lr calculate">  
105 - <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG697.png':'https://qn.colorcun.com/Line2.png'}}" mode="aspectFill" class="reduceImg" bindtap="subtraction" data-item="{{item}}" data-norms="{{normsIndex}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 104 + <view wx:for="{{item.norms}}" wx:key="{{item.unit}}" wx:for-index="normsIndex" class="algorithmImg flex-lr calculate">
  105 + <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG697.png':'https://qn.colorcun.com/Line2.png'}}" mode="aspectFill" class="reduceImg" bindtap="subtraction" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" />
106 <view class="box flex-cc"> 106 <view class="box flex-cc">
107 <view class="num flex-cc"> 107 <view class="num flex-cc">
108 - {{item.quantum}}<view style="color:rgba({{textColor}})">{{item.unitName}}</view> 108 + {{item.count}}<view wx:if="{{item.name}}" style="color:rgba({{textColor}})">{{item.name}}</view>
109 </view> 109 </view>
110 - <view class="practice" style="color:rgba({{textColor}})">{{item.practiceName}}</view> 110 + <view class="practice" wx:if="{{item.specs}}" style="color:rgba({{textColor}})">{{item.specs}}</view>
111 </view> 111 </view>
112 - <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG696.png':'https://qn.colorcun.com/Line1.png'}}" mode="aspectFill" class="imgs" data-type="0" bindtap="addition" data-norms="{{normsIndex}}" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 112 + <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG696.png':'https://qn.colorcun.com/Line1.png'}}" mode="aspectFill" class="imgs" data-type="0" bindtap="addition" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" />
113 </view> 113 </view>
114 <view wx:if="{{(item.spec.length>1 || item.practice.length>1) || item.norms.length=='0'}}" class="algorithmImg flex-rr imgbox"> 114 <view wx:if="{{(item.spec.length>1 || item.practice.length>1) || item.norms.length=='0'}}" class="algorithmImg flex-rr imgbox">
115 - <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG696.png':'https://qn.colorcun.com/Line1.png'}}" class="imgs" mode="aspectFill" bindtap="addition" data-norms="{{normsIndex}}" data-type="1" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" /> 115 + <image wx:if="{{item.id}}" src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG696.png':'https://qn.colorcun.com/Line1.png'}}" class="imgs" mode="aspectFill" bindtap="addition" data-type="1" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" />
116 </view> 116 </view>
117 </view> 117 </view>
118 </view> 118 </view>
@@ -130,7 +130,7 @@ @@ -130,7 +130,7 @@
130 <view class="right flex-cmc" bindtap="gotoShoppingCart"> 130 <view class="right flex-cmc" bindtap="gotoShoppingCart">
131 <view class="rightBox"> 131 <view class="rightBox">
132 <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG701.png':'https://qn.colorcun.com/s2.png'}}" mode="" /> 132 <image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG701.png':'https://qn.colorcun.com/s2.png'}}" mode="" />
133 - <view class="num" wx:if="{{normsLen}}">{{normsLen}}</view> 133 + <view class="num" wx:if="{{orderItemCount}}">{{orderItemCount}}</view>
134 </view> 134 </view>
135 <view class="fixedName" style="color:rgba({{textColor}})"> 135 <view class="fixedName" style="color:rgba({{textColor}})">
136 已选菜品 136 已选菜品
@@ -154,7 +154,6 @@ page { @@ -154,7 +154,6 @@ page {
154 font-size: 32rpx; 154 font-size: 32rpx;
155 margin: 0 20rpx; 155 margin: 0 20rpx;
156 } 156 }
157 -  
158 .twoItem { 157 .twoItem {
159 width: 100%; 158 width: 100%;
160 box-sizing: border-box; 159 box-sizing: border-box;
@@ -437,4 +436,15 @@ page { @@ -437,4 +436,15 @@ page {
437 display: flex; 436 display: flex;
438 justify-content: center; 437 justify-content: center;
439 flex-direction: column; 438 flex-direction: column;
  439 +}
  440 +.twoItem .num view{
  441 + font-size:24rpx;
  442 + margin: 0 10rpx;
  443 +}
  444 +
  445 +.twoItem .practice{
  446 + font-size:24rpx;
  447 +}
  448 +.twoItem .box .num {
  449 + font-size: 60rpx;
440 } 450 }
@@ -10,7 +10,7 @@ Page({ @@ -10,7 +10,7 @@ Page({
10 sellerName: '', 10 sellerName: '',
11 sellerid: '', 11 sellerid: '',
12 probablyPrice: '', 12 probablyPrice: '',
13 - vipProbablyPrice:'', 13 + vipProbablyPrice: '',
14 discount: '', 14 discount: '',
15 stringifyUse: '', 15 stringifyUse: '',
16 priceInfo: '', 16 priceInfo: '',
@@ -20,95 +20,264 @@ Page({ @@ -20,95 +20,264 @@ Page({
20 recharge_data: {}, 20 recharge_data: {},
21 coupon_data: {}, 21 coupon_data: {},
22 dataStr: Date.now() * 1 / 1000, 22 dataStr: Date.now() * 1 / 1000,
23 - rid:'',  
24 - oid:'',  
25 - sellerDate:'',  
26 - region:'',  
27 - tableNum:'',  
28 - soltName:'', 23 + rid: '',
  24 + oid: '',
  25 + sellerDate: '',
  26 + region: '',
  27 + tableNum: '',
  28 + soltName: '',
29 }, 29 },
30 /** 30 /**
31 * 生命周期函数--监听页面加载 31 * 生命周期函数--监听页面加载
32 */ 32 */
33 - onLoad() {  
34 - let obj = JSON.parse(wx.getStorageSync('cookbookObj'));  
35 - let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist'));  
36 - this.formatCookList(cookbooklist); 33 + onLoad(options) {
  34 + let obj = util.determine(options.cookbookObj);
  35 + console.log('options', {...obj});
37 this.setData({ 36 this.setData({
38 - sellerName: obj.sellerName,  
39 - sellerid: obj.sellerid,  
40 - notes: obj.notes,  
41 - rid:obj.rid,  
42 - oid:obj.oid,  
43 - sellerDate: obj.sellerDate,  
44 - region: obj.region,  
45 - tableNum: obj.tableNum,  
46 - soltName:obj.soltName 37 + options: obj,
47 }) 38 })
48 - console.log('obj',obj); 39 + this.getCheckCookList(obj);
49 this.getSellerTemplateConfFun() 40 this.getSellerTemplateConfFun()
50 }, 41 },
51 - formatCookList(cookbooklist){  
52 - let probablyPrice = 0;  
53 - let vipProbablyPrice = 0;  
54 - let noData = false;  
55 - cookbooklist.forEach(items => {  
56 - items.is_show = false  
57 - items.normsLen=0  
58 - items.cookbooklist[0].forEach(item => {  
59 - item.arr=[];//arr 点菜的菜品列表  
60 - if (item.norms && item.norms.length>0) {  
61 - item.norms.forEach(i => {  
62 - let obj={  
63 - name:item.name,  
64 - practice:i.practice,  
65 - unit:i.unit,  
66 - price:i.price,  
67 - quantum:i.quantum, 42 + // 过滤数据
  43 + formatCookList(list) {
  44 + // 获取所有的规格
  45 + list.forEach(item => {
  46 + item.cookbooklist[0].forEach((i, idx) => {
  47 + i.specArr = []
  48 + let obj = {}
  49 + if (i.spec && i.spec.length > 0) {
  50 + i.spec.forEach(single => {
  51 + if (single.status == '1') {
  52 + obj = {
  53 + cid: single.cid,
  54 + clear_num: single.clear_num,
  55 + id: single.id,
  56 + member_price: single.member_price,
  57 + price: single.price,
  58 + specid: single.specid,
  59 + specs: single.specs,
  60 + status: single.status,
  61 + str: '¥' + single.price + '/' + single.specs,
  62 + member_str: single.member_price ? '会员 ¥' + single.member_price + '/' + single.specs : '',
  63 + }
  64 + i.specArr.push(obj)
68 } 65 }
69 - item.arr.push(obj)  
70 - let price = i.quantum * 1 * (i.price * 1);  
71 - let vipPrice = i.quantum * 1 * (i.member_price * 1);  
72 - probablyPrice += price;  
73 - vipProbablyPrice += vipPrice;  
74 }) 66 })
75 - noData = true  
76 - items.is_show = true;//展示不展示  
77 - items.normsLen+=item.arr.length;//菜品数量  
78 } 67 }
79 }) 68 })
80 }) 69 })
81 - // wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist)) 70 + // 排序
  71 + let sortArr = []
  72 + list.forEach(item => {
  73 + item.cookbooklist[0].sort((a, b) => {
  74 + return a.order_o - b.order_o
  75 + })
  76 + sortArr.push(item)
  77 + })
  78 + //原栏目下显示
  79 + let hasShowClass = false;
  80 + //菜单中展示沽清的菜品
  81 + let hasClearCookbook = false;
  82 + //十道必选菜
  83 + let has10CaiOpen = false;
  84 + let flist = [];
  85 + let assortArr = [];
  86 + let check1 = '';
  87 + let check2 = '';
  88 + let that = this;
  89 + let complete = false
  90 + let complete1 = false
  91 + if (sortArr.length > 0) {
  92 + has10CaiOpen = list[0].status == 1;
  93 + sortArr.forEach(function (cate, i) {
  94 + let num = 0;
  95 + let obj = {
  96 + class_name: cate.class_name,
  97 + class_type: cate.class_type,
  98 + id: cate.id,
  99 + order: cate.order,
  100 + status: cate.status,
  101 + }
  102 + if (cate.status == 1 && cate.cookbooklist[0].length > 0) {
  103 + assortArr.push(obj)
  104 + let cooks = [];
  105 + cate.cookbooklist[0].forEach(function (cook, n) {
  106 + if (cook.status == 1) {
  107 + let flag = true;
  108 + if (has10CaiOpen) {
  109 + if (cate.class_type == 2 && !hasShowClass && flist.length > 0 && flist[0].class_type == 1) {
  110 + for (let fi = 0; fi < flist[0].cookbooklist[0].length; fi++) {
  111 + if (flist[0].cookbooklist[0][fi].id == cook.id) {
  112 + flag = false;
  113 + break;
  114 + }
  115 + }
  116 + }
  117 + }
  118 + cook.item_clear_num = cook.clear_num;
  119 + if (!hasClearCookbook) { //不显示卖光了
  120 + let item_clear_num = cook.clear_num;
  121 + if (cook.specArr) {
  122 + let clear_num = null;
  123 + cook.specArr.forEach(spec => {
  124 + if (spec.clear_num == 0) {
  125 + clear_num = 0;
  126 + } else {
  127 + clear_num = null;
  128 + }
  129 + })
  130 + if (clear_num == 0) {
  131 + item_clear_num = 0;
  132 + }
  133 + }
  134 + cook.item_clear_num = item_clear_num;
  135 + cook.index = n; //分类下菜品的下标
  136 + if (!cook.order_xx || cook.order_xx.length == 0) {
  137 + cook.norms = []; //做法规格
  138 + }
  139 + cook.type = '1';
  140 + let cook_style = cook.cook_style ? util.determine(cook.cook_style) : {
  141 + image_type: '1',
  142 + name_type: ''
  143 + }; //判断是不是json,是json在转换为对象
  144 + cook.cook_style = cook_style;
  145 + cook.image_type = cook_style && cook_style.image_type ? cook_style.image_type : '1'; //1大图,2小图 默认大图
  146 + cook.name_type = cook_style && cook_style.name_type ? cook_style.name_type : '3'; //1左侧,2右侧,3顶部分开 默认分开
  147 + cook.check1 = cook.practice.length > 0 ? cook.practice[0].id : '';
  148 + cook.check2 = cook.specArr.length > 0 ? cook.specArr[0].id : '';
  149 + cook.price = cook.specArr.length > 0 ? cook.specArr[0].price : '';
  150 + cook.member_price = cook.specArr.length > 0 ? cook.specArr[0].member_price : '';
  151 + if (item_clear_num == 0) {
  152 + flag = false;
  153 + }
  154 + }
  155 + if (flag) {
  156 + cooks.push(cook);
  157 + }
  158 + }
  159 + })
  160 + if (cooks.length > 0) {
  161 + cate.cookbooklist[0] = cooks;
  162 + flist.push(cate)
  163 + }
  164 + }
  165 + })
  166 + }
82 this.setData({ 167 this.setData({
83 - cookbooklist,  
84 - probablyPrice,  
85 - vipProbablyPrice,  
86 - noData 168 + check1,
  169 + check2,
  170 + assortArr
  171 + })
  172 + return flist;
  173 +
  174 + },
  175 + // 获取点菜列表
  176 + getCheckCookList(obj) {
  177 + let param = {
  178 + sellerid: obj.sid,
  179 + identity: obj.identity,
  180 + orderid: obj.oid,
  181 + status: '0,1',
  182 + };
  183 + let probablyPrice = 0;
  184 + let vipProbablyPrice = 0;
  185 + App.Cookbook.GetCookbookByClass(param).then(json => {
  186 + let cookbooklist = this.formatCookList(json.data[0].list)
  187 + let newArr = JSON.parse(JSON.stringify(cookbooklist))
  188 + let num = 0
  189 + for (let i = 0; i < newArr.length; i++) {
  190 + if (newArr[i].cookbooklist.length == 0) {
  191 + continue;
  192 + }
  193 + for (let j = 0; j < newArr[i].cookbooklist[0].length; j++) {
  194 + let cook_style = newArr[i].cookbooklist[0][j].cook_style
  195 + if (cook_style.image_type == 2) {
  196 + num++
  197 + } else {
  198 + if (num % 2 != 0) {
  199 + let k = cookbooklist[i].cookbooklist[0].findIndex((item) => {
  200 + return newArr[i].cookbooklist[0][j].id == item.id
  201 + })
  202 + if (k != -1) {
  203 + let temp = {
  204 + boderNone: true,
  205 + image_type: '2',
  206 + }
  207 + cookbooklist[i].cookbooklist[0].splice(k, 0, temp)
  208 + }
  209 + }
  210 + num = 0
  211 + }
  212 + }
  213 + }
  214 + cookbooklist.forEach(item => {
  215 + item.normsLen = 0
  216 + item.cookbooklist[0].forEach((cooks, idx) => {
  217 + if (cooks.order_xx && cooks.order_xx.length > 0) {
  218 + let arr = cooks.order_xx
  219 + let result = arr.reduce((obj, item) => {
  220 + let find = obj.find(i => (i.practiceid === item.practiceid && i.specid === item.specid));
  221 + let _d = {
  222 + ...item,
  223 + count: 1
  224 + };
  225 + find ? find.count++ : obj.push(_d);
  226 + return obj;
  227 + }, []);
  228 + cooks.norms = result
  229 + cooks.norms.forEach(n => {
  230 + let obj = cooks.specArr.filter(i => {
  231 + return i.id == n.specid
  232 + })
  233 + n.price = (obj[0] && obj[0].price) ? obj[0].price : cooks.price;
  234 + n.member_price = (obj[0] && obj[0].member_price) ? obj[0].member_price : cooks.member_price;
  235 + n.id = cooks.id;
  236 + n.check2 = cooks.check2;
  237 + n.cookName = cooks.name;
  238 + n.check1 = cooks.check1;
  239 + let price = n.count * 1 * (n.price * 1);
  240 + let vipPrice = n.count * 1 * (n.member_price * 1);
  241 + probablyPrice += price;
  242 + vipProbablyPrice += vipPrice;
  243 + })
  244 + item.is_show = true
  245 + item.normsLen += cooks.norms.length
  246 + } else {
  247 + cooks.norms = []
  248 + }
  249 + })
  250 + })
  251 + this.setData({
  252 + cookbooklist,
  253 + noData: true,
  254 + probablyPrice,
  255 + vipProbablyPrice
  256 + })
87 }) 257 })
88 }, 258 },
89 // 菜品更换 259 // 菜品更换
90 - continueOrdering(){ 260 + continueOrdering() {
  261 + console.log({...this.data.options});
91 wx.reLaunch({ 262 wx.reLaunch({
92 - url: `/pack-cookbook/pages/index_new?rid=${this.data.rid}&sid=${this.data.sellerid}&oid=${this.data.oid}&sellerName=${this.data.sellerName}&identity=1`, 263 + url: `/pack-cookbook/pages/index_new?rid=${this.data.options.rid}&sid=${this.data.options.sid}&oid=${this.data.options.oid}&sellerName=${this.data.options.sellerName}&identity=1`,
93 }) 264 })
94 }, 265 },
95 // 点击了解更多会员优惠政策 266 // 点击了解更多会员优惠政策
96 - gotoFavourableList(){  
97 - let url=util.http_build_query({  
98 - sellerName:this.data.sellerName,  
99 - sellerid:this.data.sellerid,  
100 - oid:this.data.oid,  
101 - types:'2',  
102 - },'/pack-cookbook/pages/favourableList')  
103 - console.log(url); 267 + gotoFavourableList() {
  268 + let url = util.http_build_query({
  269 + sellerName: this.data.sellerName,
  270 + sellerid: this.data.sid,
  271 + oid: this.data.oid,
  272 + types: '2',
  273 + }, '/pack-cookbook/pages/favourableList')
104 wx.navigateTo({ 274 wx.navigateTo({
105 - url 275 + url
106 }) 276 })
107 }, 277 },
108 - getSellerTemplateConfFun(sid) {  
109 - console.log(sid, 'sidsidsidsid'); 278 + getSellerTemplateConfFun() {
110 App.Seller.GetSellerTemplateConf({ 279 App.Seller.GetSellerTemplateConf({
111 - sid: this.data.sellerid 280 + sid: this.data.sid
112 }).then(res => { 281 }).then(res => {
113 let data = res.data 282 let data = res.data
114 let marketing, coupon_data, priceInfo, scoreInfo, recharge_list, stringifyUse; 283 let marketing, coupon_data, priceInfo, scoreInfo, recharge_list, stringifyUse;
@@ -158,17 +327,17 @@ Page({ @@ -158,17 +327,17 @@ Page({
158 * 用户点击右上角分享 327 * 用户点击右上角分享
159 */ 328 */
160 onShareAppMessage() { 329 onShareAppMessage() {
161 - let options={  
162 - sid:this.data.sellerid,  
163 - rid:this.data.rid,  
164 - oid:this.data.oid,  
165 - identity:'1',  
166 - hasOnlyShow:'1' 330 + let options = {
  331 + sid: this.data.sid,
  332 + rid: this.data.rid,
  333 + oid: this.data.oid,
  334 + identity: '1',
  335 + hasOnlyShow: '1'
167 }; 336 };
168 return { 337 return {
169 - title:'菜品已点好,快来看看都点了什么~',  
170 - path:util.http_build_query(options,'/pack-cookbook/pages/success_new'),  
171 - imageUrl:'http://nosqn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148571.jpg', 338 + title: '菜品已点好,快来看看都点了什么~',
  339 + path: util.http_build_query(options, '/pack-cookbook/pages/success_new'),
  340 + imageUrl: 'http://nosqn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148571.jpg',
172 } 341 }
173 }, 342 },
174 /** 343 /**
1 <!--pack-cookbook/pages/success_new.wxml--> 1 <!--pack-cookbook/pages/success_new.wxml-->
2 -<nav backgroundColor="#4d4e50" color="#fff">{{sellerName||'提交订单'}}</nav> 2 +<nav backgroundColor="#4d4e50" color="#fff">{{options.sellerName||'提交订单'}}</nav>
3 <scroll-view class="main"> 3 <scroll-view class="main">
4 <view class="box"> 4 <view class="box">
5 <view class="info flex-lr"> 5 <view class="info flex-lr">
6 <view class="texts font28r">就餐时间:</view> 6 <view class="texts font28r">就餐时间:</view>
7 - <view class="texts_right font28r">{{sellerDate}} {{soltName}}</view> 7 + <view class="texts_right font28r">{{options.sellerDate}} {{soltName}}</view>
8 </view> 8 </view>
9 <view class="info flex-lr"> 9 <view class="info flex-lr">
10 <view class="texts font28r">桌位台号:</view> 10 <view class="texts font28r">桌位台号:</view>
11 - <view class="texts_right font28r">{{region}}</view> 11 + <view class="texts_right font28r">{{options.region}}</view>
12 </view> 12 </view>
13 <view class="info flex-lr"> 13 <view class="info flex-lr">
14 <view class="texts font28r">就餐人数:</view> 14 <view class="texts font28r">就餐人数:</view>
15 - <view class="texts font28r">{{tableNum}}</view> 15 + <view class="texts font28r">{{options.tableNum}}</view>
16 </view> 16 </view>
17 <view class="info flex-lr"> 17 <view class="info flex-lr">
18 <view class="texts font28r">备注信息:</view> 18 <view class="texts font28r">备注信息:</view>
19 - <view class="texts font28r">{{notes}}</view> 19 + <view class="texts font28r">{{options.notes}}</view>
20 </view> 20 </view>
21 <image class="imgs" src="https://qn.colorcun.com/001.png" mode="" /> 21 <image class="imgs" src="https://qn.colorcun.com/001.png" mode="" />
22 </view> 22 </view>
@@ -28,11 +28,11 @@ @@ -28,11 +28,11 @@
28 <view class="rightTitle">{{item.normsLen}}道</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 - <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}} 31 + <block wx:if="{{item.norms.length>0}}">
  32 + <view wx:for="{{item.norms}}" wx:for-index="idx" class="content flex-lr">
  33 + <view class="single">{{item.cookName}}<text wx:if="{{item.name}}">({{item.name}})</text></view>
  34 + <view class="price">{{item.price}}元{{item.specs?'/'+item.specs:''}}</view>
  35 + {{item.count}}
36 </view> 36 </view>
37 </block> 37 </block>
38 </block> 38 </block>
@@ -208,7 +208,7 @@ Page({ @@ -208,7 +208,7 @@ Page({
208 rid: this.id, 208 rid: this.id,
209 oid: this.data.detail.order.id, 209 oid: this.data.detail.order.id,
210 identity: 1 210 identity: 1
211 - }, '/pack-cookbook/pages/success') 211 + }, '/pack-cookbook/pages/success_new')
212 }); 212 });
213 } else { 213 } else {
214 App.Advance.CreateOrder({ 214 App.Advance.CreateOrder({
@@ -230,7 +230,7 @@ Page({ @@ -230,7 +230,7 @@ Page({
230 soltName:this.data.seller.soltName, 230 soltName:this.data.seller.soltName,
231 region:this.data.seller.region+this.data.seller.room, 231 region:this.data.seller.region+this.data.seller.room,
232 tableNum:this.data.detail.actual_pum?this.data.detail.actual_pum:this.data.tableNum 232 tableNum:this.data.detail.actual_pum?this.data.detail.actual_pum:this.data.tableNum
233 - }, '/pack-cookbook/pages/index') 233 + }, '/pack-cookbook/pages/index_new')
234 }); 234 });
235 }) 235 })
236 } 236 }