|
...
|
...
|
@@ -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 |
...
|
...
|
|