|
...
|
...
|
@@ -14,8 +14,8 @@ Page({ |
|
|
|
options: {},
|
|
|
|
check1: '', //做法
|
|
|
|
check2: '', //规格
|
|
|
|
check1Name:'',
|
|
|
|
check2Name:'',
|
|
|
|
check1Name: '',
|
|
|
|
check2Name: '',
|
|
|
|
isloading: true,
|
|
|
|
toView: "inToView27",
|
|
|
|
hasEnter: false,
|
|
...
|
...
|
@@ -32,6 +32,9 @@ Page({ |
|
|
|
checkObj: '',
|
|
|
|
normsIndex: '',
|
|
|
|
assortArr: [],
|
|
|
|
themeColor:'',
|
|
|
|
textColor:'',
|
|
|
|
navColor:'',
|
|
|
|
},
|
|
|
|
checkModal: '',
|
|
|
|
classifyModal: '',
|
|
...
|
...
|
@@ -80,25 +83,26 @@ Page({ |
|
|
|
// 选择做法
|
|
|
|
checkSingle1(e) {
|
|
|
|
const item = e.currentTarget.dataset['item'];
|
|
|
|
let checkItem=this.data.checkItem
|
|
|
|
checkItem.check1=item.id
|
|
|
|
let checkItem = this.data.checkItem
|
|
|
|
checkItem.check1 = item.id
|
|
|
|
this.setData({
|
|
|
|
check1:item.id,
|
|
|
|
check1Name:item.name,
|
|
|
|
check1: item.id,
|
|
|
|
check1Name: item.name,
|
|
|
|
checkItem
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 选择规格
|
|
|
|
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,
|
|
|
|
check2: item.id,
|
|
|
|
check2Name: item.specs,
|
|
|
|
checkItem
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取点菜数量
|
|
|
|
getNormsLen() {
|
|
|
|
let cookbooklist = this.data.cookbooklist;
|
|
|
|
let normsLen = 0;
|
|
...
|
...
|
@@ -140,13 +144,15 @@ Page({ |
|
|
|
cookbooklist: this.data.cookbooklist,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
console.log({...data});
|
|
|
|
let obj = {
|
|
|
|
quantum: 1,
|
|
|
|
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
|
|
|
|
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:''
|
|
|
|
}
|
|
|
|
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
|
|
|
|
this.setData({
|
|
...
|
...
|
@@ -175,29 +181,33 @@ 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.spec.length > 1)) {
|
|
|
|
this.setData({
|
|
|
|
check1:item.practice.length>0?item.practice[0].id:'',
|
|
|
|
check2:item.spec.length>0?item.spec[0].id:'',
|
|
|
|
check1: item.practice[0].id,
|
|
|
|
check2: item.spec[0].id,
|
|
|
|
check1Name:item.practice[0].name,
|
|
|
|
check2Name:item.spec[0].spec,
|
|
|
|
})
|
|
|
|
return this.showModal()
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
normsNum = 1;
|
|
|
|
let obj={
|
|
|
|
quantum:normsNum,
|
|
|
|
let obj = {
|
|
|
|
quantum: normsNum,
|
|
|
|
practice: item.check1Name,
|
|
|
|
unit:item.unit,
|
|
|
|
practiceName:item.check1Name,
|
|
|
|
unitName:item.check2Name,
|
|
|
|
unit: item.unit,
|
|
|
|
practiceName: item.check1Name,
|
|
|
|
unitName: item.check2Name,
|
|
|
|
name:item.name,
|
|
|
|
price:item.price,
|
|
|
|
}
|
|
|
|
if(!normsIndex && norms.length == '0'){
|
|
|
|
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;
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
normsNum = 1
|
|
|
|
}
|
|
|
|
this.setData({
|
|
...
|
...
|
@@ -264,6 +274,7 @@ Page({ |
|
|
|
let assortArr = [];
|
|
|
|
let check1 = '';
|
|
|
|
let check2 = '';
|
|
|
|
let that=this;
|
|
|
|
if (list.length > 0) {
|
|
|
|
has10CaiOpen = list[0].status == 1;
|
|
|
|
list.forEach(function (cate, i) {
|
|
...
|
...
|
@@ -313,14 +324,14 @@ Page({ |
|
|
|
cook.norms = []; //做法规格
|
|
|
|
}
|
|
|
|
cook.type = '1';
|
|
|
|
let cook_style=cook.cook_style?JSON.parse(cook.cook_style):'';
|
|
|
|
let cook_style = cook.cook_style?that.determine(cook.cook_style):'';//判断是不是json,是json在转换为对象
|
|
|
|
cook.cook_style = cook_style;
|
|
|
|
cook.image_type = cook_style.image_type?cook_style.image_type:'1';//1大图,2小图 默认大图
|
|
|
|
cook.name_type = 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.check1Name = cook.practice.length>0?cook.practice[0].name:'';
|
|
|
|
cook.check2Name = cook.spec.length>0?cook.spec[0].specs:'';
|
|
|
|
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.check1Name = cook.practice.length > 0 ? cook.practice[0].name : '';
|
|
|
|
cook.check2Name = cook.spec.length > 0 ? cook.spec[0].specs : '';
|
|
|
|
if (item_clear_num == 0) {
|
|
|
|
flag = false;
|
|
|
|
}
|
|
...
|
...
|
@@ -340,41 +351,63 @@ Page({ |
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
let sortArr=[]
|
|
|
|
flist.forEach(item=>{
|
|
|
|
item.cookbooklist[0].sort((a,b)=>{
|
|
|
|
return a.order_o-b.order_o
|
|
|
|
// 排序
|
|
|
|
let sortArr = []
|
|
|
|
flist.forEach(item => {
|
|
|
|
item.cookbooklist[0].sort((a, b) => {
|
|
|
|
return a.order_o - b.order_o
|
|
|
|
})
|
|
|
|
sortArr.push(item)
|
|
|
|
})
|
|
|
|
let image_typeArr=[];
|
|
|
|
sortArr.forEach(item=>{
|
|
|
|
let num=0;
|
|
|
|
item.cookbooklist[0].forEach((i,idx)=>{
|
|
|
|
if(i.image_type=='2'){
|
|
|
|
// 大小图设置边框
|
|
|
|
let image_typeArr = [];
|
|
|
|
sortArr.forEach(item => {
|
|
|
|
let num = 0;
|
|
|
|
item.cookbooklist[0].forEach((i, idx) => {
|
|
|
|
if (i.image_type == '2') {
|
|
|
|
num++
|
|
|
|
i.index=num;
|
|
|
|
if(i.index%2!=0){
|
|
|
|
i.boderNone=false;
|
|
|
|
}else{
|
|
|
|
i.boderNone=true;
|
|
|
|
i.index = num;
|
|
|
|
if (i.index % 2 != 0) {
|
|
|
|
i.boderNone = false;
|
|
|
|
} else {
|
|
|
|
i.boderNone = true;
|
|
|
|
}
|
|
|
|
// 下一个是大图 不是最后一个
|
|
|
|
if(item.cookbooklist[0][idx+1].image_type=='1' && idx!=item.cookbooklist[0].length-1){
|
|
|
|
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})
|
|
|
|
if (num % 2 != 0) {
|
|
|
|
let s = i.index * 1 + 1;
|
|
|
|
item.cookbooklist[0].splice(idx + 1, 0, {
|
|
|
|
index: s,
|
|
|
|
boderNone: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if(i.image_type=='1'){
|
|
|
|
i.index=0
|
|
|
|
num=0
|
|
|
|
} else if (i.image_type == '1') {
|
|
|
|
i.index = 0
|
|
|
|
num = 0
|
|
|
|
}
|
|
|
|
})
|
|
|
|
image_typeArr.push(item)
|
|
|
|
})
|
|
|
|
console.log('image_typeArr',image_typeArr);
|
|
|
|
// 获取所有的规格
|
|
|
|
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,
|
|
...
|
...
|
@@ -382,10 +415,22 @@ 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(orderid) {
|
|
|
|
getCookList() {
|
|
|
|
let cookbooklist = wx.getStorageSync('cookbooklist');
|
|
|
|
let cookbooklistStorage = cookbooklist ? JSON.parse(cookbooklist) : '';
|
|
|
|
console.log('cookbooklist历史数据', cookbooklistStorage);
|
|
...
|
...
|
@@ -402,9 +447,9 @@ Page({ |
|
|
|
orderid: this.data.options.oid,
|
|
|
|
status: '0,1',
|
|
|
|
};
|
|
|
|
App.Advance.GetCookbookByClass(param).then(json => {
|
|
|
|
let cookbooklist=this.formatCookList(json.data[0].list)
|
|
|
|
// console.log('cookbooklist',cookbooklist);
|
|
|
|
App.Cookbook.GetCookbookByClass(param).then(json => {
|
|
|
|
let cookbooklist = this.formatCookList(json.data[0].list)
|
|
|
|
console.log('cookbooklist', cookbooklist);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.setData({
|
|
|
|
cookbooklist,
|
|
...
|
...
|
@@ -416,6 +461,34 @@ Page({ |
|
|
|
console.log(res);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
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'
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
...
|
...
|
|