Commit fca4a1f7754e80f3c0ab5eb8b6a79a8e61d81316

Authored by wangfan
1 parent 171b8ef9

快速预定

// pack-cookbook/components/cart/cart.js
Component({
/**
* 组件的属性列表
*/
properties: {
/**
* 组件的属性列表
*/
properties: {
rid:{
type:String,
value:"",
}
},
},
/**
* 组件的初始数据
*/
data: {
hidden: true,
carts: ['啦啦啦', '啦啦啦啦啦', '啦啦', '啦', '啦啦啦啦啦', '啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦', '啦啦啦啦', '啦啦', '啦', '啦啦啦', '啦啦啦'],
},
/**
* 组件的初始数据
*/
data: {
carts:['啦啦啦','啦啦啦啦啦','啦啦','啦','啦啦啦啦啦','啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦','啦啦啦啦','啦啦','啦','啦啦啦','啦啦啦'],
/**
* 组件的方法列表
*/
methods: {
hide(){
this.setData({
hidden:true,
})
},
show(){
this.setData({
hidden:false,
})
},
init(){
App.Advance.CreateOrder({
rid:this.data.rid
}).then(res=>{
/**
* 组件的方法列表
*/
methods: {
}
})
},
}
})
... ...
<!--pack-cookbook/components/cart/cart.wxml-->
<view class="mask flex-bc" style="bottom: 103rpx; align-items: flex-end;">
<view class="cart">
<view class="mask flex-bc" style="bottom: 103rpx; align-items: flex-end;" hidden="{{hidden}}" bindtap="hide">
<view class="cart" catchtap="catchtap">
<view class="cart-title flex-rr">
<view class="icon">
<image src="http://qn.colorcun.com/custom/lite-yd-cook/image/empty.png"></image>
... ...
... ... @@ -4,147 +4,163 @@ import App from '../../utils/api';
const {regeneratorRuntime} = global
Page({
/**
* 页面的初始数据
*/
data: {
scrollTop:0,
isloading:true,
toView:"",
hasEnter:false,
totalWidth:getApp().system.windowWidth,
singleWidth:parseInt((getApp().system.windowWidth*0.92-16)/2),
totalHeight:getApp().system.windowHeight,
kindHeight:getApp().system.windowHeight-68,
hasListModel:true,
cookbooklist:[{},{},{},{},{},{},{},],
showSkeleton: true
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getCookList();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
/**
* 页面的初始数据
*/
data: {
scrollTop: 0,
isloading: true,
toView: "",
hasEnter: false,
totalWidth: getApp().system.windowWidth,
singleWidth: parseInt((getApp().system.windowWidth * 0.92 - 16) / 2),
totalHeight: getApp().system.windowHeight,
kindHeight: getApp().system.windowHeight - 68,
hasListModel: true,
cookbooklist: [{}, {}, {}, {}, {}, {}, {},],
showSkeleton: true,
order: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
options: options,
})
this.getCookList();
this.initOrder();
},
initOrder(){
App.Advance.CreateOrder({
rid: this.data.options.rid
}).then(res => {
this.setData({
totalWidth:getApp().system.windowWidth,
singleWidth:parseInt((getApp().system.windowWidth*0.92-16)/2),
totalHeight:getApp().system.windowHeight,
kindHeight:getApp().system.windowHeight-68
order: res.data,
})
},
})
},
dispalyCart(){
this.selectComponent("#cart").show();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.setData({
totalWidth: getApp().system.windowWidth,
singleWidth: parseInt((getApp().system.windowWidth * 0.92 - 16) / 2),
totalHeight: getApp().system.windowHeight,
kindHeight: getApp().system.windowHeight - 68
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
},
formatCookList(list){
//原栏目下显示
let hasShowClass=false;
let hasShowClass = false;
//菜单中展示沽清的菜品
let hasClearCookbook=false;
let hasClearCookbook = false;
//十道必选菜
let has10CaiOpen=false;
let flist=[];
if(list.length>0) {
has10CaiOpen=list[0].status==1;
let has10CaiOpen = false;
let flist = [];
if (list.length > 0) {
has10CaiOpen = list[0].status == 1;
list.forEach(function (cate, i) {
if (cate.status == 1 && cate.cookbooklist[0].length > 0) {
let cooks=[];
let cooks = [];
//let cooks_order=[];
cate.cookbooklist[0].forEach(function(cook,n){
if(cook.status==1){
let flag=true;
if(has10CaiOpen){
if(cate.class_type==2 && !hasShowClass && flist.length>0 && flist[0].class_type==1){
for(let fi=0;fi<flist[0].cookbooklist[0].length;fi++){
if(flist[0].cookbooklist[0][fi].id==cook.id){
flag=false;
cate.cookbooklist[0].forEach(function (cook, n) {
if (cook.status == 1) {
let flag = true;
if (has10CaiOpen) {
if (cate.class_type == 2 && !hasShowClass && flist.length > 0 && flist[0].class_type == 1) {
for (let fi = 0; fi < flist[0].cookbooklist[0].length; fi++) {
if (flist[0].cookbooklist[0][fi].id == cook.id) {
flag = false;
break;
}
}
}
}
cook.item_clear_num=cook.clear_num;
if(!hasClearCookbook){//不显示卖光了
let item_clear_num=cook.clear_num;
if(cook.spec){
let clear_num=null;
cook.spec.forEach(spec=>{
if(spec.clear_num==0){
clear_num=0;
}else{
clear_num=null;
cook.item_clear_num = cook.clear_num;
if (!hasClearCookbook) {//不显示卖光了
let item_clear_num = cook.clear_num;
if (cook.spec) {
let clear_num = null;
cook.spec.forEach(spec => {
if (spec.clear_num == 0) {
clear_num = 0;
} else {
clear_num = null;
}
})
if(clear_num==0){
item_clear_num=0;
if (clear_num == 0) {
item_clear_num = 0;
}
}
cook.item_clear_num=item_clear_num;
if(item_clear_num==0){
flag=false;
cook.item_clear_num = item_clear_num;
if (item_clear_num == 0) {
flag = false;
}
}
if(flag){
if (flag) {
cooks.push(cook);
//cooks_order.push(cook.order_o);
}
}
})
if(cooks.length>0){
if (cooks.length > 0) {
//cooks 排序...
cate.cookbooklist[0]=cooks;
cate.cookbooklist[0] = cooks;
flist.push(cate)
}
}
... ... @@ -152,102 +168,102 @@ Page({
}
return flist;
},
getCookList:function(orderid){
let param={
getCookList: function (orderid) {
let param = {
sellerid: 80,
//status:this.data.fromSoucre!=''?1:'',
identity:1
identity: 1
};
if(orderid){
param.orderid=orderid;
if (orderid) {
param.orderid = orderid;
}
App.Advance.GetCookbookByClass(param).then(json=>{
App.Advance.GetCookbookByClass(param).then(json => {
//菜单分类添加修饰
let cookbooklist = this.formatCookList(json.data[0].list);
setTimeout(()=>{
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,
countPirce: json.data[0].countPirce ? json.data[0].countPirce : 0,
countTotal: json.data[0].countTotal ? json.data[0].countTotal : 0,
isloading: false,
showSkeleton: false,
})
},1000)
}, 1000)
}).catch(res=>{
console.log('getCookList-catch',res);
}).catch(res => {
console.log('getCookList-catch', res);
this.selectComponent("#network").show('网络不给力,请检查网络后重试');
});
},
//菜品分类操作
changeList: function (e) {
var _id=e.detail.id;
console.log('changeList','inToView' + _id)
var _id = e.detail.id;
console.log('changeList', 'inToView' + _id)
this.setData({
toView: 'inToView' + _id,
});
},
foodCardCallback(e){
let opt=e.detail;
console.log('foodCardCallback',opt);
if(opt.type=='specWin'){
if(opt.value=='show'){
this.setData({scrollZindex:9999});
}else{
this.setData({scrollZindex:'auto'});
let opt = e.detail;
console.log('foodCardCallback', opt);
if (opt.type == 'specWin') {
if (opt.value == 'show') {
this.setData({scrollZindex: 9999});
} else {
this.setData({scrollZindex: 'auto'});
}
return;
}
let books=this.data.cookbooklist;
books.forEach(menu=>{
menu.cookbooklist[0].forEach(book=>{
if(book.id==opt.cookbookid){
book.num=opt.num;
let books = this.data.cookbooklist;
books.forEach(menu => {
menu.cookbooklist[0].forEach(book => {
if (book.id == opt.cookbookid) {
book.num = opt.num;
}
})
})
this.setData({
countTotal:this.data.countTotal+opt.type,
cookbooklist:books
countTotal: this.data.countTotal + opt.type,
cookbooklist: books
});
this.getOrderInfo();
},
//订单详情
getOrderInfo:function(){
App.Orders.GetOrderById({orderid:this.data.orderid}).then(json=>{
let order=json.data[0].order[0];
if(order.status<2){
this.setData({aiOrderStatus:json.data[0].order[0].status});
}else{
var title=''
if(json.data[0].order[0].status==2 || json.data[0].order[0].status==3){
if(this.data.fromSoucre || util.cache('identity')==2){
getOrderInfo: function () {
App.Orders.GetOrderById({orderid: this.data.orderid}).then(json => {
let order = json.data[0].order[0];
if (order.status < 2) {
this.setData({aiOrderStatus: json.data[0].order[0].status});
} else {
var title = ''
if (json.data[0].order[0].status == 2 || json.data[0].order[0].status == 3) {
if (this.data.fromSoucre || util.cache('identity') == 2) {
return;
}
title='手慢了,小伙伴已下单'
title = '手慢了,小伙伴已下单'
}
if(json.data[0].order[0].status==5){
title='订单已结账'
if (json.data[0].order[0].status == 5) {
title = '订单已结账'
}
if(json.data[0].order[0].status==7){
title='订单已清台'
if (json.data[0].order[0].status == 7) {
title = '订单已清台'
}
wx.showToast({
icon:'none',
title:title,
duration:1500,
icon: 'none',
title: title,
duration: 1500,
});
let that=this;
setTimeout(function(){
if(json.data[0].order[0].status>5){
let that = this;
setTimeout(function () {
if (json.data[0].order[0].status > 5) {
wx.reLaunch({
url:'/pages/menu/s_nothing?sellerid='+that.data.sellerid+'&orderid='+that.data.orderid,
url: '/pages/menu/s_nothing?sellerid=' + that.data.sellerid + '&orderid=' + that.data.orderid,
})
}else{
} else {
that.goToOrder(that.data.orderid)
}
},1500)
}, 1500)
}
})
... ...
... ... @@ -17,10 +17,8 @@
<block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="itemIndex" >
<view class="item">
<foodCard item="{{item}}"
sellerid="{{sellerid}}" orderid="{{orderid}}"
fromSoucre="{{fromSoucre}}" request_uri="{{request_uri}}"
sellerid="{{order.sellerid}}" orderid="{{order.id}}"
bindfoodCardCallback="foodCardCallback"
hasListModel="{{hasListModel}}"
></foodCard>
</view>
</block>
... ... @@ -37,34 +35,18 @@
</view>
<view class="text">一起点</view>
</view>
<view class="cart flex-ll">
<view class="cart flex-ll" bindtap="dispalyCart">
<view class="icon">
<image src="http://qn.colorcun.com/custom/lite-yd-cook/image/cart.png"/>
<view class="dot">11</view>
<view class="dot" wx:if="{{order.cookbooklist.length>0}}">{{order.cookbooklist.length}}</view>
</view>
<view class="text Semibold">¥0.00</view>
<view class="text Semibold">¥{{order.price}}</view>
</view>
<view class="place flex-vc">选好了</view>
<!--
<view class="body-view">
</view>
<view class="shopping-total flex-vc list-layout-buttom-opt">
<image src="http://qn.colorcun.com/custom/lite/image/cook-list-gwc.png" class="icon" />
<view style="color:#fff;font-size:24rpx;margin-top:-2px;text-align:center;" class="smooth">下单</view>
<block wx:if="{{countTotal>0}}">
<view class="show-num fwhite flex-cc smooth">{{countTotal}}</view>
</block>
<button bindgetuserinfo="bindChooseOk" open-type="getUserInfo" class="shop-button"></button>
<bubble id="bubble"></bubble>
</view>
<!--只有点菜后才显示点好了按钮-->
</view>
</view>
<cookClass id="menu" bind:changeList="changeList"
cooklist="{{cookbooklist}}" hasListModel="{{hasListModel}}">
</cookClass>
<cart></cart>
\ No newline at end of file
<cart rid="{{options.rid}}" id="cart" order="{{order}}"></cart>
\ No newline at end of file
... ...
... ... @@ -30,7 +30,7 @@
"list": []
},
"miniprogram": {
"current": 36,
"current": 25,
"list": [
{
"id": 0,
... ... @@ -225,10 +225,10 @@
"scene": "1001"
},
{
"id": -1,
"id": 25,
"name": "pack-cookbook/pages/index",
"pathName": "pack-cookbook/pages/index",
"query": ""
"query": "rid=1196&oid=2"
},
{
"id": 26,
... ... @@ -305,7 +305,8 @@
{
"id": -1,
"name": "pack-cookbook/pages/remark",
"pathName": "pack-cookbook/pages/remark"
"pathName": "pack-cookbook/pages/remark",
"query": ""
}
]
}
... ...