|
@@ -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
|
})
|