Commit 568103a6acd10587f2c5fdd0bd0266c31d5079a7

Authored by yiren
1 parent d4181854

提前点餐

... ... @@ -14,6 +14,8 @@ Page({
options: {},
check1: '', //做法
check2: '', //规格
check1Name:'',
check2Name:'',
isloading: true,
toView: "inToView27",
hasEnter: false,
... ... @@ -62,13 +64,6 @@ Page({
onReady() {
},
// 选择做法
checkSingle1(e) {
const check1 = e.currentTarget.dataset['item'];
this.setData({
check1
})
},
// 已选菜单页面跳转
gotoShoppingCart() {
let cookbooklist = this.data.cookbooklist;
... ... @@ -89,11 +84,26 @@ Page({
url: '/pack-cookbook/pages/cart_new',
})
},
// 选择做法
checkSingle1(e) {
const item = e.currentTarget.dataset['item'];
let checkItem=this.data.checkItem
checkItem.check1=item.id
this.setData({
check1:item.id,
check1Name:item.name,
checkItem
})
},
// 选择规格
checkSingle2(e) {
const check2 = e.currentTarget.dataset['item'];
const item = e.currentTarget.dataset['item'];
let checkItem=this.data.checkItem
checkItem.check2=item.id
this.setData({
check2
check2:item.id,
check2Name:item.specs,
checkItem
})
},
getNormsLen() {
... ... @@ -154,9 +164,11 @@ Page({
})
} else {
let obj = {
practice: this.data.check1,
unit: this.data.check2,
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
}
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
... ... @@ -185,20 +197,31 @@ Page({
})
let norms = this.data.cookbooklist[indexs].cookbooklist[0][index].norms
let normsNum;
if (norms.length != '0' && type == '0') {
normsNum = this.data.cookbooklist[indexs].cookbooklist[0][index].norms[normsIndex].quantum * 1 + 1;
} else {
normsNum = 1
}
if (type == '1') {
// 点击下面的加号并且有规格或者做法的,弹框选规格 下面的直接加
if (type == '1' && (item.practice.length>1 || item.spec.length>1)) {
return this.showModal()
}else {
normsNum = 1;
let obj={
quantum:normsNum,
practice: item.check1Name,
unit:item.unit,
practiceName:item.check1Name,
unitName:item.check2Name,
}
if(!normsIndex && norms.length == '0'){
this.data.cookbooklist[indexs].cookbooklist[0][index].norms.push(obj)
}
}
if (type == '0') {
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;
this.setData({
cookbooklist: this.data.cookbooklist,
})
}else{
normsNum = 1
}
this.setData({
cookbooklist: this.data.cookbooklist,
})
this.getNormsLen()
},
// 点击减号
... ... @@ -308,22 +331,19 @@ Page({
if (!cook.norms || cook.norms.length == 0) {
cook.norms = []; //做法规格
}
// let type;//模拟种类 1为一行显示1个 2为一行显示2个
// if(n=='0' || n=='3'){
// type='1'
// }else{
// type='2'
// }
cook.type = '1';
cook.arr1 = ['香辣', '清蒸', '爆炒', '清汤'];
cook.arr2 = ['小份', '中份', '份', '例', '两只'];
check1 = cook.arr1[0];
check2 = cook.arr2[0];
let cook_style=cook.cook_style?JSON.parse(cook.cook_style):'';
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:'';
if (item_clear_num == 0) {
flag = false;
}
}
if (flag) {
cooks.push(cook);
//cooks_order.push(cook.order_o);
... ... @@ -333,13 +353,26 @@ Page({
})
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)
})
// let image_typeArr=[];
// sortArr.forEach(item=>{
// item.cookbooklist[0].sort((a,b)=>{
// return a.image_type-b.image_type
// })
// image_typeArr.push(item)
// })
setTimeout(() => {
this.setData({
check1,
... ... @@ -347,8 +380,7 @@ Page({
assortArr
})
}, 1);
console.log('flist', flist);
return flist;
return sortArr;
},
// 获取所有分类下所有菜品列表
getCookList(orderid) {
... ... @@ -369,15 +401,15 @@ Page({
status: '0,1',
};
App.Advance.GetCookbookByClass(param).then(json => {
//菜单分类添加修饰
let cookbooklist = this.formatCookList(json.data[0].list);
let cookbooklist=this.formatCookList(json.data[0].list)
console.log('cookbooklist',cookbooklist);
setTimeout(() => {
this.setData({
cookbooklist,
isloading: false,
showSkeleton: false,
})
}, 0)
}, 1)
}).catch(res => {
console.log(res);
});
... ...
<!--pack-cookbook/pages/index_new.wxml-->
<nav backgroundColor="#4d4e50" color="#fff">{{options.sellerName||'提前点菜'}}</nav>
<loading wx:if="{{isloading}}">数据加载中</loading>
<view wx:if="{{type=='A'}}" class="wrapIine"></view>
<view class="wrapIine"></view>
<scroll-view style="height:100vh;" class="content" scroll-into-view="{{toView}}" scroll-y="true" scroll-with-animation="true">
<block wx:for="{{cookbooklist}}" wx:key="cookbooklist-key" wx:for-index="indexs">
<view class="dishWrap" id="{{ 'inToView'+item.id}}">
<block wx:if="{{type=='A'}}">
<block wx:if="{{item.class_type=='1'}}">
<view class="heand flex-vc flex-cc">
<view class="style_round flex-vc flex-cc">
<view class="round"></view>
... ... @@ -19,7 +19,8 @@
</view>
</block>
<block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index">
<view wx:if="{{item.type=='1'}}" class="dishWrap">
<!-- name_type 1左侧,2右侧,3顶部分开 image_type 1大图,2小图 -->
<view wx:if="{{item.image_type=='1'}}" class="dishWrap">
<view class="dishItem flex-lr">
<view class="dishLeft dishTexts">{{item.name}}</view>
<view class="dishTexts dishRight">{{item.first_name}}</view>
... ... @@ -39,7 +40,7 @@
</view>
<view class="norms">{{item.first_name}}</view>
</block>
<image wx:if="{{item.image}}" src="{{item.image}}" class="dishImg" mode="aspectFill" />
<image wx:if="{{item.image}}" src="{{item.image}}" class="dishImg" mode="aspectFill" />
<view class="greens">
<view class="news">{{item.first_name}}</view>
</view>
... ... @@ -47,13 +48,13 @@
<image src="https://qn.colorcun.com/WechatIMG697.png" mode="aspectFill" class="reduceImg" bindtap="subtraction" data-item="{{item}}" data-norms="{{normsIndex}}" data-key="{{index}}" data-indexs="{{indexs}}" />
<view class="box flex-cc">
<view class="num flex-cc">
{{item.quantum}}<view>{{item.unit}}</view>
{{item.quantum}}<view>{{item.unitName}}</view>
</view>
<view class="practice">{{item.practice}}</view>
<view class="practice">{{item.practiceName}}</view>
</view>
<image id="add" src="https://qn.colorcun.com/WechatIMG696.png" mode="aspectFill" class="imgs" data-type="0" bindtap="addition" data-norms="{{normsIndex}}" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" />
</view>
<view class="algorithmImg flex-rr">
<view wx:if="{{(item.spec.length>1 || item.practice.length>1) || item.norms.length=='0'}}" class="algorithmImg flex-rr">
<image src="https://qn.colorcun.com/WechatIMG696.png" class="imgs" mode="aspectFill" bindtap="addition" data-norms="{{normsIndex}}" data-type="1" data-item="{{item}}" data-key="{{index}}" data-indexs="{{indexs}}" />
</view>
<view class="wrapIine"></view>
... ... @@ -101,16 +102,16 @@
<scroll-view scroll-y style="height: 78%;overflow: auto;">
<view class="textSty">做法</view>
<view class="itemBox">
<block wx:for="{{checkItem.arr1}}">
<view class="single {{check1==item?'active':''}}" data-item="{{item}}" bindtap="checkSingle1">
{{item}}</view>
<block wx:for="{{checkItem.practice}}">
<view class="single {{checkItem.check1==item.id?'active':''}}" data-item="{{item}}" data-item="{{item}}" bindtap="checkSingle1">
{{item.name}}</view>
</block>
</view>
<view class="checkLine"></view>
<view class="textSty">规格</view>
<view class="itemBox">
<view class="single {{check2==item?'active':''}}" bindtap="checkSingle2" wx:for="{{checkItem.arr2}}" data-item="{{item}}">
{{item}}</view>
<view class="single {{checkItem.check2==item.id?'active':''}}" bindtap="checkSingle2" wx:for="{{checkItem.spec}}" data-item="{{item}}">
{{item.specs}}</view>
</view>
</scroll-view>
<view class="btns">
... ...