Commit 9a0ce2868a093432943b8c79c6b4cbeb2cbc1c7f

Authored by yiren
1 parent b863ec50

提前点餐

... ... @@ -10,46 +10,70 @@ Page({
sellerid: '',
notes: '',
noData: false,
rid: '',
oid: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
let obj = JSON.parse(wx.getStorageSync('cookbookObj'));
let noData = false;
let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist'));
this.formatCookList(cookbooklist);
this.setData({
sellerName: obj.sellerName,
sellerid: obj.sellerid,
rid: obj.rid,
oid: obj.oid,
})
},
formatCookList(cookbooklist) {
let probablyPrice = 0;
let noData = false;
cookbooklist.forEach(items => {
items.is_show = false
items.normsLen = 0
items.cookbooklist[0].forEach(item => {
console.log({
...item
});
if (item.isTrue) {
item.arr = []; //arr 点菜的菜品列表
if (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,
}
item.arr.push(obj)
let price = i.quantum * 1 * (i.price * 1);
probablyPrice += price;
})
noData = true
items.is_show = true
items.is_show = true; //展示不展示
items.normsLen += item.arr.length; //菜品数量
}
})
})
this.setData({
cookbooklist,
sellerName: obj.sellerName,
sellerid: obj.sellerid,
probablyPrice,
noData
})
},
// 继续点菜
continueOrdering() {
wx.navigateBack(1)
},
// 确认下单
determineFun() {
// wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist))
if (this.data.noData) {
let obj = {
sellerName: this.data.sellerName,
sellerid: this.data.sellerid,
notes: this.data.notes
notes: this.data.notes,
rid: this.data.rid,
oid: this.data.oid,
}
wx.navigateTo({
url: `/pack-cookbook/pages/success_new?cookbooklist=${JSON.stringify(this.data.cookbooklist)}&obj=${JSON.stringify(obj)}`,
... ... @@ -57,18 +81,21 @@ Page({
}
},
// 点加减
count(e) {
const item = e.currentTarget.dataset['item'];
const indexs = e.currentTarget.dataset['indexs'];
const index = e.currentTarget.dataset['index'];
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 quantum;
if (type == '1') quantum = item.quantum * 1 + 1;
if (type == '0') quantum = item.quantum * 1 - 1;
let checkObj = `cookbooklist[${indexs}].cookbooklist[0][${index}].quantum`;
this.setData({
[checkObj]: quantum,
})
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;
}
wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist))
this.formatCookList(this.data.cookbooklist)
},
/**
* 生命周期函数--监听页面初次渲染完成
... ...
... ... @@ -18,22 +18,24 @@
<input type="text" model:value="{{notes}}" placeholder="点击录入口味,偏好等要求" placeholder-style="color:#fff" />
</view>
<view class="line"></view>
<view class="checkMenu">
<view class="checkMenu" wx:if="{{cookbooklist.length>0}}">
<block wx:for="{{cookbooklist}}" wx:key="{{item.id}}" wx:for-index="indexs">
<view wx:if="{{item.is_show}}" class="title flex-lr">
<view class="leftTitle">{{item.class_name}}</view>
<view class="rightTitle">{{item.arr.length}}道</view>
<view class="rightTitle">{{item.normsLen}}道</view>
</view>
<block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index">
<view wx:if="{{item.quantum>0}}" class="content flex-lr">
<view class="single">{{item.name}}<text>({{item.practice}})</text></view>
<view class="price">{{item.price}}元/{{item.unit}}</view>
<view class="count flex-cc">
<image bindtap="count" data-item="{{item}}" data-type="0" data-indexs="{{indexs}}" data-index="{{index}}" src="https://qn.colorcun.com/WechatIMG809.png" class="img1" mode="" />
{{item.quantum}}
<image bindtap="count" data-item="{{item}}" data-type="1" data-indexs="{{indexs}}" data-index="{{index}}" src="https://qn.colorcun.com/WechatIMG810.png" class="img2" mode="" />
<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>
<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="" />
</view>
</view>
</view>
</block>
</block>
</block>
</view>
... ...
... ... @@ -38,17 +38,27 @@ page {
background: #999999;
}
.checkMenu {
border-radius: 10rpx;
background: #ffffff;
padding: 0 40rpx;
.content {
background-color: #fff;
padding: 10rpx 40rpx 20rpx 40rpx;
}
.content:last-of-type {
border-bottom-left-radius: 10rpx;
border-bottom-right-radius: 10rpx;
}
.title {
padding: 36rpx 0 4rpx 0;
padding: 36rpx 40rpx 4rpx 40rpx;
background-color: #fff;
border-bottom: 2rpx solid #DBDBDB;
}
.title:nth-of-type(1) {
border-top-left-radius: 10rpx;
border-top-right-radius: 10rpx;
}
.leftTitle {
color: #515151;
font-family: PingFang SC;
... ... @@ -62,10 +72,6 @@ page {
font-size: 28rpx;
}
.content {
padding: 20rpx 0;
}
.count text {
font-weight: bold;
color: #515151;
... ... @@ -115,5 +121,5 @@ page {
.determine1 {
background: #DBDBDB;
color:#BFC4D4;
color: #BFC4D4;
}
\ No newline at end of file
... ...
... ... @@ -16,8 +16,6 @@ Page({
check2: '', //规格
isloading: true,
toView: "inToView27",
countPirce: '',
countTotal: '',
hasEnter: false,
totalWidth: getApp().system.windowWidth,
singleWidth: parseInt((getApp().system.windowWidth * 0.92 - 16) / 2),
... ... @@ -31,13 +29,6 @@ Page({
orderItemCount: 0,
checkObj: '',
normsIndex: '',
normsList: [{
text: '做饭',
},
{
text: '规格',
}
],
assortArr: [],
},
checkModal: '',
... ... @@ -83,7 +74,10 @@ Page({
let obj = {
sellerName: this.data.options.sellerName,
sellerid: this.data.options.sid,
rid:this.data.options.rid,
oid: this.data.options.oid,
}
console.log('objobjobjobjobj',obj);
wx.setStorageSync('cookbooklist', JSON.stringify(cookbooklist))
wx.setStorageSync('cookbookObj', JSON.stringify(obj))
wx.navigateTo({
... ... @@ -129,6 +123,7 @@ Page({
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
... ... @@ -186,11 +181,6 @@ Page({
cookbooklist: this.data.cookbooklist,
})
}
if(this.data.cookbooklist[indexs].cookbooklist[0][index].norms.length>0){
this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=true
}else{
this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=false
}
},
// 点击减号
subtraction(e) {
... ... @@ -207,24 +197,6 @@ Page({
this.setData({
cookbooklist: this.data.cookbooklist,
})
if(this.data.cookbooklist[indexs].cookbooklist[0][index].norms.length>0){
this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=true
}else{
this.data.cookbooklist[indexs].cookbooklist[0][index].isTrue=false
}
// let practice = `cookbooklist[${indexs}].cookbooklist[0][${index}].practice`;
// let unit = `cookbooklist[${indexs}].cookbooklist[0][${index}].unit`;
// this.setData({
// checkObj: {
// indexs,
// index
// },
// [practice]: this.data.check1,
// [unit]: this.data.check2,
// })
},
// 扫桌码点餐
initOrder() {
... ... @@ -325,7 +297,6 @@ Page({
cook.arr2 = ['小份', '中份', '份', '例', '两只'];
check1 = cook.arr1[0];
check2 = cook.arr2[0];
cook.isTrue=false;//是否选了菜
if (item_clear_num == 0) {
flag = false;
}
... ... @@ -359,39 +330,53 @@ Page({
},
// 获取所有分类下所有菜品列表
getCookList(orderid) {
let param = {
sellerid: this.data.options.sid,
identity: this.data.options.identity,
orderid: this.data.options.oid,
status: '0,1',
};
App.Advance.GetCookbookByClass(param).then(json => {
//菜单分类添加修饰
let cookbooklist = this.formatCookList(json.data[0].list);
setTimeout(() => {
this.setData({
cookbooklist: cookbooklist,
countPirce: json.data[0].countPirce ? json.data[0].countPirce : 0,
countTotal: json.data[0].countTotal ? json.data[0].countTotal : 0,
isloading: false,
showSkeleton: false,
})
}, 0)
}).catch(res => {
this.selectComponent("#network").show('网络不给力,请检查网络后重试');
});
},
getStatus(e) {
this.setData({
status: e.currentTarget.dataset.index
})
let cookbooklist=wx.getStorageSync('cookbooklist');
console.log(cookbooklist,'cookbooklistcookbooklist');
let cookbooklistStorage=cookbooklist?JSON.parse(cookbooklist):'';
console.log('cookbooklist历史数据',cookbooklistStorage);
if(cookbooklistStorage.length>0){
this.setData({
cookbooklist:cookbooklistStorage,
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.Advance.GetCookbookByClass(param).then(json => {
//菜单分类添加修饰
let cookbooklist = this.formatCookList(json.data[0].list);
setTimeout(() => {
this.setData({
cookbooklist,
isloading: false,
showSkeleton: false,
})
}, 0)
}).catch(res => {
this.selectComponent("#network").show('网络不给力,请检查网络后重试');
});
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
let cookbooklistStorage=JSON.parse(wx.getStorageSync('cookbooklist'))
console.log('cookbooklist历史数据',cookbooklistStorage);
if(cookbooklistStorage){
this.setData({
cookbooklist:cookbooklistStorage,
isloading: false,
showSkeleton: false,
})
}else{
this.getCookList()
}
},
/**
... ...
// pack-cookbook/pages/success_new.js
import App from '../../utils/api';
import util from '../../utils/util';
Page({
/**
* 页面的初始数据
... ... @@ -18,37 +19,66 @@ Page({
recharge_data: {},
coupon_data: {},
dataStr: Date.now() * 1 / 1000,
rid:'',
oid:'',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
onLoad() {
let obj = JSON.parse(wx.getStorageSync('cookbookObj'));
let cookbooklist = JSON.parse(wx.getStorageSync('cookbooklist'));
this.formatCookList(cookbooklist);
this.setData({
sellerName: obj.sellerName,
sellerid: obj.sellerid,
notes: obj.notes,
rid:obj.rid,
oid:obj.oid,
})
console.log('obj',obj);
this.getSellerTemplateConfFun()
},
formatCookList(cookbooklist){
let probablyPrice = 0;
let noData = false;
cookbooklist.forEach(items => {
items.is_show = false
items.normsLen=0
items.cookbooklist[0].forEach(item => {
let price = item.quantum * 1 * (item.price * 1);
probablyPrice += price;
if (item.quantum > 0) {
items.is_show = true
item.arr=[];//arr 点菜的菜品列表
if (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,
}
item.arr.push(obj)
let price = i.quantum * 1 * (i.price * 1);
probablyPrice += price;
})
noData = true
items.is_show = true;//展示不展示
items.normsLen+=item.arr.length;//菜品数量
}
})
})
// wx.setStorageSync('cookbooklist', JSON.stringify(this.data.cookbooklist))
this.setData({
cookbooklist,
sellerName: obj.sellerName,
sellerid: obj.sellerid,
probablyPrice,
notes: obj.notes
noData
})
this.getSellerTemplateConfFun()
},
determineFun() {
wx.navigateTo({
url: `/pack-cookbook/pages/success_new?arr=${JSON.stringify(this.data.checkList)}&sellerName=${this.data.sellerName}`,
})
// 菜品更换
continueOrdering(){
// wx.nextTick(()=>{
// })
// wx.navigateBack()
// console.log(getCurrentPages());
},
getSellerTemplateConfFun(sid) {
console.log(sid, 'sidsidsidsid');
... ... @@ -56,7 +86,6 @@ Page({
sid: this.data.sellerid
}).then(res => {
let data = res.data
console.log('data', data);
let marketing, coupon_data, priceInfo, scoreInfo, recharge_list, stringifyUse;
marketing = data.marketing ? JSON.parse(data.marketing) : '';
console.log('marketing', marketing);
... ... @@ -101,6 +130,23 @@ Page({
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
let options={
sid:this.data.sellerid,
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',
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
... ... @@ -141,11 +187,4 @@ Page({
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
... ...
... ... @@ -25,16 +25,16 @@
<block wx:for="{{cookbooklist}}" wx:key="{{item.id}}" wx:for-index="indexs">
<view wx:if="{{item.is_show}}" class="title flex-lr">
<view class="leftTitle">{{item.class_name}}</view>
<view class="rightTitle">{{item.arr.length}}道</view>
<view class="rightTitle">{{item.normsLen}}道</view>
</view>
<block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="index">
<view wx:if="{{item.quantum>0}}" class="content flex-lr">
<view class="single">{{item.name}}<text>({{item.practice}})</text></view>
<view class="price">{{item.price}}元/{{item.unit}}</view>
<view class="count flex-cc">
<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}}
</view>
</view>
</block>
</block>
</block>
<view class="probably flex-ll">
... ... @@ -98,5 +98,5 @@
</scroll-view>
<view class="btns flex-cc">
<button class="font32r continue flex-cc" bindtap="continueOrdering">菜品更换</button>
<button class="font32r determine flex-cc" bindtap="determineFun">分享菜单</button>
<button class="font32r determine flex-cc" open-type="share">分享菜单</button>
</view>
\ No newline at end of file
... ...