Commit 055f15a25bfa00a8513074629a37ee63a8f23616

Authored by yiren
1 parent 94ca23fe

提前点餐

... ... @@ -105,7 +105,7 @@ Page({
icon:'none'
})
}
if((this.data.detail.grant_num*1)<(this.data.num*1)){
if(this.data.detail.grant_num && (this.data.detail.grant_num*1)<(this.data.num*1)){
return wx.showToast({
title:'优惠券剩余数量不足!',
duration:2000,
... ...
... ... @@ -82,6 +82,6 @@
<view class="content font24r">
总计:<text>¥{{totalize}}</text>元
</view>
<button class="font32r {{detail.grant_num=='0' || (detail.grant_num*1)<(num*1)?'btns btnsDisabled':'btns'}}" bindtap="submitOrder">提交订单
<button class="font32r {{(detail.grant_num=='0' || (this.data.detail.grant_num && (detail.grant_num*1)<(num*1)))?'btns btnsDisabled':'btns'}}" bindtap="submitOrder">提交订单
</button>
</view>
\ No newline at end of file
... ...
// pack-cookbook/pages/cart_new.js
import App from '../../utils/api';
import util from '../../utils/util';
Page({
/**
* 页面的初始数据
*/
data: {
cookbooklist: [],
sellerName: '',
options: {
sellerName: '',
sellerid: '',
rid: '',
oid: '', //订单id
sellerDate: '',
region: '',
tableNum: '',
soltName: '',
identity: '',
},
probablyPrice: '',
vipProbablyPrice: '',
sellerid: '',
notes: '',
noData: false,
rid: '',
oid: '',
sellerDate: '',
region: '',
tableNum: '',
soltName: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
let obj = JSON.parse(wx.getStorageSync('cookbookObj'));
let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist'));
this.formatCookList(cookbooklist);
onLoad(options) {
let obj = JSON.parse(options.cookbookObj);
console.log('options', {...obj});
this.setData({
sellerName: obj.sellerName,
sellerid: obj.sellerid,
rid: obj.rid,
oid: obj.oid,
sellerDate: obj.sellerDate,
region: obj.region,
tableNum: obj.tableNum,
soltName: obj.soltName
options: obj,
})
this.setData({
options: obj,
})
this.getCheckCookList(obj);
},
formatCookList(cookbooklist) {
// 获取点菜列表
getCheckCookList(obj) {
let param = {
sellerid: obj.sid,
identity: obj.identity,
orderid: obj.oid,
status: '0,1',
};
let probablyPrice = 0;
let vipProbablyPrice = 0;
let noData = false;
cookbooklist.forEach(items => {
items.is_show = false
items.normsLen = 0
items.cookbooklist[0].forEach(item => {
if (item.norms && item.norms.length > 0) {
item.norms.forEach(i => {
let price = i.quantum * 1 * (i.price * 1);
let vipPrice = i.quantum * 1 * (i.member_price * 1);
probablyPrice += price;
vipProbablyPrice += vipPrice;
App.Cookbook.GetCookbookByClass(param).then(json => {
let cookbooklist = this.formatCookList(json.data[0].list)
let newArr = JSON.parse(JSON.stringify(cookbooklist))
let num = 0
for (let i = 0; i < newArr.length; i++) {
if (newArr[i].cookbooklist.length == 0) {
continue;
}
for (let j = 0; j < newArr[i].cookbooklist[0].length; j++) {
let cook_style = newArr[i].cookbooklist[0][j].cook_style
if (cook_style.image_type == 2) {
num++
} else {
if (num % 2 != 0) {
let k = cookbooklist[i].cookbooklist[0].findIndex((item) => {
return newArr[i].cookbooklist[0][j].id == item.id
})
if (k != -1) {
let temp = {
boderNone: true,
image_type: '2',
}
cookbooklist[i].cookbooklist[0].splice(k, 0, temp)
}
}
num = 0
}
}
}
cookbooklist.forEach(item => {
item.normsLen = 0
item.cookbooklist[0].forEach((cooks, idx) => {
if (cooks.order_xx && cooks.order_xx.length > 0) {
let arr = cooks.order_xx
let result = arr.reduce((obj, item) => {
let find = obj.find(i => (i.practiceid === item.practiceid && i.specid === item.specid));
let _d = {
...item,
count: 1
};
find ? find.count++ : obj.push(_d);
return obj;
}, []);
cooks.norms = result
cooks.norms.forEach(n => {
let obj = cooks.specArr.filter(i => {
return i.id == n.specid
})
n.price = (obj[0] && obj[0].price) ? obj[0].price : cooks.price;
n.member_price = (obj[0] && obj[0].member_price) ? obj[0].member_price : cooks.member_price;
n.id = cooks.id;
n.check2 = cooks.check2;
n.cookName = cooks.name;
n.check1 = cooks.check1;
let price = n.count * 1 * (n.price * 1);
let vipPrice = n.count * 1 * (n.member_price * 1);
probablyPrice += price;
vipProbablyPrice += vipPrice;
})
item.is_show = true
item.normsLen += cooks.norms.length
} else {
cooks.norms = []
}
})
})
this.setData({
cookbooklist,
noData: true,
probablyPrice,
vipProbablyPrice
})
})
},
// 过滤数据
formatCookList(list) {
// 获取所有的规格
list.forEach(item => {
item.cookbooklist[0].forEach((i, idx) => {
i.specArr = []
let obj = {}
if (i.spec && i.spec.length > 0) {
i.spec.forEach(single => {
if (single.status == '1') {
obj = {
cid: single.cid,
clear_num: single.clear_num,
id: single.id,
member_price: single.member_price,
price: single.price,
specid: single.specid,
specs: single.specs,
status: single.status,
str: '¥' + single.price + '/' + single.specs,
member_str: single.member_price ? '会员 ¥' + single.member_price + '/' + single.specs : '',
}
i.specArr.push(obj)
}
})
noData = true
items.is_show = true; //展示不展示
items.normsLen += item.norms.length; //菜品数量
}
})
})
// 排序
let sortArr = []
list.forEach(item => {
item.cookbooklist[0].sort((a, b) => {
return a.order_o - b.order_o
})
sortArr.push(item)
})
//原栏目下显示
let hasShowClass = false;
//菜单中展示沽清的菜品
let hasClearCookbook = false;
//十道必选菜
let has10CaiOpen = false;
let flist = [];
let assortArr = [];
let check1 = '';
let check2 = '';
let that = this;
let complete = false
let complete1 = false
if (sortArr.length > 0) {
has10CaiOpen = list[0].status == 1;
sortArr.forEach(function (cate, i) {
let num = 0;
let obj = {
class_name: cate.class_name,
class_type: cate.class_type,
id: cate.id,
order: cate.order,
status: cate.status,
}
if (cate.status == 1 && cate.cookbooklist[0].length > 0) {
assortArr.push(obj)
let cooks = [];
cate.cookbooklist[0].forEach(function (cook, n) {
if (cook.status == 1) {
let flag = true;
if (has10CaiOpen) {
if (cate.class_type == 2 && !hasShowClass && flist.length > 0 && flist[0].class_type == 1) {
for (let fi = 0; fi < flist[0].cookbooklist[0].length; fi++) {
if (flist[0].cookbooklist[0][fi].id == cook.id) {
flag = false;
break;
}
}
}
}
cook.item_clear_num = cook.clear_num;
if (!hasClearCookbook) { //不显示卖光了
let item_clear_num = cook.clear_num;
if (cook.specArr) {
let clear_num = null;
cook.specArr.forEach(spec => {
if (spec.clear_num == 0) {
clear_num = 0;
} else {
clear_num = null;
}
})
if (clear_num == 0) {
item_clear_num = 0;
}
}
cook.item_clear_num = item_clear_num;
cook.index = n; //分类下菜品的下标
if (!cook.order_xx || cook.order_xx.length == 0) {
cook.norms = []; //做法规格
}
cook.type = '1';
let cook_style = cook.cook_style ? util.determine(cook.cook_style) : {
image_type: '1',
name_type: ''
}; //判断是不是json,是json在转换为对象
cook.cook_style = cook_style;
cook.image_type = cook_style && cook_style.image_type ? cook_style.image_type : '1'; //1大图,2小图 默认大图
cook.name_type = cook_style && cook_style.name_type ? cook_style.name_type : '3'; //1左侧,2右侧,3顶部分开 默认分开
cook.check1 = cook.practice.length > 0 ? cook.practice[0].id : '';
cook.check2 = cook.specArr.length > 0 ? cook.specArr[0].id : '';
cook.price = cook.specArr.length > 0 ? cook.specArr[0].price : '';
cook.member_price = cook.specArr.length > 0 ? cook.specArr[0].member_price : '';
if (item_clear_num == 0) {
flag = false;
}
}
if (flag) {
cooks.push(cook);
}
}
})
if (cooks.length > 0) {
cate.cookbooklist[0] = cooks;
flist.push(cate)
}
}
})
}
this.setData({
cookbooklist,
probablyPrice,
vipProbablyPrice,
noData
check1,
check2,
assortArr
})
return flist;
},
// 继续点菜
continueOrdering() {
... ... @@ -71,39 +261,41 @@ Page({
// 确认下单
determineFun() {
if (this.data.noData) {
let data = {
sellerName: this.data.sellerName,
sellerid: this.data.sellerid,
notes: this.data.notes,
rid: this.data.rid,
oid: this.data.oid,
sellerDate: this.data.sellerDate,
region: this.data.region,
tableNum: this.data.tableNum,
soltName: this.data.soltName
let cookbookObj = {
...this.data.options
}
wx.setStorageSync('cookbookObj', JSON.stringify(data))
wx.navigateTo({
url: '/pack-cookbook/pages/success_new',
url: `/pack-cookbook/pages/success_new?cookbookObj=${JSON.stringify(cookbookObj)}`,
})
}
},
// 点加减
countFun(e) {
const index = e.currentTarget.dataset['index']; //菜下标
const indexs = e.currentTarget.dataset['indexs']; //分类下标
const idx = e.currentTarget.dataset['idx']; //菜品点菜的数组下标
const type = e.currentTarget.dataset['type'];
let normsNum;
if (type == '1') normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[idx].quantum * 1 + 1;
if (type == '0') normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[idx].quantum * 1 - 1;
if (normsNum == 0) {
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.splice(idx, 1)
} else {
this.data.cookbooklist[indexs].cookbooklist[0][index].norms[idx].quantum = normsNum;
const item = e.currentTarget.dataset['item'];
let params = {
orderid: this.data.options.oid * 1,
cookbookid: item.id,
source: type,
openid: getApp().openid,
specid: item.specid,
practiceid: item.practiceid,
request_uri: this.data.request_uri == true ? 1 : '', //服务员通过消息通知进来 又加菜的标识
fromSoucre: this.data.fromSoucre ? this.data.fromSoucre : '',
identity: this.data.options.identity
}
if(type=='1'){
App.Advance.AddCart(params).then(res => {
this.getCheckCookList(this.data.options);
})
return
}
if(type=='2'){
App.Advance.ReduceOrder(params).then(res => {
this.getCheckCookList(this.data.options);
})
return
}
wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist))
this.formatCookList(this.data.cookbooklist)
},
/**
* 生命周期函数--监听页面初次渲染完成
... ...
<!--pack-cookbook/pages/cart_new.wxml-->
<nav backgroundColor="#4d4e50" color="#fff">{{sellerName||'提交订单'}}</nav>
<nav backgroundColor="#4d4e50" color="#fff">{{options.sellerName||'提交订单'}}</nav>
<scroll-view class="main">
<view class="info flex-lr">
<view class="texts font28r">就餐时间:</view>
<view class="texts_right font28r">{{sellerDate}} {{soltName}}</view>
<view class="texts_right font28r">{{options.sellerDate}} {{options.soltName}}</view>
</view>
<view class="info flex-lr">
<view class="texts font28r">桌位台号:</view>
<view class="texts_right font28r">{{region}}</view>
<view class="texts_right font28r">{{options.region}}</view>
</view>
<view class="info flex-lr">
<view class="texts font28r">就餐人数:</view>
<view class="texts font28r">{{tableNum}}</view>
<view class="texts font28r">{{options.tableNum}}</view>
</view>
<view class="info flex-lr">
<view class="texts font28r">备注信息:</view>
... ... @@ -27,12 +27,12 @@
<block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index">
<block wx:if="{{item.norms.length>0}}">
<view wx:for="{{item.norms}}" wx:for-index="idx" class="content flex-lr">
<view class="single">{{item.name}}<text wx:if="{{item.practiceName}}">({{item.practiceName}})</text></view>
<view class="price">{{item.price}}元/{{item.unitName}}</view>
<view class="single">{{item.cookName}}<text wx:if="{{item.name}}">({{item.name}})</text></view>
<view class="price">{{item.price}}元{{item.specs?'/'+item.specs:''}}</view>
<view class="count flex-cc">
<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="" />
{{item.quantum}}
<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="" />
<image bindtap="countFun" data-type="2" data-item="{{item}}" src="https://qn.colorcun.com/WechatIMG809.png" class="img1" mode="" />
{{item.count}}
<image bindtap="countFun" data-type="1" data-item="{{item}}" src="https://qn.colorcun.com/WechatIMG810.png" class="img2" mode="" />
</view>
</view>
</block>
... ...
... ... @@ -14,10 +14,8 @@ Page({
options: {},
check1: '', //做法
check2: '', //规格
check1Name: '',
check2Name: '',
price:'',
member_price:'',
price: '',
member_price: '',
isloading: true,
toView: "inToView27",
hasEnter: false,
... ... @@ -29,28 +27,30 @@ Page({
cookbooklist: [],
checkItem: {},
showSkeleton: true,
request_uri: false,
fromSoucre: 0,
order: {},
orderItemCount: 0,
checkObj: '',
normsIndex: '',
assortArr: [],
checkCookbooklist: [],
themeColor: '',
textColor: '',
navColor: '',
},
checkModal: '',
classifyModal: '',
normsLen: '',
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log('options', {...options});
console.log('options', {
...options
});
this.setData({
options: options,
})
this.getCookList();
this.initOrder();
this.getCookList()
mta.Page.init({
"appID": "500667280",
"eventID": "500667287",
... ... @@ -64,21 +64,12 @@ Page({
},
// 已选菜单页面跳转
gotoShoppingCart() {
let cookbooklist = this.data.cookbooklist;
let obj = {
sellerName: this.data.options.sellerName,
sellerid: this.data.options.sid,
rid: this.data.options.rid,
oid: this.data.options.oid,
sellerDate: this.data.options.sellerDate,
region: this.data.options.region,
tableNum: this.data.options.tableNum,
soltName: this.data.options.soltName,
let cookbookObj = {
...this.data.options
}
wx.setStorageSync('cookbooklist', JSON.stringify(cookbooklist))
wx.setStorageSync('cookbookObj', JSON.stringify(obj))
wx.setStorageSync('cookbookObj',JSON.stringify(cookbookObj));
wx.navigateTo({
url: '/pack-cookbook/pages/cart_new',
url: `/pack-cookbook/pages/cart_new?cookbookObj=${JSON.stringify(cookbookObj)}`,
})
},
// 选择做法
... ... @@ -105,19 +96,76 @@ Page({
checkItem,
})
},
// 获取点菜数量
getNormsLen() {
let cookbooklist = this.data.cookbooklist;
let normsLen = 0;
cookbooklist.forEach(items => {
items.cookbooklist[0].forEach(item => {
if (item.norms && item.norms.length > 0) {
normsLen += item.norms.length
// 获取点菜列表
getCheckCookList() {
let param = {
sellerid: this.data.options.sid,
identity: this.data.options.identity,
orderid: this.data.options.oid,
status: '0,1',
};
App.Cookbook.GetCookbookByClass(param).then(json => {
let cookbooklist = this.formatCookList(json.data[0].list)
let newArr = JSON.parse(JSON.stringify(cookbooklist))
let num = 0
for (let i = 0; i < newArr.length; i++) {
if (newArr[i].cookbooklist.length == 0) {
continue;
}
for (let j = 0; j < newArr[i].cookbooklist[0].length; j++) {
let cook_style = newArr[i].cookbooklist[0][j].cook_style
if (cook_style.image_type == 2) {
num++
} else {
if (num % 2 != 0) {
let k = cookbooklist[i].cookbooklist[0].findIndex((item) => {
return newArr[i].cookbooklist[0][j].id == item.id
})
if (k != -1) {
let temp = {
boderNone: true,
image_type: '2',
}
cookbooklist[i].cookbooklist[0].splice(k, 0, temp)
}
}
num = 0
}
}
}
cookbooklist.forEach(item => {
item.cookbooklist[0].forEach((cooks, idx) => {
if (cooks.order_xx && cooks.order_xx.length > 0) {
let arr = cooks.order_xx;
let result = arr.reduce((obj, item) => {
let find = obj.find(i => (i.practiceid === item.practiceid && i.specid === item.specid));
let _d = {
...item,
count: 1
};
find ? find.count++ : obj.push(_d);
return obj;
}, []);
cooks.norms = result
cooks.norms.forEach(n => {
n.id = cooks.id;
n.check2 = cooks.check2;
n.cookName = cooks.name;
n.check1 = cooks.check1;
let obj = cooks.specArr.filter(i => {
return i.id == n.specid
})
n.price = (obj[0] && obj[0].price) ? obj[0].price : cooks.price;
n.member_price = (obj[0] && obj[0].member_price) ? obj[0].member_price : cooks.member_price;
})
} else {
cooks.norms = []
}
})
})
this.setData({
cookbooklist
})
})
this.setData({
normsLen
})
},
// 选择菜品分类
... ... @@ -133,37 +181,26 @@ Page({
determineFun() {
let index = this.data.checkObj.index;
let indexs = this.data.checkObj.indexs;
let data = this.data.cookbooklist[indexs].cookbooklist[0][index]
let isAlike = false;
data.norms.forEach(item => {
if (this.data.check1 == item.practice && this.data.check2 == item.unit) {
isAlike = true
item.quantum = item.quantum * 1 + 1
}
})
if (isAlike) {
this.setData({
cookbooklist: this.data.cookbooklist,
})
} else {
let obj = {
quantum: 1,
name: data.name,
practice: this.data.check1 ? this.data.check1 : data.check1,
unit: this.data.check2 ? this.data.check2 : data.check2,
practiceName: this.data.check1Name ? this.data.check1Name : data.check1Name,
unitName: this.data.check2Name ? this.data.check2Name : data.check2Name,
price: this.data.price ? this.data.price : data.price,
member_price: this.data.member_price ? this.data.member_price : data.member_price,
}
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
let item = this.data.cookbooklist[indexs].cookbooklist[0][index]
let params = {
orderid: this.data.options.oid * 1,
cookbookid: item.id,
source: 1,
openid: getApp().openid,
specid: this.data.check2 ? this.data.check2 : item.check2,
practiceid: this.data.check1 ? this.data.check1 : item.check1,
request_uri: this.data.request_uri == true ? 1 : '', //服务员通过消息通知进来 又加菜的标识
fromSoucre: this.data.fromSoucre ? this.data.fromSoucre : '',
identity: this.data.options.identity
}
App.Advance.AddCart(params).then(res => {
this.closeModal()
this.getCheckCookList();
let orderItemCount = this.data.orderItemCount * 1 + 1
this.setData({
cookbooklist: this.data.cookbooklist,
orderItemCount
})
}
this.closeModal()
this.getNormsLen()
})
},
// 点击加号
addition(e) {
... ... @@ -171,7 +208,6 @@ Page({
const index = e.currentTarget.dataset['key']; //菜下标
const indexs = e.currentTarget.dataset['indexs']; //分类下标
const type = e.currentTarget.dataset['type']; //1 弹框 0不选规格型号
const normsIndex = e.currentTarget.dataset['norms']; //菜品点菜的数组下标
this.setData({
checkObj: {
indexs,
... ... @@ -179,65 +215,65 @@ Page({
price: this.data.price ? this.data.price : '',
member_price: this.data.member_price ? this.data.member_price : '',
},
normsIndex,
checkItem: item
})
let norms = this.data.cookbooklist[indexs].cookbooklist[0][index].norms
let normsNum;
// 点击下面的加号并且有规格或者做法的,弹框选规格 下面的直接加
// 点击下面的加号并且有规格或者做法的,弹框选规格
if (type == '1' && (item.practice.length > 1 || item.specArr.length > 1)) {
this.setData({
check1: item.practice[0].id,
check2: item.specArr[0].id,
check1Name: item.practice[0].name,
check2Name: item.specArr[0].spec,
price: item.specArr[0].price,
member_price: item.specArr[0].member_price,
})
return this.showCheckModal()
} else {
normsNum = 1;
let obj = {
quantum: normsNum,
practice: item.check1Name,
unit: item.unit,
practiceName: item.check1Name,
unitName: item.check2Name,
name: item.name,
price: this.data.price ? this.data.price :item.price,
member_price: this.data.member_price ? this.data.member_price : item.member_price,
}
if (!normsIndex && norms.length == '0') {
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
}
}
if (type == '0' && norms.length != '0') {
normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 + 1;
this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum;
//点击下面的加号,并且没有规格和做法没有多选
let practiceid, specid;
if (type == '0') {
practiceid = item.practiceid;
specid = item.specid;
} else {
normsNum = 1
practiceid = this.data.check1 ? this.data.check1 : item.check1;
specid = this.data.check2 ? this.data.check2 : item.check2;
}
this.setData({
cookbooklist: this.data.cookbooklist,
let params = {
orderid: this.data.options.oid * 1,
cookbookid: item.id,
source: 1,
openid: getApp().openid,
specid,
practiceid,
request_uri: this.data.request_uri == true ? 1 : '', //服务员通过消息通知进来 又加菜的标识
fromSoucre: this.data.fromSoucre ? this.data.fromSoucre : '',
identity: this.data.options.identity
}
App.Advance.AddCart(params).then(res => {
this.getCheckCookList();
let orderItemCount = this.data.orderItemCount * 1 + 1
this.setData({
orderItemCount
})
})
this.getNormsLen()
},
// 点击减号
subtraction(e) {
const index = e.currentTarget.dataset['key']; //菜下标
const indexs = e.currentTarget.dataset['indexs']; //分类下标
const normsIndex = e.currentTarget.dataset['norms']; //菜品点菜的数组下标
let normsNum;
normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 - 1;
if (normsNum == 0) {
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.splice(normsIndex, 1)
} else {
this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum = normsNum;
const item = e.currentTarget.dataset['item']; //菜下标
let params = {
orderid: this.data.options.oid * 1,
cookbookid: item.id,
source: 2,
openid: getApp().openid,
specid: item.specid,
practiceid: item.practiceid,
request_uri: this.data.request_uri == true ? 1 : '', //服务员通过消息通知进来 又加菜的标识
fromSoucre: this.data.fromSoucre ? this.data.fromSoucre : '',
identity: this.data.options.identity
}
this.setData({
cookbooklist: this.data.cookbooklist,
App.Advance.ReduceOrder(params).then(res => {
this.getCheckCookList();
let orderItemCount = this.data.orderItemCount * 1 - 1
this.setData({
orderItemCount
})
})
this.getNormsLen()
},
// 扫桌码点餐
initOrder() {
... ... @@ -250,23 +286,24 @@ Page({
let orderItemCount = 0;
res.data.cookbooklist.forEach(cb => {
if (this.data.options.identity == 1 && cb.status > 0) {
let cookbookObj = {
...this.data.options
}
wx.redirectTo({
url: util.http_build_query({
rid: this.data.options.rid,
oid: res.data.id,
identity: 1,
sellerid: this.data.options.sid,
}, '/pack-cookbook/pages/success')
});
url: `/pack-cookbook/pages/success_new?cookbookObj=${JSON.stringify(cookbookObj)}`,
})
return false;
}
orderItemCount += parseInt(cb.num)
})
this.setData({
[`options.oid`]: res.data.id,
[`options.sellerName`]: res.data.seller.sellername,
order: res.data,
orderItemCount: orderItemCount,
checkCookbooklist: res.data.cookbooklist,
})
this.getCheckCookList();
})
},
// 过滤数据
... ... @@ -280,14 +317,14 @@ Page({
i.spec.forEach(single => {
if (single.status == '1') {
obj = {
cid:single.cid,
clear_num:single.clear_num,
id:single.id,
member_price:single.member_price,
price:single.price,
specid:single.specid,
specs:single.specs,
status:single.status,
cid: single.cid,
clear_num: single.clear_num,
id: single.id,
member_price: single.member_price,
price: single.price,
specid: single.specid,
specs: single.specs,
status: single.status,
str: '¥' + single.price + '/' + single.specs,
member_str: single.member_price ? '会员 ¥' + single.member_price + '/' + single.specs : '',
}
... ... @@ -297,6 +334,14 @@ Page({
}
})
})
// 排序
let sortArr = []
list.forEach(item => {
item.cookbooklist[0].sort((a, b) => {
return a.order_o - b.order_o
})
sortArr.push(item)
})
//原栏目下显示
let hasShowClass = false;
//菜单中展示沽清的菜品
... ... @@ -308,9 +353,12 @@ Page({
let check1 = '';
let check2 = '';
let that = this;
if (list.length > 0) {
let complete = false
let complete1 = false
if (sortArr.length > 0) {
has10CaiOpen = list[0].status == 1;
list.forEach(function (cate, i) {
sortArr.forEach(function (cate, i) {
let num = 0;
let obj = {
class_name: cate.class_name,
class_type: cate.class_type,
... ... @@ -321,7 +369,6 @@ Page({
if (cate.status == 1 && cate.cookbooklist[0].length > 0) {
assortArr.push(obj)
let cooks = [];
//let cooks_order=[];
cate.cookbooklist[0].forEach(function (cook, n) {
if (cook.status == 1) {
let flag = true;
... ... @@ -353,18 +400,19 @@ Page({
}
cook.item_clear_num = item_clear_num;
cook.index = n; //分类下菜品的下标
if (!cook.norms || cook.norms.length == 0) {
if (!cook.order_xx || cook.order_xx.length == 0) {
cook.norms = []; //做法规格
}
cook.type = '1';
let cook_style = cook.cook_style ? util.determine(cook.cook_style) : ''; //判断是不是json,是json在转换为对象
let cook_style = cook.cook_style ? util.determine(cook.cook_style) : {
image_type: '1',
name_type: ''
}; //判断是不是json,是json在转换为对象
cook.cook_style = cook_style;
cook.image_type = cook_style && cook_style.image_type ? cook_style.image_type : '1'; //1大图,2小图 默认大图
cook.name_type = cook_style && cook_style.name_type ? cook_style.name_type : '3'; //1左侧,2右侧,3顶部分开 默认分开
cook.check1 = cook.practice.length > 0 ? cook.practice[0].id : '';
cook.check2 = cook.specArr.length > 0 ? cook.specArr[0].id : '';
cook.check1Name = cook.practice.length > 0 ? cook.practice[0].name : '';
cook.check2Name = cook.specArr.length > 0 ? cook.specArr[0].specs : '';
cook.price = cook.specArr.length > 0 ? cook.specArr[0].price : '';
cook.member_price = cook.specArr.length > 0 ? cook.specArr[0].member_price : '';
if (item_clear_num == 0) {
... ... @@ -373,102 +421,70 @@ Page({
}
if (flag) {
cooks.push(cook);
//cooks_order.push(cook.order_o);
}
}
})
if (cooks.length > 0) {
//cooks 排序...
cate.cookbooklist[0] = cooks;
flist.push(cate)
}
}
})
}
// 排序
let sortArr = []
flist.forEach(item => {
item.cookbooklist[0].sort((a, b) => {
return a.order_o - b.order_o
})
sortArr.push(item)
this.setData({
check1,
check2,
assortArr
})
return flist;
let image_typeArr = [];
// 大小图设置边框
sortArr.forEach(item => {
let num = 0;
item.cookbooklist[0].forEach((i, idx) => {
if (i.image_type == '1') {
i.index = 0
num = 0
},
// 获取所有分类下所有菜品列表
getCookList() {
let param = {
sellerid: this.data.options.sid,
identity: this.data.options.identity,
orderid: this.data.options.oid,
status: '0,1',
};
App.Cookbook.GetCookbookByClass(param).then(json => {
let cookbooklist = this.formatCookList(json.data[0].list)
let newArr = JSON.parse(JSON.stringify(cookbooklist))
let num = 0
for (let i = 0; i < newArr.length; i++) {
if (newArr[i].cookbooklist.length == 0) {
continue;
}
if (i.image_type == '2') {
num++
i.index = num;
if (i.index % 2 != 0) {
i.boderNone = false;
for (let j = 0; j < newArr[i].cookbooklist[0].length; j++) {
let cook_style = newArr[i].cookbooklist[0][j].cook_style
if (cook_style.image_type == 2) {
num++
} else {
i.boderNone = true;
}
// 下一个是大图 不是最后一个
if (item.cookbooklist[0][idx + 1].image_type == '1' && idx != item.cookbooklist[0].length - 1) {
// 是奇数
if (num % 2 != 0) {
let s = i.index * 1 + 1;
item.cookbooklist[0].splice(idx + 1, 0, {
index: s,
boderNone: true,
image_type: '2',
let k = cookbooklist[i].cookbooklist[0].findIndex((item) => {
return newArr[i].cookbooklist[0][j].id == item.id
})
if (k != -1) {
let temp = {
boderNone: true,
image_type: '2',
}
cookbooklist[i].cookbooklist[0].splice(k, 0, temp)
}
}
num = 0
}
}
})
image_typeArr.push(item)
})
setTimeout(() => {
this.setData({
check1,
check2,
assortArr
})
}, 1);
return image_typeArr;
},
// 获取所有分类下所有菜品列表
getCookList() {
let cookbooklist = wx.getStorageSync('cookbooklist');
let cookbooklistStorage = cookbooklist ? JSON.parse(cookbooklist) : '';
console.log('cookbooklist历史数据', cookbooklistStorage);
if (cookbooklistStorage.length > 0) {
}
this.setData({
cookbooklist: this.formatCookList(cookbooklistStorage),
cookbooklist,
isloading: false,
showSkeleton: false,
})
} else {
let param = {
sellerid: this.data.options.sid,
identity: this.data.options.identity,
orderid: this.data.options.oid,
status: '0,1',
};
App.Cookbook.GetCookbookByClass(param).then(json => {
let cookbooklist = this.formatCookList(json.data[0].list)
console.log('cookbooklist', cookbooklist);
setTimeout(() => {
this.setData({
cookbooklist,
isloading: false,
showSkeleton: false,
})
}, 1)
}).catch(res => {
console.log(res);
});
}
this.getCheckCookList()
}).catch(res => {
console.log(res);
});
this.GetDzSellerConfFun()
},
// 获取主题色
... ... @@ -509,20 +525,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
let cookbooklist = wx.getStorageSync('cookbooklist')
let cookbooklistStorage = cookbooklist ? JSON.parse(cookbooklist) : ''
console.log('cookbooklist历史数据', cookbooklistStorage);
if (cookbooklistStorage) {
this.setData({
cookbooklist: cookbooklistStorage,
isloading: false,
showSkeleton: false,
})
this.getNormsLen()
} else {
this.getCookList()
this.getNormsLen()
}
this.initOrder()
},
// 展示做法规格弹窗
showCheckModal() {
... ... @@ -565,6 +568,9 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage() {
return {
title: '一起来点菜啦!',
imageUrl: 'http://nosqn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20191115114857.jpg',
}
}
})
\ No newline at end of file
... ...
... ... @@ -19,7 +19,7 @@
</block>
<block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index">
<!-- name_type 1左侧,2右侧,3顶部分开 image_type 1大图,2小图 -->
<view wx:if="{{item.image_type=='1'}}" class="oneBox" data-idx="{{item.index}}" data-nameType="{{item.name_type}}">
<view wx:if="{{item.image_type=='1'}}" class="oneBox" data-idx="{{item.image_type}}" data-nameType="{{item.name_type}}">
<block wx:if="{{item.name_type!='3'}}">
<view class="dishItem {{item.name_type=='2'?'typeB':''}}">
<view class="dishLeft dishTexts" style="color:rgba({{textColor}})">
... ... @@ -31,7 +31,7 @@
</view>
</view>
<view wx:if="{{item.specArr.length>0}}" class="norms {{item.name_type=='2'?'normsB':''}}" style="color:rgba({{navColor}})">
<view wx:for="{{item.specArr}}">
<view wx:for="{{item.specArr}}" wx:key="{{item.id}}">
{{item.str}}
{{item.member_str}}
</view>
... ... @@ -47,7 +47,7 @@
{{item.name}}
</view>
<view wx:if="{{item.specArr.length>0}}" style="color:rgba({{textColor}})" class="norms {{item.name_type=='2'?'normsB':''}}" style="color:rgba({{navColor}})">
<view wx:for="{{item.specArr}}">
<view wx:for="{{item.specArr}}" wx:key="{{item.id}}">
{{item.str}}
{{item.member_str}}
</view>
... ... @@ -66,21 +66,21 @@
<view class="greens" wx:if="{{item.desc}}">
<view class="news" style="color:rgba({{textColor}})">{{item.desc}}</view>
</view>
<view wx:for="{{item.norms}}" wx:for-index="normsIndex" class="algorithmImg flex-lr calculate">
<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}}" />
<view wx:for="{{item.norms}}" wx:key="{{item.id}}" wx:for-index="normsIndex" class="algorithmImg flex-lr calculate">
<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}}"/>
<view class="box flex-cc">
<view class="num flex-cc">
{{item.quantum}}<view style="color:rgba({{textColor}})">{{item.unitName}}</view>
{{item.count}}<view wx:if="{{item.name}}" style="color:rgba({{textColor}})">{{item.name}}</view>
</view>
<view class="practice" style="color:rgba({{textColor}})">{{item.practiceName}}</view>
<view class="practice" wx:if="{{item.specs}}" style="color:rgba({{textColor}})">{{item.specs}}</view>
</view>
<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}}" />
<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}}"/>
</view>
<view wx:if="{{(item.specArr.length>1 || item.practice.length>1) || item.norms.length=='0'}}" class="algorithmImg flex-rr imgbox">
<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}}" />
<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}}"/>
</view>
</view>
<view wx:else class="twoBox" data-idx="{{item.index}}" data-nameType="{{item.name_type}}">
<view wx:else class="twoBox" data-idx="{{item.image_type}}" data-nameType="{{item.name_type}}">
<view class="{{item.boderNone?'borderNone twoItem':'twoItem'}}">
<view class="twoTitle" style="color:rgba({{textColor}})">{{item.name}}</view>
<view class="twoInfo dishTexts" wx:if="{{item.taste}}">
... ... @@ -88,7 +88,7 @@
<text wx:if="{{item.cooks}}">烹调:{{item.cooks}}</text>
</view>
<view wx:if="{{item.specArr.length>0}}" class="twoInfo twoSingle" style="color:rgba({{textColor}})">
<view wx:for="{{item.specArr}}">
<view wx:for="{{item.specArr}}" wx:key="{{item.id}}">
{{item.str}}
{{item.member_str}}
</view>
... ... @@ -101,18 +101,18 @@
<view class="greens" wx:if="{{item.desc}}">
<view class="news" style="color:rgba({{textColor}})">{{item.desc}}</view>
</view>
<view wx:for="{{item.norms}}" wx:for-index="normsIndex" class="algorithmImg flex-lr calculate">
<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}}" />
<view wx:for="{{item.norms}}" wx:key="{{item.unit}}" wx:for-index="normsIndex" class="algorithmImg flex-lr calculate">
<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}}" />
<view class="box flex-cc">
<view class="num flex-cc">
{{item.quantum}}<view style="color:rgba({{textColor}})">{{item.unitName}}</view>
{{item.count}}<view wx:if="{{item.name}}" style="color:rgba({{textColor}})">{{item.name}}</view>
</view>
<view class="practice" style="color:rgba({{textColor}})">{{item.practiceName}}</view>
<view class="practice" wx:if="{{item.specs}}" style="color:rgba({{textColor}})">{{item.specs}}</view>
</view>
<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}}" />
<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}}" />
</view>
<view wx:if="{{(item.spec.length>1 || item.practice.length>1) || item.norms.length=='0'}}" class="algorithmImg flex-rr imgbox">
<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}}" />
<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}}" />
</view>
</view>
</view>
... ... @@ -130,7 +130,7 @@
<view class="right flex-cmc" bindtap="gotoShoppingCart">
<view class="rightBox">
<image src="{{themeColor!='251,246,241,1'?'https://qn.colorcun.com/WechatIMG701.png':'https://qn.colorcun.com/s2.png'}}" mode="" />
<view class="num" wx:if="{{normsLen}}">{{normsLen}}</view>
<view class="num" wx:if="{{orderItemCount}}">{{orderItemCount}}</view>
</view>
<view class="fixedName" style="color:rgba({{textColor}})">
已选菜品
... ...
... ... @@ -154,7 +154,6 @@ page {
font-size: 32rpx;
margin: 0 20rpx;
}
.twoItem {
width: 100%;
box-sizing: border-box;
... ... @@ -437,4 +436,15 @@ page {
display: flex;
justify-content: center;
flex-direction: column;
}
.twoItem .num view{
font-size:24rpx;
margin: 0 10rpx;
}
.twoItem .practice{
font-size:24rpx;
}
.twoItem .box .num {
font-size: 60rpx;
}
\ No newline at end of file
... ...
... ... @@ -10,7 +10,7 @@ Page({
sellerName: '',
sellerid: '',
probablyPrice: '',
vipProbablyPrice:'',
vipProbablyPrice: '',
discount: '',
stringifyUse: '',
priceInfo: '',
... ... @@ -20,95 +20,264 @@ Page({
recharge_data: {},
coupon_data: {},
dataStr: Date.now() * 1 / 1000,
rid:'',
oid:'',
sellerDate:'',
region:'',
tableNum:'',
soltName:'',
rid: '',
oid: '',
sellerDate: '',
region: '',
tableNum: '',
soltName: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
let obj = JSON.parse(wx.getStorageSync('cookbookObj'));
let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist'));
this.formatCookList(cookbooklist);
onLoad(options) {
let obj = util.determine(options.cookbookObj);
console.log('options', {...obj});
this.setData({
sellerName: obj.sellerName,
sellerid: obj.sellerid,
notes: obj.notes,
rid:obj.rid,
oid:obj.oid,
sellerDate: obj.sellerDate,
region: obj.region,
tableNum: obj.tableNum,
soltName:obj.soltName
options: obj,
})
console.log('obj',obj);
this.getCheckCookList(obj);
this.getSellerTemplateConfFun()
},
formatCookList(cookbooklist){
let probablyPrice = 0;
let vipProbablyPrice = 0;
let noData = false;
cookbooklist.forEach(items => {
items.is_show = false
items.normsLen=0
items.cookbooklist[0].forEach(item => {
item.arr=[];//arr 点菜的菜品列表
if (item.norms && item.norms.length>0) {
item.norms.forEach(i => {
let obj={
name:item.name,
practice:i.practice,
unit:i.unit,
price:i.price,
quantum:i.quantum,
// 过滤数据
formatCookList(list) {
// 获取所有的规格
list.forEach(item => {
item.cookbooklist[0].forEach((i, idx) => {
i.specArr = []
let obj = {}
if (i.spec && i.spec.length > 0) {
i.spec.forEach(single => {
if (single.status == '1') {
obj = {
cid: single.cid,
clear_num: single.clear_num,
id: single.id,
member_price: single.member_price,
price: single.price,
specid: single.specid,
specs: single.specs,
status: single.status,
str: '¥' + single.price + '/' + single.specs,
member_str: single.member_price ? '会员 ¥' + single.member_price + '/' + single.specs : '',
}
i.specArr.push(obj)
}
item.arr.push(obj)
let price = i.quantum * 1 * (i.price * 1);
let vipPrice = i.quantum * 1 * (i.member_price * 1);
probablyPrice += price;
vipProbablyPrice += vipPrice;
})
noData = true
items.is_show = true;//展示不展示
items.normsLen+=item.arr.length;//菜品数量
}
})
})
// wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist))
// 排序
let sortArr = []
list.forEach(item => {
item.cookbooklist[0].sort((a, b) => {
return a.order_o - b.order_o
})
sortArr.push(item)
})
//原栏目下显示
let hasShowClass = false;
//菜单中展示沽清的菜品
let hasClearCookbook = false;
//十道必选菜
let has10CaiOpen = false;
let flist = [];
let assortArr = [];
let check1 = '';
let check2 = '';
let that = this;
let complete = false
let complete1 = false
if (sortArr.length > 0) {
has10CaiOpen = list[0].status == 1;
sortArr.forEach(function (cate, i) {
let num = 0;
let obj = {
class_name: cate.class_name,
class_type: cate.class_type,
id: cate.id,
order: cate.order,
status: cate.status,
}
if (cate.status == 1 && cate.cookbooklist[0].length > 0) {
assortArr.push(obj)
let cooks = [];
cate.cookbooklist[0].forEach(function (cook, n) {
if (cook.status == 1) {
let flag = true;
if (has10CaiOpen) {
if (cate.class_type == 2 && !hasShowClass && flist.length > 0 && flist[0].class_type == 1) {
for (let fi = 0; fi < flist[0].cookbooklist[0].length; fi++) {
if (flist[0].cookbooklist[0][fi].id == cook.id) {
flag = false;
break;
}
}
}
}
cook.item_clear_num = cook.clear_num;
if (!hasClearCookbook) { //不显示卖光了
let item_clear_num = cook.clear_num;
if (cook.specArr) {
let clear_num = null;
cook.specArr.forEach(spec => {
if (spec.clear_num == 0) {
clear_num = 0;
} else {
clear_num = null;
}
})
if (clear_num == 0) {
item_clear_num = 0;
}
}
cook.item_clear_num = item_clear_num;
cook.index = n; //分类下菜品的下标
if (!cook.order_xx || cook.order_xx.length == 0) {
cook.norms = []; //做法规格
}
cook.type = '1';
let cook_style = cook.cook_style ? util.determine(cook.cook_style) : {
image_type: '1',
name_type: ''
}; //判断是不是json,是json在转换为对象
cook.cook_style = cook_style;
cook.image_type = cook_style && cook_style.image_type ? cook_style.image_type : '1'; //1大图,2小图 默认大图
cook.name_type = cook_style && cook_style.name_type ? cook_style.name_type : '3'; //1左侧,2右侧,3顶部分开 默认分开
cook.check1 = cook.practice.length > 0 ? cook.practice[0].id : '';
cook.check2 = cook.specArr.length > 0 ? cook.specArr[0].id : '';
cook.price = cook.specArr.length > 0 ? cook.specArr[0].price : '';
cook.member_price = cook.specArr.length > 0 ? cook.specArr[0].member_price : '';
if (item_clear_num == 0) {
flag = false;
}
}
if (flag) {
cooks.push(cook);
}
}
})
if (cooks.length > 0) {
cate.cookbooklist[0] = cooks;
flist.push(cate)
}
}
})
}
this.setData({
cookbooklist,
probablyPrice,
vipProbablyPrice,
noData
check1,
check2,
assortArr
})
return flist;
},
// 获取点菜列表
getCheckCookList(obj) {
let param = {
sellerid: obj.sid,
identity: obj.identity,
orderid: obj.oid,
status: '0,1',
};
let probablyPrice = 0;
let vipProbablyPrice = 0;
App.Cookbook.GetCookbookByClass(param).then(json => {
let cookbooklist = this.formatCookList(json.data[0].list)
let newArr = JSON.parse(JSON.stringify(cookbooklist))
let num = 0
for (let i = 0; i < newArr.length; i++) {
if (newArr[i].cookbooklist.length == 0) {
continue;
}
for (let j = 0; j < newArr[i].cookbooklist[0].length; j++) {
let cook_style = newArr[i].cookbooklist[0][j].cook_style
if (cook_style.image_type == 2) {
num++
} else {
if (num % 2 != 0) {
let k = cookbooklist[i].cookbooklist[0].findIndex((item) => {
return newArr[i].cookbooklist[0][j].id == item.id
})
if (k != -1) {
let temp = {
boderNone: true,
image_type: '2',
}
cookbooklist[i].cookbooklist[0].splice(k, 0, temp)
}
}
num = 0
}
}
}
cookbooklist.forEach(item => {
item.normsLen = 0
item.cookbooklist[0].forEach((cooks, idx) => {
if (cooks.order_xx && cooks.order_xx.length > 0) {
let arr = cooks.order_xx
let result = arr.reduce((obj, item) => {
let find = obj.find(i => (i.practiceid === item.practiceid && i.specid === item.specid));
let _d = {
...item,
count: 1
};
find ? find.count++ : obj.push(_d);
return obj;
}, []);
cooks.norms = result
cooks.norms.forEach(n => {
let obj = cooks.specArr.filter(i => {
return i.id == n.specid
})
n.price = (obj[0] && obj[0].price) ? obj[0].price : cooks.price;
n.member_price = (obj[0] && obj[0].member_price) ? obj[0].member_price : cooks.member_price;
n.id = cooks.id;
n.check2 = cooks.check2;
n.cookName = cooks.name;
n.check1 = cooks.check1;
let price = n.count * 1 * (n.price * 1);
let vipPrice = n.count * 1 * (n.member_price * 1);
probablyPrice += price;
vipProbablyPrice += vipPrice;
})
item.is_show = true
item.normsLen += cooks.norms.length
} else {
cooks.norms = []
}
})
})
this.setData({
cookbooklist,
noData: true,
probablyPrice,
vipProbablyPrice
})
})
},
// 菜品更换
continueOrdering(){
continueOrdering() {
console.log({...this.data.options});
wx.reLaunch({
url: `/pack-cookbook/pages/index_new?rid=${this.data.rid}&sid=${this.data.sellerid}&oid=${this.data.oid}&sellerName=${this.data.sellerName}&identity=1`,
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`,
})
},
// 点击了解更多会员优惠政策
gotoFavourableList(){
let url=util.http_build_query({
sellerName:this.data.sellerName,
sellerid:this.data.sellerid,
oid:this.data.oid,
types:'2',
},'/pack-cookbook/pages/favourableList')
console.log(url);
gotoFavourableList() {
let url = util.http_build_query({
sellerName: this.data.sellerName,
sellerid: this.data.sid,
oid: this.data.oid,
types: '2',
}, '/pack-cookbook/pages/favourableList')
wx.navigateTo({
url
url
})
},
getSellerTemplateConfFun(sid) {
console.log(sid, 'sidsidsidsid');
getSellerTemplateConfFun() {
App.Seller.GetSellerTemplateConf({
sid: this.data.sellerid
sid: this.data.sid
}).then(res => {
let data = res.data
let marketing, coupon_data, priceInfo, scoreInfo, recharge_list, stringifyUse;
... ... @@ -158,17 +327,17 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage() {
let options={
sid:this.data.sellerid,
rid:this.data.rid,
oid:this.data.oid,
identity:'1',
hasOnlyShow:'1'
let options = {
sid: this.data.sid,
rid: this.data.rid,
oid: this.data.oid,
identity: '1',
hasOnlyShow: '1'
};
return {
title:'菜品已点好,快来看看都点了什么~',
path:util.http_build_query(options,'/pack-cookbook/pages/success_new'),
imageUrl:'http://nosqn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148571.jpg',
title: '菜品已点好,快来看看都点了什么~',
path: util.http_build_query(options, '/pack-cookbook/pages/success_new'),
imageUrl: 'http://nosqn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148571.jpg',
}
},
/**
... ...
<!--pack-cookbook/pages/success_new.wxml-->
<nav backgroundColor="#4d4e50" color="#fff">{{sellerName||'提交订单'}}</nav>
<nav backgroundColor="#4d4e50" color="#fff">{{options.sellerName||'提交订单'}}</nav>
<scroll-view class="main">
<view class="box">
<view class="info flex-lr">
<view class="texts font28r">就餐时间:</view>
<view class="texts_right font28r">{{sellerDate}} {{soltName}}</view>
<view class="texts_right font28r">{{options.sellerDate}} {{soltName}}</view>
</view>
<view class="info flex-lr">
<view class="texts font28r">桌位台号:</view>
<view class="texts_right font28r">{{region}}</view>
<view class="texts_right font28r">{{options.region}}</view>
</view>
<view class="info flex-lr">
<view class="texts font28r">就餐人数:</view>
<view class="texts font28r">{{tableNum}}</view>
<view class="texts font28r">{{options.tableNum}}</view>
</view>
<view class="info flex-lr">
<view class="texts font28r">备注信息:</view>
<view class="texts font28r">{{notes}}</view>
<view class="texts font28r">{{options.notes}}</view>
</view>
<image class="imgs" src="https://qn.colorcun.com/001.png" mode="" />
</view>
... ... @@ -28,11 +28,11 @@
<view class="rightTitle">{{item.normsLen}}道</view>
</view>
<block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index">
<block wx:if="{{item.arr.length>0}}">
<view wx:for="{{item.arr}}" wx:for-index="idx" class="content flex-lr">
<view class="single">{{item.name}}<text>({{item.practice}})</text></view>
<view class="price">{{item.price}}元/{{item.unit}}</view>
{{item.quantum}}
<block wx:if="{{item.norms.length>0}}">
<view wx:for="{{item.norms}}" wx:for-index="idx" class="content flex-lr">
<view class="single">{{item.cookName}}<text wx:if="{{item.name}}">({{item.name}})</text></view>
<view class="price">{{item.price}}元{{item.specs?'/'+item.specs:''}}</view>
{{item.count}}
</view>
</block>
</block>
... ...
... ... @@ -208,7 +208,7 @@ Page({
rid: this.id,
oid: this.data.detail.order.id,
identity: 1
}, '/pack-cookbook/pages/success')
}, '/pack-cookbook/pages/success_new')
});
} else {
App.Advance.CreateOrder({
... ... @@ -230,7 +230,7 @@ Page({
soltName:this.data.seller.soltName,
region:this.data.seller.region+this.data.seller.room,
tableNum:this.data.detail.actual_pum?this.data.detail.actual_pum:this.data.tableNum
}, '/pack-cookbook/pages/index')
}, '/pack-cookbook/pages/index_new')
});
})
}
... ...