|
...
|
...
|
@@ -16,6 +16,8 @@ Page({ |
|
|
|
check2: '', //规格
|
|
|
|
check1Name: '',
|
|
|
|
check2Name: '',
|
|
|
|
price:'',
|
|
|
|
member_price:'',
|
|
|
|
isloading: true,
|
|
|
|
toView: "inToView27",
|
|
|
|
hasEnter: false,
|
|
...
|
...
|
@@ -32,9 +34,9 @@ Page({ |
|
|
|
checkObj: '',
|
|
|
|
normsIndex: '',
|
|
|
|
assortArr: [],
|
|
|
|
themeColor:'',
|
|
|
|
textColor:'',
|
|
|
|
navColor:'',
|
|
|
|
themeColor: '',
|
|
|
|
textColor: '',
|
|
|
|
navColor: '',
|
|
|
|
},
|
|
|
|
checkModal: '',
|
|
|
|
classifyModal: '',
|
|
...
|
...
|
@@ -43,7 +45,7 @@ Page({ |
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
console.log('options', options);
|
|
|
|
console.log('options', {...options});
|
|
|
|
this.setData({
|
|
|
|
options: options,
|
|
|
|
})
|
|
...
|
...
|
@@ -73,7 +75,6 @@ Page({ |
|
|
|
tableNum: this.data.options.tableNum,
|
|
|
|
soltName: this.data.options.soltName,
|
|
|
|
}
|
|
|
|
console.log('objobjobjobjobj', obj);
|
|
|
|
wx.setStorageSync('cookbooklist', JSON.stringify(cookbooklist))
|
|
|
|
wx.setStorageSync('cookbookObj', JSON.stringify(obj))
|
|
|
|
wx.navigateTo({
|
|
...
|
...
|
@@ -94,12 +95,14 @@ Page({ |
|
|
|
// 选择规格
|
|
|
|
checkSingle2(e) {
|
|
|
|
const item = e.currentTarget.dataset['item'];
|
|
|
|
let checkItem = this.data.checkItem
|
|
|
|
checkItem.check2 = item.id
|
|
|
|
let checkItem = this.data.checkItem;
|
|
|
|
checkItem.check2 = item.id;
|
|
|
|
this.setData({
|
|
|
|
check2: item.id,
|
|
|
|
check2Name: item.specs,
|
|
|
|
checkItem
|
|
|
|
price: item.price,
|
|
|
|
member_price: item.member_price,
|
|
|
|
checkItem,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取点菜数量
|
|
...
|
...
|
@@ -130,9 +133,9 @@ Page({ |
|
|
|
determineFun() {
|
|
|
|
let index = this.data.checkObj.index;
|
|
|
|
let indexs = this.data.checkObj.indexs;
|
|
|
|
let price = this.data.checkObj.price;
|
|
|
|
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
|
|
...
|
...
|
@@ -144,15 +147,15 @@ Page({ |
|
|
|
cookbooklist: this.data.cookbooklist,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
console.log({...data});
|
|
|
|
let obj = {
|
|
|
|
quantum: 1,
|
|
|
|
name:data.name,
|
|
|
|
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:price?price:''
|
|
|
|
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)
|
|
|
|
this.setData({
|
|
...
|
...
|
@@ -173,7 +176,8 @@ Page({ |
|
|
|
checkObj: {
|
|
|
|
indexs,
|
|
|
|
index,
|
|
|
|
price: item.price
|
|
|
|
price: this.data.price ? this.data.price : '',
|
|
|
|
member_price: this.data.member_price ? this.data.member_price : '',
|
|
|
|
},
|
|
|
|
normsIndex,
|
|
|
|
checkItem: item
|
|
...
|
...
|
@@ -181,14 +185,16 @@ Page({ |
|
|
|
let norms = this.data.cookbooklist[indexs].cookbooklist[0][index].norms
|
|
|
|
let normsNum;
|
|
|
|
// 点击下面的加号并且有规格或者做法的,弹框选规格 下面的直接加
|
|
|
|
if (type == '1' && (item.practice.length > 1 || item.spec.length > 1)) {
|
|
|
|
if (type == '1' && (item.practice.length > 1 || item.specArr.length > 1)) {
|
|
|
|
this.setData({
|
|
|
|
check1: item.practice[0].id,
|
|
|
|
check2: item.spec[0].id,
|
|
|
|
check1Name:item.practice[0].name,
|
|
|
|
check2Name:item.spec[0].spec,
|
|
|
|
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.showModal()
|
|
|
|
return this.showCheckModal()
|
|
|
|
} else {
|
|
|
|
normsNum = 1;
|
|
|
|
let obj = {
|
|
...
|
...
|
@@ -197,8 +203,9 @@ Page({ |
|
|
|
unit: item.unit,
|
|
|
|
practiceName: item.check1Name,
|
|
|
|
unitName: item.check2Name,
|
|
|
|
name:item.name,
|
|
|
|
price:item.price,
|
|
|
|
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)
|
|
...
|
...
|
@@ -264,6 +271,32 @@ Page({ |
|
|
|
},
|
|
|
|
// 过滤数据
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
//原栏目下显示
|
|
|
|
let hasShowClass = false;
|
|
|
|
//菜单中展示沽清的菜品
|
|
...
|
...
|
@@ -274,7 +307,7 @@ Page({ |
|
|
|
let assortArr = [];
|
|
|
|
let check1 = '';
|
|
|
|
let check2 = '';
|
|
|
|
let that=this;
|
|
|
|
let that = this;
|
|
|
|
if (list.length > 0) {
|
|
|
|
has10CaiOpen = list[0].status == 1;
|
|
|
|
list.forEach(function (cate, i) {
|
|
...
|
...
|
@@ -305,9 +338,9 @@ Page({ |
|
|
|
cook.item_clear_num = cook.clear_num;
|
|
|
|
if (!hasClearCookbook) { //不显示卖光了
|
|
|
|
let item_clear_num = cook.clear_num;
|
|
|
|
if (cook.spec) {
|
|
|
|
if (cook.specArr) {
|
|
|
|
let clear_num = null;
|
|
|
|
cook.spec.forEach(spec => {
|
|
|
|
cook.specArr.forEach(spec => {
|
|
|
|
if (spec.clear_num == 0) {
|
|
|
|
clear_num = 0;
|
|
|
|
} else {
|
|
...
|
...
|
@@ -324,14 +357,16 @@ Page({ |
|
|
|
cook.norms = []; //做法规格
|
|
|
|
}
|
|
|
|
cook.type = '1';
|
|
|
|
let cook_style = cook.cook_style?that.determine(cook.cook_style):'';//判断是不是json,是json在转换为对象
|
|
|
|
let cook_style = cook.cook_style ? util.determine(cook.cook_style) : ''; //判断是不是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.spec.length > 0 ? cook.spec[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.spec.length > 0 ? cook.spec[0].specs : '';
|
|
|
|
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) {
|
|
|
|
flag = false;
|
|
|
|
}
|
|
...
|
...
|
@@ -359,11 +394,16 @@ Page({ |
|
|
|
})
|
|
|
|
sortArr.push(item)
|
|
|
|
})
|
|
|
|
// 大小图设置边框
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
if (i.image_type == '2') {
|
|
|
|
num++
|
|
|
|
i.index = num;
|
|
...
|
...
|
@@ -379,35 +419,15 @@ Page({ |
|
|
|
let s = i.index * 1 + 1;
|
|
|
|
item.cookbooklist[0].splice(idx + 1, 0, {
|
|
|
|
index: s,
|
|
|
|
boderNone: true
|
|
|
|
boderNone: true,
|
|
|
|
image_type: '2',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (i.image_type == '1') {
|
|
|
|
i.index = 0
|
|
|
|
num = 0
|
|
|
|
}
|
|
|
|
})
|
|
|
|
image_typeArr.push(item)
|
|
|
|
})
|
|
|
|
// 获取所有的规格
|
|
|
|
image_typeArr.forEach(item => {
|
|
|
|
item.cookbooklist[0].forEach((i, idx) => {
|
|
|
|
i.specArr=[]
|
|
|
|
if(i.spec && i.spec.length>0){
|
|
|
|
i.spec.forEach(sigin=>{
|
|
|
|
if(sigin.status=='1'){
|
|
|
|
let obj={
|
|
|
|
str:'¥'+i.price+'/'+i.specs
|
|
|
|
}
|
|
|
|
i.specArr.push(sigin)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log(i.specArr);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
this.setData({
|
|
|
|
check1,
|
|
...
|
...
|
@@ -415,20 +435,8 @@ Page({ |
|
|
|
assortArr
|
|
|
|
})
|
|
|
|
}, 1);
|
|
|
|
console.log(image_typeArr);
|
|
|
|
return image_typeArr;
|
|
|
|
},
|
|
|
|
// 判断
|
|
|
|
determine(str) {
|
|
|
|
if (typeof str == 'string') {
|
|
|
|
try {
|
|
|
|
var obj = JSON.parse(str);
|
|
|
|
return obj;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 获取所有分类下所有菜品列表
|
|
|
|
getCookList() {
|
|
|
|
let cookbooklist = wx.getStorageSync('cookbooklist');
|
|
...
|
...
|
@@ -463,31 +471,38 @@ Page({ |
|
|
|
}
|
|
|
|
this.GetDzSellerConfFun()
|
|
|
|
},
|
|
|
|
// 获取主题色
|
|
|
|
GetDzSellerConfFun() {
|
|
|
|
App.Seller.GetDzSellerConf({
|
|
|
|
sid: this.data.options.sid
|
|
|
|
}).then(res => {
|
|
|
|
if(res.data.cook_style){
|
|
|
|
let style=this.determine(res.data.cook_style)
|
|
|
|
let themeColor,textColor,navColor;
|
|
|
|
if(style && style.red && style.green && style.blue && style.alpha){
|
|
|
|
themeColor=style.red + ',' + style.green + ',' + style.blue + ',' + Math.floor(style.alpha)
|
|
|
|
}else{
|
|
|
|
themeColor ='77,78,80,1'
|
|
|
|
let themeColor, textColor, navColor;
|
|
|
|
if (res.data.cook_style) {
|
|
|
|
let style = util.determine(res.data.cook_style)
|
|
|
|
if (style && style.red && style.green && style.blue && style.alpha) {
|
|
|
|
themeColor = style.red + ',' + style.green + ',' + style.blue + ',' + Math.floor(style.alpha)
|
|
|
|
} else {
|
|
|
|
themeColor = '77,78,80,1'; //未设置 为灰色
|
|
|
|
}
|
|
|
|
if(themeColor=='251,246,241,1'){
|
|
|
|
textColor="81,81,81,1"
|
|
|
|
navColor="81,81,81,1"
|
|
|
|
}else{
|
|
|
|
navColor="255,255,255,1"
|
|
|
|
if (themeColor == '251,246,241,1') {
|
|
|
|
textColor = "81,81,81,1"
|
|
|
|
navColor = "81,81,81,1"
|
|
|
|
} else {
|
|
|
|
navColor = "255,255,255,1"
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
themeColor,
|
|
|
|
textColor,
|
|
|
|
navColor
|
|
|
|
})
|
|
|
|
console.log(themeColor);
|
|
|
|
}
|
|
|
|
}).catch(res => {
|
|
|
|
themeColor = '77,78,80,1';
|
|
|
|
navColor = "255,255,255,1"
|
|
|
|
this.setData({
|
|
|
|
themeColor,
|
|
|
|
navColor
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
...
|
...
|
@@ -510,7 +525,7 @@ Page({ |
|
|
|
}
|
|
|
|
},
|
|
|
|
// 展示做法规格弹窗
|
|
|
|
showModal() {
|
|
|
|
showCheckModal() {
|
|
|
|
this.checkModal.showModal()
|
|
|
|
},
|
|
|
|
// 关闭做法规格弹窗
|
...
|
...
|
|