Commit fca4a1f7754e80f3c0ab5eb8b6a79a8e61d81316

Authored by wangfan
1 parent 171b8ef9

快速预定

1 // pack-cookbook/components/cart/cart.js 1 // pack-cookbook/components/cart/cart.js
2 Component({ 2 Component({
3 - /**  
4 - * 组件的属性列表  
5 - */  
6 - properties: { 3 + /**
  4 + * 组件的属性列表
  5 + */
  6 + properties: {
  7 + rid:{
  8 + type:String,
  9 + value:"",
  10 + }
  11 + },
7 12
8 - }, 13 + /**
  14 + * 组件的初始数据
  15 + */
  16 + data: {
  17 + hidden: true,
  18 + carts: ['啦啦啦', '啦啦啦啦啦', '啦啦', '啦', '啦啦啦啦啦', '啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦', '啦啦啦啦', '啦啦', '啦', '啦啦啦', '啦啦啦'],
  19 + },
9 20
10 - /**  
11 - * 组件的初始数据  
12 - */  
13 - data: {  
14 - carts:['啦啦啦','啦啦啦啦啦','啦啦','啦','啦啦啦啦啦','啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦','啦啦啦啦','啦啦','啦','啦啦啦','啦啦啦'], 21 + /**
  22 + * 组件的方法列表
  23 + */
  24 + methods: {
  25 + hide(){
  26 + this.setData({
  27 + hidden:true,
  28 + })
15 }, 29 },
  30 + show(){
  31 + this.setData({
  32 + hidden:false,
  33 + })
  34 + },
  35 + init(){
  36 + App.Advance.CreateOrder({
  37 + rid:this.data.rid
  38 + }).then(res=>{
16 39
17 - /**  
18 - * 组件的方法列表  
19 - */  
20 - methods: {  
21 -  
22 - } 40 + })
  41 + },
  42 + }
23 }) 43 })
1 <!--pack-cookbook/components/cart/cart.wxml--> 1 <!--pack-cookbook/components/cart/cart.wxml-->
2 -<view class="mask flex-bc" style="bottom: 103rpx; align-items: flex-end;">  
3 - <view class="cart"> 2 +<view class="mask flex-bc" style="bottom: 103rpx; align-items: flex-end;" hidden="{{hidden}}" bindtap="hide">
  3 + <view class="cart" catchtap="catchtap">
4 <view class="cart-title flex-rr"> 4 <view class="cart-title flex-rr">
5 <view class="icon"> 5 <view class="icon">
6 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/empty.png"></image> 6 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/empty.png"></image>
@@ -4,147 +4,163 @@ import App from '../../utils/api'; @@ -4,147 +4,163 @@ import App from '../../utils/api';
4 const {regeneratorRuntime} = global 4 const {regeneratorRuntime} = global
5 Page({ 5 Page({
6 6
7 - /**  
8 - * 页面的初始数据  
9 - */  
10 - data: {  
11 - scrollTop:0,  
12 - isloading:true,  
13 - toView:"",  
14 - hasEnter:false,  
15 -  
16 - totalWidth:getApp().system.windowWidth,  
17 - singleWidth:parseInt((getApp().system.windowWidth*0.92-16)/2),  
18 - totalHeight:getApp().system.windowHeight,  
19 - kindHeight:getApp().system.windowHeight-68,  
20 - hasListModel:true,  
21 -  
22 - cookbooklist:[{},{},{},{},{},{},{},],  
23 - showSkeleton: true  
24 - },  
25 -  
26 - /**  
27 - * 生命周期函数--监听页面加载  
28 - */  
29 - onLoad: function (options) {  
30 - this.getCookList();  
31 - },  
32 -  
33 - /**  
34 - * 生命周期函数--监听页面初次渲染完成  
35 - */  
36 - onReady: function () {  
37 -  
38 - },  
39 -  
40 - /**  
41 - * 生命周期函数--监听页面显示  
42 - */  
43 - onShow: function () { 7 + /**
  8 + * 页面的初始数据
  9 + */
  10 + data: {
  11 + scrollTop: 0,
  12 + isloading: true,
  13 + toView: "",
  14 + hasEnter: false,
  15 +
  16 + totalWidth: getApp().system.windowWidth,
  17 + singleWidth: parseInt((getApp().system.windowWidth * 0.92 - 16) / 2),
  18 + totalHeight: getApp().system.windowHeight,
  19 + kindHeight: getApp().system.windowHeight - 68,
  20 + hasListModel: true,
  21 +
  22 + cookbooklist: [{}, {}, {}, {}, {}, {}, {},],
  23 + showSkeleton: true,
  24 + order: {},
  25 + },
  26 +
  27 + /**
  28 + * 生命周期函数--监听页面加载
  29 + */
  30 + onLoad: function (options) {
  31 + this.setData({
  32 + options: options,
  33 + })
  34 + this.getCookList();
  35 + this.initOrder();
  36 + },
  37 + initOrder(){
  38 + App.Advance.CreateOrder({
  39 + rid: this.data.options.rid
  40 + }).then(res => {
44 this.setData({ 41 this.setData({
45 - totalWidth:getApp().system.windowWidth,  
46 - singleWidth:parseInt((getApp().system.windowWidth*0.92-16)/2),  
47 - totalHeight:getApp().system.windowHeight,  
48 - kindHeight:getApp().system.windowHeight-68 42 + order: res.data,
49 }) 43 })
50 - }, 44 + })
  45 + },
  46 + dispalyCart(){
  47 + this.selectComponent("#cart").show();
  48 + },
  49 + /**
  50 + * 生命周期函数--监听页面初次渲染完成
  51 + */
  52 + onReady: function () {
51 53
52 - /**  
53 - * 生命周期函数--监听页面隐藏  
54 - */  
55 - onHide: function () { 54 + },
56 55
57 - }, 56 + /**
  57 + * 生命周期函数--监听页面显示
  58 + */
  59 + onShow: function () {
  60 + this.setData({
  61 + totalWidth: getApp().system.windowWidth,
  62 + singleWidth: parseInt((getApp().system.windowWidth * 0.92 - 16) / 2),
  63 + totalHeight: getApp().system.windowHeight,
  64 + kindHeight: getApp().system.windowHeight - 68
  65 + })
  66 + },
  67 +
  68 + /**
  69 + * 生命周期函数--监听页面隐藏
  70 + */
  71 + onHide: function () {
  72 +
  73 + },
58 74
59 - /**  
60 - * 生命周期函数--监听页面卸载  
61 - */  
62 - onUnload: function () { 75 + /**
  76 + * 生命周期函数--监听页面卸载
  77 + */
  78 + onUnload: function () {
63 79
64 - }, 80 + },
65 81
66 - /**  
67 - * 页面相关事件处理函数--监听用户下拉动作  
68 - */  
69 - onPullDownRefresh: function () { 82 + /**
  83 + * 页面相关事件处理函数--监听用户下拉动作
  84 + */
  85 + onPullDownRefresh: function () {
70 86
71 - }, 87 + },
72 88
73 - /**  
74 - * 页面上拉触底事件的处理函数  
75 - */  
76 - onReachBottom: function () { 89 + /**
  90 + * 页面上拉触底事件的处理函数
  91 + */
  92 + onReachBottom: function () {
77 93
78 - }, 94 + },
79 95
80 - /**  
81 - * 用户点击右上角分享  
82 - */  
83 - onShareAppMessage: function () { 96 + /**
  97 + * 用户点击右上角分享
  98 + */
  99 + onShareAppMessage: function () {
84 100
85 - }, 101 + },
86 formatCookList(list){ 102 formatCookList(list){
87 //原栏目下显示 103 //原栏目下显示
88 - let hasShowClass=false; 104 + let hasShowClass = false;
89 105
90 //菜单中展示沽清的菜品 106 //菜单中展示沽清的菜品
91 - let hasClearCookbook=false; 107 + let hasClearCookbook = false;
92 108
93 //十道必选菜 109 //十道必选菜
94 - let has10CaiOpen=false;  
95 - let flist=[];  
96 - if(list.length>0) {  
97 - has10CaiOpen=list[0].status==1; 110 + let has10CaiOpen = false;
  111 + let flist = [];
  112 + if (list.length > 0) {
  113 + has10CaiOpen = list[0].status == 1;
98 list.forEach(function (cate, i) { 114 list.forEach(function (cate, i) {
99 if (cate.status == 1 && cate.cookbooklist[0].length > 0) { 115 if (cate.status == 1 && cate.cookbooklist[0].length > 0) {
100 - let cooks=[]; 116 + let cooks = [];
101 //let cooks_order=[]; 117 //let cooks_order=[];
102 - cate.cookbooklist[0].forEach(function(cook,n){  
103 - if(cook.status==1){  
104 - let flag=true;  
105 - if(has10CaiOpen){  
106 - if(cate.class_type==2 && !hasShowClass && flist.length>0 && flist[0].class_type==1){  
107 - for(let fi=0;fi<flist[0].cookbooklist[0].length;fi++){  
108 - if(flist[0].cookbooklist[0][fi].id==cook.id){  
109 - flag=false; 118 + cate.cookbooklist[0].forEach(function (cook, n) {
  119 + if (cook.status == 1) {
  120 + let flag = true;
  121 + if (has10CaiOpen) {
  122 + if (cate.class_type == 2 && !hasShowClass && flist.length > 0 && flist[0].class_type == 1) {
  123 + for (let fi = 0; fi < flist[0].cookbooklist[0].length; fi++) {
  124 + if (flist[0].cookbooklist[0][fi].id == cook.id) {
  125 + flag = false;
110 break; 126 break;
111 } 127 }
112 } 128 }
113 } 129 }
114 } 130 }
115 - cook.item_clear_num=cook.clear_num;  
116 - if(!hasClearCookbook){//不显示卖光了  
117 - let item_clear_num=cook.clear_num;  
118 - if(cook.spec){  
119 - let clear_num=null;  
120 - cook.spec.forEach(spec=>{  
121 - if(spec.clear_num==0){  
122 - clear_num=0;  
123 - }else{  
124 - clear_num=null; 131 + cook.item_clear_num = cook.clear_num;
  132 + if (!hasClearCookbook) {//不显示卖光了
  133 + let item_clear_num = cook.clear_num;
  134 + if (cook.spec) {
  135 + let clear_num = null;
  136 + cook.spec.forEach(spec => {
  137 + if (spec.clear_num == 0) {
  138 + clear_num = 0;
  139 + } else {
  140 + clear_num = null;
125 } 141 }
126 }) 142 })
127 - if(clear_num==0){  
128 - item_clear_num=0; 143 + if (clear_num == 0) {
  144 + item_clear_num = 0;
129 } 145 }
130 } 146 }
131 - cook.item_clear_num=item_clear_num;  
132 - if(item_clear_num==0){  
133 - flag=false; 147 + cook.item_clear_num = item_clear_num;
  148 + if (item_clear_num == 0) {
  149 + flag = false;
134 } 150 }
135 } 151 }
136 152
137 - if(flag){ 153 + if (flag) {
138 cooks.push(cook); 154 cooks.push(cook);
139 //cooks_order.push(cook.order_o); 155 //cooks_order.push(cook.order_o);
140 } 156 }
141 157
142 } 158 }
143 }) 159 })
144 - if(cooks.length>0){ 160 + if (cooks.length > 0) {
145 //cooks 排序... 161 //cooks 排序...
146 162
147 - cate.cookbooklist[0]=cooks; 163 + cate.cookbooklist[0] = cooks;
148 flist.push(cate) 164 flist.push(cate)
149 } 165 }
150 } 166 }
@@ -152,102 +168,102 @@ Page({ @@ -152,102 +168,102 @@ Page({
152 } 168 }
153 return flist; 169 return flist;
154 }, 170 },
155 - getCookList:function(orderid){  
156 - let param={ 171 + getCookList: function (orderid) {
  172 + let param = {
157 sellerid: 80, 173 sellerid: 80,
158 //status:this.data.fromSoucre!=''?1:'', 174 //status:this.data.fromSoucre!=''?1:'',
159 - identity:1 175 + identity: 1
160 }; 176 };
161 - if(orderid){  
162 - param.orderid=orderid; 177 + if (orderid) {
  178 + param.orderid = orderid;
163 } 179 }
164 - App.Advance.GetCookbookByClass(param).then(json=>{ 180 + App.Advance.GetCookbookByClass(param).then(json => {
165 //菜单分类添加修饰 181 //菜单分类添加修饰
166 let cookbooklist = this.formatCookList(json.data[0].list); 182 let cookbooklist = this.formatCookList(json.data[0].list);
167 - setTimeout(()=>{ 183 + setTimeout(() => {
168 this.setData({ 184 this.setData({
169 cookbooklist: cookbooklist, 185 cookbooklist: cookbooklist,
170 - countPirce:json.data[0].countPirce ? json.data[0].countPirce : 0,  
171 - countTotal:json.data[0].countTotal ? json.data[0].countTotal : 0,  
172 - isloading:false,  
173 - showSkeleton:false, 186 + countPirce: json.data[0].countPirce ? json.data[0].countPirce : 0,
  187 + countTotal: json.data[0].countTotal ? json.data[0].countTotal : 0,
  188 + isloading: false,
  189 + showSkeleton: false,
174 }) 190 })
175 - },1000) 191 + }, 1000)
176 192
177 - }).catch(res=>{  
178 - console.log('getCookList-catch',res); 193 + }).catch(res => {
  194 + console.log('getCookList-catch', res);
179 this.selectComponent("#network").show('网络不给力,请检查网络后重试'); 195 this.selectComponent("#network").show('网络不给力,请检查网络后重试');
180 }); 196 });
181 }, 197 },
182 //菜品分类操作 198 //菜品分类操作
183 changeList: function (e) { 199 changeList: function (e) {
184 - var _id=e.detail.id;  
185 - console.log('changeList','inToView' + _id) 200 + var _id = e.detail.id;
  201 + console.log('changeList', 'inToView' + _id)
186 this.setData({ 202 this.setData({
187 toView: 'inToView' + _id, 203 toView: 'inToView' + _id,
188 }); 204 });
189 205
190 }, 206 },
191 foodCardCallback(e){ 207 foodCardCallback(e){
192 - let opt=e.detail;  
193 - console.log('foodCardCallback',opt);  
194 - if(opt.type=='specWin'){  
195 - if(opt.value=='show'){  
196 - this.setData({scrollZindex:9999});  
197 - }else{  
198 - this.setData({scrollZindex:'auto'}); 208 + let opt = e.detail;
  209 + console.log('foodCardCallback', opt);
  210 + if (opt.type == 'specWin') {
  211 + if (opt.value == 'show') {
  212 + this.setData({scrollZindex: 9999});
  213 + } else {
  214 + this.setData({scrollZindex: 'auto'});
199 } 215 }
200 return; 216 return;
201 } 217 }
202 - let books=this.data.cookbooklist;  
203 - books.forEach(menu=>{  
204 - menu.cookbooklist[0].forEach(book=>{  
205 - if(book.id==opt.cookbookid){  
206 - book.num=opt.num; 218 + let books = this.data.cookbooklist;
  219 + books.forEach(menu => {
  220 + menu.cookbooklist[0].forEach(book => {
  221 + if (book.id == opt.cookbookid) {
  222 + book.num = opt.num;
207 } 223 }
208 }) 224 })
209 }) 225 })
210 this.setData({ 226 this.setData({
211 - countTotal:this.data.countTotal+opt.type,  
212 - cookbooklist:books 227 + countTotal: this.data.countTotal + opt.type,
  228 + cookbooklist: books
213 }); 229 });
214 this.getOrderInfo(); 230 this.getOrderInfo();
215 }, 231 },
216 //订单详情 232 //订单详情
217 - getOrderInfo:function(){  
218 - App.Orders.GetOrderById({orderid:this.data.orderid}).then(json=>{  
219 - let order=json.data[0].order[0];  
220 - if(order.status<2){  
221 - this.setData({aiOrderStatus:json.data[0].order[0].status});  
222 - }else{  
223 - var title=''  
224 - if(json.data[0].order[0].status==2 || json.data[0].order[0].status==3){  
225 - if(this.data.fromSoucre || util.cache('identity')==2){ 233 + getOrderInfo: function () {
  234 + App.Orders.GetOrderById({orderid: this.data.orderid}).then(json => {
  235 + let order = json.data[0].order[0];
  236 + if (order.status < 2) {
  237 + this.setData({aiOrderStatus: json.data[0].order[0].status});
  238 + } else {
  239 + var title = ''
  240 + if (json.data[0].order[0].status == 2 || json.data[0].order[0].status == 3) {
  241 + if (this.data.fromSoucre || util.cache('identity') == 2) {
226 return; 242 return;
227 } 243 }
228 - title='手慢了,小伙伴已下单' 244 + title = '手慢了,小伙伴已下单'
229 } 245 }
230 - if(json.data[0].order[0].status==5){  
231 - title='订单已结账' 246 + if (json.data[0].order[0].status == 5) {
  247 + title = '订单已结账'
232 } 248 }
233 - if(json.data[0].order[0].status==7){  
234 - title='订单已清台' 249 + if (json.data[0].order[0].status == 7) {
  250 + title = '订单已清台'
235 } 251 }
236 wx.showToast({ 252 wx.showToast({
237 - icon:'none',  
238 - title:title,  
239 - duration:1500, 253 + icon: 'none',
  254 + title: title,
  255 + duration: 1500,
240 }); 256 });
241 - let that=this;  
242 - setTimeout(function(){  
243 - if(json.data[0].order[0].status>5){ 257 + let that = this;
  258 + setTimeout(function () {
  259 + if (json.data[0].order[0].status > 5) {
244 wx.reLaunch({ 260 wx.reLaunch({
245 - url:'/pages/menu/s_nothing?sellerid='+that.data.sellerid+'&orderid='+that.data.orderid, 261 + url: '/pages/menu/s_nothing?sellerid=' + that.data.sellerid + '&orderid=' + that.data.orderid,
246 }) 262 })
247 - }else{ 263 + } else {
248 that.goToOrder(that.data.orderid) 264 that.goToOrder(that.data.orderid)
249 } 265 }
250 - },1500) 266 + }, 1500)
251 } 267 }
252 268
253 }) 269 })
@@ -17,10 +17,8 @@ @@ -17,10 +17,8 @@
17 <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="itemIndex" > 17 <block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="itemIndex" >
18 <view class="item"> 18 <view class="item">
19 <foodCard item="{{item}}" 19 <foodCard item="{{item}}"
20 - sellerid="{{sellerid}}" orderid="{{orderid}}"  
21 - fromSoucre="{{fromSoucre}}" request_uri="{{request_uri}}" 20 + sellerid="{{order.sellerid}}" orderid="{{order.id}}"
22 bindfoodCardCallback="foodCardCallback" 21 bindfoodCardCallback="foodCardCallback"
23 - hasListModel="{{hasListModel}}"  
24 ></foodCard> 22 ></foodCard>
25 </view> 23 </view>
26 </block> 24 </block>
@@ -37,34 +35,18 @@ @@ -37,34 +35,18 @@
37 </view> 35 </view>
38 <view class="text">一起点</view> 36 <view class="text">一起点</view>
39 </view> 37 </view>
40 - <view class="cart flex-ll"> 38 + <view class="cart flex-ll" bindtap="dispalyCart">
41 <view class="icon"> 39 <view class="icon">
42 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/cart.png"/> 40 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/cart.png"/>
43 - <view class="dot">11</view> 41 + <view class="dot" wx:if="{{order.cookbooklist.length>0}}">{{order.cookbooklist.length}}</view>
44 </view> 42 </view>
45 - <view class="text Semibold">¥0.00</view> 43 + <view class="text Semibold">¥{{order.price}}</view>
46 </view> 44 </view>
47 <view class="place flex-vc">选好了</view> 45 <view class="place flex-vc">选好了</view>
48 - <!--  
49 - <view class="body-view">  
50 -  
51 - </view>  
52 - <view class="shopping-total flex-vc list-layout-buttom-opt">  
53 -  
54 - <image src="http://qn.colorcun.com/custom/lite/image/cook-list-gwc.png" class="icon" />  
55 - <view style="color:#fff;font-size:24rpx;margin-top:-2px;text-align:center;" class="smooth">下单</view>  
56 - <block wx:if="{{countTotal>0}}">  
57 - <view class="show-num fwhite flex-cc smooth">{{countTotal}}</view>  
58 - </block>  
59 - <button bindgetuserinfo="bindChooseOk" open-type="getUserInfo" class="shop-button"></button>  
60 - <bubble id="bubble"></bubble>  
61 - </view>  
62 -  
63 - <!--只有点菜后才显示点好了按钮-->  
64 </view> 46 </view>
65 </view> 47 </view>
66 48
67 <cookClass id="menu" bind:changeList="changeList" 49 <cookClass id="menu" bind:changeList="changeList"
68 cooklist="{{cookbooklist}}" hasListModel="{{hasListModel}}"> 50 cooklist="{{cookbooklist}}" hasListModel="{{hasListModel}}">
69 </cookClass> 51 </cookClass>
70 -<cart></cart>  
  52 +<cart rid="{{options.rid}}" id="cart" order="{{order}}"></cart>
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 "list": [] 30 "list": []
31 }, 31 },
32 "miniprogram": { 32 "miniprogram": {
33 - "current": 36, 33 + "current": 25,
34 "list": [ 34 "list": [
35 { 35 {
36 "id": 0, 36 "id": 0,
@@ -225,10 +225,10 @@ @@ -225,10 +225,10 @@
225 "scene": "1001" 225 "scene": "1001"
226 }, 226 },
227 { 227 {
228 - "id": -1, 228 + "id": 25,
229 "name": "pack-cookbook/pages/index", 229 "name": "pack-cookbook/pages/index",
230 "pathName": "pack-cookbook/pages/index", 230 "pathName": "pack-cookbook/pages/index",
231 - "query": "" 231 + "query": "rid=1196&oid=2"
232 }, 232 },
233 { 233 {
234 "id": 26, 234 "id": 26,
@@ -305,7 +305,8 @@ @@ -305,7 +305,8 @@
305 { 305 {
306 "id": -1, 306 "id": -1,
307 "name": "pack-cookbook/pages/remark", 307 "name": "pack-cookbook/pages/remark",
308 - "pathName": "pack-cookbook/pages/remark" 308 + "pathName": "pack-cookbook/pages/remark",
  309 + "query": ""
309 } 310 }
310 ] 311 ]
311 } 312 }