|
@@ -2,636 +2,647 @@ |
|
@@ -2,636 +2,647 @@ |
2
|
const app = getApp();
|
2
|
const app = getApp();
|
3
|
Page({
|
3
|
Page({
|
4
|
|
4
|
|
5
|
- /**
|
|
|
6
|
- * 页面的初始数据
|
|
|
7
|
- */
|
|
|
8
|
- data: {
|
|
|
9
|
- imgUrl: app.globalData.imgUrl,
|
|
|
10
|
- shoucang: false,
|
|
|
11
|
- active: true,
|
|
|
12
|
- show: false,
|
|
|
13
|
- shows: false,
|
|
|
14
|
- id: 0,
|
|
|
15
|
- goods: [],
|
|
|
16
|
- ids: [],
|
|
|
17
|
- idss: [],
|
|
|
18
|
- status: 0,
|
|
|
19
|
- cart_count: 0,
|
|
|
20
|
- skuid: '',
|
|
|
21
|
- num: 1,
|
|
|
22
|
- id_arr: [],
|
|
|
23
|
- gPrice: 0,
|
|
|
24
|
- collocation: [],
|
|
|
25
|
- goods_star: 1,
|
|
|
26
|
- star_arr: [],
|
|
|
27
|
- commentCount: 0,
|
|
|
28
|
- favorite: 0,
|
|
|
29
|
- totalPrice: 0,
|
|
|
30
|
- gPrice: 0,
|
|
|
31
|
- is_group: 0,
|
|
|
32
|
- packageList: [],
|
|
|
33
|
- showList: [],
|
|
|
34
|
- showMore: false,
|
|
|
35
|
- show1: false,
|
|
|
36
|
- goods1: {},
|
|
|
37
|
- origin: 0,
|
|
|
38
|
- skuid_arr: [],
|
|
|
39
|
- is_vip: 0
|
|
|
40
|
- },
|
|
|
41
|
- fetchVip() {
|
|
|
42
|
- let url = '/wxapp/user/index'
|
|
|
43
|
- app.post(url).then(r => {
|
|
|
44
|
- if (r.code == 1) {
|
|
|
45
|
- console.log(r)
|
|
|
46
|
- this.setData({
|
|
|
47
|
- is_vip: r.data.user.is_vip
|
|
|
48
|
- })
|
|
|
49
|
- this.fetchGoods()
|
|
|
50
|
- }
|
5
|
+ /**
|
|
|
6
|
+ * 页面的初始数据
|
|
|
7
|
+ */
|
|
|
8
|
+ data: {
|
|
|
9
|
+ imgUrl: app.globalData.imgUrl,
|
|
|
10
|
+ shoucang: false,
|
|
|
11
|
+ active: true,
|
|
|
12
|
+ show: false,
|
|
|
13
|
+ shows: false,
|
|
|
14
|
+ id: 0,
|
|
|
15
|
+ goods: [],
|
|
|
16
|
+ ids: [],
|
|
|
17
|
+ idss: [],
|
|
|
18
|
+ status: 0,
|
|
|
19
|
+ cart_count: 0,
|
|
|
20
|
+ skuid: '',
|
|
|
21
|
+ num: 1,
|
|
|
22
|
+ id_arr: [],
|
|
|
23
|
+ gPrice: 0,
|
|
|
24
|
+ collocation: [],
|
|
|
25
|
+ goods_star: 1,
|
|
|
26
|
+ star_arr: [],
|
|
|
27
|
+ commentCount: 0,
|
|
|
28
|
+ favorite: 0,
|
|
|
29
|
+ totalPrice: 0,
|
|
|
30
|
+ gPrice: 0,
|
|
|
31
|
+ is_group: 0,
|
|
|
32
|
+ packageList: [],
|
|
|
33
|
+ showList: [],
|
|
|
34
|
+ showMore: false,
|
|
|
35
|
+ show1: false,
|
|
|
36
|
+ goods1: {},
|
|
|
37
|
+ origin: 0,
|
|
|
38
|
+ skuid_arr: [],
|
|
|
39
|
+ is_vip: 0,
|
|
|
40
|
+ countn: null
|
|
|
41
|
+ },
|
|
|
42
|
+ fetchVip() {
|
|
|
43
|
+ let url = '/wxapp/user/index'
|
|
|
44
|
+ app.post(url).then(r => {
|
|
|
45
|
+ if (r.code == 1) {
|
|
|
46
|
+ console.log(r)
|
|
|
47
|
+ this.setData({
|
|
|
48
|
+ is_vip: r.data.user.is_vip
|
51
|
})
|
49
|
})
|
52
|
- },
|
|
|
53
|
- //进入评论列表
|
|
|
54
|
- jump_user_comment(e) {
|
|
|
55
|
- let id = e.currentTarget.dataset.id
|
|
|
56
|
- wx.navigateTo({
|
|
|
57
|
- url: '../user_comment/user_comment?id=' + this.data.id
|
50
|
+ this.fetchGoods()
|
|
|
51
|
+ }
|
|
|
52
|
+ })
|
|
|
53
|
+ },
|
|
|
54
|
+ //进入评论列表
|
|
|
55
|
+ jump_user_comment(e) {
|
|
|
56
|
+ let id = e.currentTarget.dataset.id
|
|
|
57
|
+ wx.navigateTo({
|
|
|
58
|
+ url: '../user_comment/user_comment?id=' + this.data.id
|
|
|
59
|
+ })
|
|
|
60
|
+ },
|
|
|
61
|
+ //进入商品详情
|
|
|
62
|
+ goDetail(e) {
|
|
|
63
|
+ wx.navigateTo({
|
|
|
64
|
+ url: '../goodsDetials/goodsDetials?id=' + e.currentTarget.dataset.id
|
|
|
65
|
+ })
|
|
|
66
|
+ },
|
|
|
67
|
+ //减少数量
|
|
|
68
|
+ dec_num() {
|
|
|
69
|
+ var num = this.data.num;
|
|
|
70
|
+ if (num <= 1) {
|
|
|
71
|
+ return;
|
|
|
72
|
+ } else {
|
|
|
73
|
+ num--
|
|
|
74
|
+ }
|
|
|
75
|
+ this.setData({
|
|
|
76
|
+ num: num
|
|
|
77
|
+ });
|
|
|
78
|
+ this.totalPrice()
|
|
|
79
|
+ },
|
|
|
80
|
+ //增加数量
|
|
|
81
|
+ add_num() {
|
|
|
82
|
+ var num = this.data.num;
|
|
|
83
|
+ num++
|
|
|
84
|
+ this.setData({
|
|
|
85
|
+ num: num
|
|
|
86
|
+ });
|
|
|
87
|
+ this.totalPrice();
|
|
|
88
|
+ },
|
|
|
89
|
+ //总价格
|
|
|
90
|
+ totalPrice() {
|
|
|
91
|
+ var that = this
|
|
|
92
|
+ var total = that.data.goods.info.price * that.data.num
|
|
|
93
|
+ that.setData({
|
|
|
94
|
+ totalPrice: total
|
|
|
95
|
+ })
|
|
|
96
|
+ },
|
|
|
97
|
+ //点击收藏
|
|
|
98
|
+ collection_true(e) {
|
|
|
99
|
+ let id = e.currentTarget.dataset.id
|
|
|
100
|
+ let that = this
|
|
|
101
|
+ let url = '/wxapp/cookbook_package/setFavorites?id=' + id
|
|
|
102
|
+ let params = {
|
|
|
103
|
+ id: id
|
|
|
104
|
+ }
|
|
|
105
|
+ app.post(url).then(r => {
|
|
|
106
|
+ if (r.code == 1) {
|
|
|
107
|
+ wx.showToast({
|
|
|
108
|
+ title: r.msg,
|
|
|
109
|
+ icon: 'none'
|
58
|
})
|
110
|
})
|
59
|
- },
|
|
|
60
|
- //进入商品详情
|
|
|
61
|
- goDetail(e) {
|
|
|
62
|
- wx.navigateTo({
|
|
|
63
|
- url: '../goodsDetials/goodsDetials?id=' + e.currentTarget.dataset.id
|
111
|
+ that.fetchGoods();
|
|
|
112
|
+ }
|
|
|
113
|
+ })
|
|
|
114
|
+ },
|
|
|
115
|
+ //促销进商品详情
|
|
|
116
|
+ jump_goodsDetial2(e) {
|
|
|
117
|
+ wx.navigateTo({
|
|
|
118
|
+ url: '../goodsDetial2/goodsDetial2?id=' + e.currentTarget.dataset.id
|
|
|
119
|
+ })
|
|
|
120
|
+ },
|
|
|
121
|
+ //关闭弹窗
|
|
|
122
|
+ close_mask_carts() {
|
|
|
123
|
+ this.setData({
|
|
|
124
|
+ shows: false
|
|
|
125
|
+ });
|
|
|
126
|
+ },
|
|
|
127
|
+ //根据id获取内容
|
|
|
128
|
+ fetchGoods() {
|
|
|
129
|
+ let url = '/wxapp/cookbook_package/getPackageInfo';
|
|
|
130
|
+ let params = {
|
|
|
131
|
+ id: this.data.id
|
|
|
132
|
+ };
|
|
|
133
|
+ let that = this
|
|
|
134
|
+ let showList = []
|
|
|
135
|
+ let arr1 = []
|
|
|
136
|
+ let skuid1 = 0
|
|
|
137
|
+ let skuid_price1 = 0
|
|
|
138
|
+ let old_skuid_price1 = 0
|
|
|
139
|
+ let skuid_arr = that.data.skuid_arr;
|
|
|
140
|
+ let is_vip = that.data.is_vip
|
|
|
141
|
+ console.log(is_vip + 'shibushis')
|
|
|
142
|
+ app.post(url, params).then(r => {
|
|
|
143
|
+ // console.log(r);
|
|
|
144
|
+ r.data.list.forEach(function(ele, indexxx) {
|
|
|
145
|
+ if (is_vip == 1) {
|
|
|
146
|
+ ele.ggprice = ele.vip_price
|
|
|
147
|
+ } else {
|
|
|
148
|
+ ele.ggprice = ele.price
|
|
|
149
|
+ }
|
|
|
150
|
+ if (ele.is_default == 1) {
|
|
|
151
|
+ showList.push(ele)
|
|
|
152
|
+ }
|
|
|
153
|
+ ele.t = false
|
|
|
154
|
+ if (indexxx < r.data.info.num) {
|
|
|
155
|
+ ele.t = true
|
|
|
156
|
+ }
|
|
|
157
|
+ ele.attr.attr_sku.forEach(function(eles, indexxxx) {
|
|
|
158
|
+ for (let i = 0; i < eles.item.length; i++) {
|
|
|
159
|
+ eles.item[i].t = false
|
|
|
160
|
+ eles.item[0].t = true;
|
|
|
161
|
+ arr1.push(eles.item[0].id)
|
|
|
162
|
+ }
|
64
|
})
|
163
|
})
|
65
|
- },
|
|
|
66
|
- //减少数量
|
|
|
67
|
- dec_num() {
|
|
|
68
|
- var num = this.data.num;
|
|
|
69
|
- if (num <= 1) {
|
|
|
70
|
- return;
|
164
|
+ arr1.sort();
|
|
|
165
|
+ let arr2 = [...new Set(arr1)]
|
|
|
166
|
+ ele.arr = arr2
|
|
|
167
|
+ let str1 = arr2.join('_');
|
|
|
168
|
+ let sys_attrprice1 = r.data.list[indexxx].sys_attrprice
|
|
|
169
|
+
|
|
|
170
|
+ if (ele.attr.attr_sku.length == 0) {
|
|
|
171
|
+ return;
|
71
|
} else {
|
172
|
} else {
|
72
|
- num--
|
173
|
+ for (let i in sys_attrprice1) {
|
|
|
174
|
+ if (i == str1) {
|
|
|
175
|
+ skuid1 = sys_attrprice1[i].skuid
|
|
|
176
|
+ skuid_price1 = sys_attrprice1[i].price
|
|
|
177
|
+ old_skuid_price1 = sys_attrprice1[i].old_price
|
|
|
178
|
+ }
|
|
|
179
|
+ }
|
73
|
}
|
180
|
}
|
74
|
- this.setData({
|
|
|
75
|
- num: num
|
181
|
+ ele.ggid = skuid1
|
|
|
182
|
+ if (ele.ggid) {
|
|
|
183
|
+ skuid_arr.push(skuid1)
|
|
|
184
|
+ }
|
|
|
185
|
+ str1 = ''
|
|
|
186
|
+ arr1 = []
|
|
|
187
|
+ })
|
|
|
188
|
+ if (r.data.groupType) {
|
|
|
189
|
+ var days = ''
|
|
|
190
|
+ var hours = ''
|
|
|
191
|
+ var minutes = ''
|
|
|
192
|
+ var seconds = ''
|
|
|
193
|
+ var percent = 0
|
|
|
194
|
+
|
|
|
195
|
+ function time() {
|
|
|
196
|
+ var cut_time = r.data.groupType.count_down_time
|
|
|
197
|
+ days = Math.floor((cut_time) / (60 * 60 * 24));
|
|
|
198
|
+ hours = Math.floor((cut_time) / (60 * 60)) % 24;
|
|
|
199
|
+ minutes = Math.floor((cut_time) / (60)) % 60;
|
|
|
200
|
+ seconds = cut_time % 60;
|
|
|
201
|
+ percent = Math.floor(r.data.info.group_number * 100 / r.data.info.group_min_number)
|
|
|
202
|
+ }
|
|
|
203
|
+ time();
|
|
|
204
|
+ // setInterval(time, 1000);
|
|
|
205
|
+ that.setData({
|
|
|
206
|
+ day: days,
|
|
|
207
|
+ hour: hours,
|
|
|
208
|
+ minute: minutes,
|
|
|
209
|
+ second: seconds,
|
|
|
210
|
+ percent: percent,
|
|
|
211
|
+ goods: r.data,
|
|
|
212
|
+ gPrice: r.data.info.price,
|
|
|
213
|
+ collocation: r.data.collocation,
|
|
|
214
|
+ comment: r.data.comment,
|
|
|
215
|
+ // star_arr: star_arr,
|
|
|
216
|
+ is_group: r.data.info.group_min_number,
|
|
|
217
|
+ countn: r.data.info.num
|
76
|
});
|
218
|
});
|
77
|
- this.totalPrice()
|
|
|
78
|
- },
|
|
|
79
|
- //增加数量
|
|
|
80
|
- add_num() {
|
|
|
81
|
- var num = this.data.num;
|
|
|
82
|
- num++
|
|
|
83
|
- this.setData({
|
|
|
84
|
- num: num
|
219
|
+ } else {
|
|
|
220
|
+ that.setData({
|
|
|
221
|
+ goods: r.data,
|
|
|
222
|
+ gPrice: r.data.info.price,
|
|
|
223
|
+ // comment: r.data.comment,
|
|
|
224
|
+ packageList: r.data.list,
|
|
|
225
|
+ showList: showList,
|
|
|
226
|
+ countn: r.data.info.num
|
85
|
});
|
227
|
});
|
86
|
- this.totalPrice();
|
|
|
87
|
- },
|
|
|
88
|
- //总价格
|
|
|
89
|
- totalPrice() {
|
|
|
90
|
- var that = this
|
|
|
91
|
- var total = that.data.goods.info.price * that.data.num
|
228
|
+ }
|
|
|
229
|
+ });
|
|
|
230
|
+ },
|
|
|
231
|
+ //渲染评论列表
|
|
|
232
|
+ fetchCommentList() {
|
|
|
233
|
+ let url = '/wxapp/product/comment?id=' + this.data.id
|
|
|
234
|
+ app.post(url).then(r => {
|
|
|
235
|
+ this.setData({
|
|
|
236
|
+ commentCount: r.data.length
|
|
|
237
|
+ });
|
|
|
238
|
+ })
|
|
|
239
|
+ },
|
|
|
240
|
+ //点击更换菜品
|
|
|
241
|
+ replaceDishes() {
|
|
|
242
|
+ this.setData({
|
|
|
243
|
+ showMore: true
|
|
|
244
|
+ })
|
|
|
245
|
+ wx.pageScrollTo({
|
|
|
246
|
+ scrollTop: 0,
|
|
|
247
|
+ })
|
|
|
248
|
+ },
|
|
|
249
|
+
|
|
|
250
|
+ /**
|
|
|
251
|
+ * 生命周期函数--监听页面加载
|
|
|
252
|
+ */
|
|
|
253
|
+ onLoad: function(options) {
|
|
|
254
|
+ console.log(options)
|
|
|
255
|
+ this.fetchVip();
|
|
|
256
|
+ var query = wx.createSelectorQuery();
|
|
|
257
|
+ var offset = query.select('.itme_list5');
|
|
|
258
|
+ this.setData({
|
|
|
259
|
+ id: options.id
|
|
|
260
|
+ });
|
|
|
261
|
+ // this.fetchGoods();
|
|
|
262
|
+ this.fetchCommentList();
|
|
|
263
|
+ },
|
|
|
264
|
+ // 返回上一页
|
|
|
265
|
+ get_back() {
|
|
|
266
|
+ wx.navigateBack({})
|
|
|
267
|
+ },
|
|
|
268
|
+ //弹框返回
|
|
|
269
|
+ closeShowMore() {
|
|
|
270
|
+ let that = this
|
|
|
271
|
+ let goods = that.data.goods
|
|
|
272
|
+ let num = goods.info.num
|
|
|
273
|
+ let showList = []
|
|
|
274
|
+ let n = 0
|
|
|
275
|
+ goods.list.forEach(function(ele, index) {
|
|
|
276
|
+ if (ele.t) {
|
|
|
277
|
+ showList.push(ele)
|
|
|
278
|
+ n++;
|
|
|
279
|
+ }
|
|
|
280
|
+ })
|
|
|
281
|
+ if ((n < goods.info.num && n >= 0) || n > goods.info.num) {
|
|
|
282
|
+ wx.showToast({
|
|
|
283
|
+ title: '您最多能选择' + num + '种商品',
|
|
|
284
|
+ icon: 'none'
|
|
|
285
|
+ })
|
|
|
286
|
+ return;
|
|
|
287
|
+ } else {
|
|
|
288
|
+ if (showList.length == 0) {
|
92
|
that.setData({
|
289
|
that.setData({
|
93
|
- totalPrice: total
|
|
|
94
|
- })
|
|
|
95
|
- },
|
|
|
96
|
- //点击收藏
|
|
|
97
|
- collection_true(e) {
|
|
|
98
|
- let id = e.currentTarget.dataset.id
|
|
|
99
|
- let that = this
|
|
|
100
|
- let url = '/wxapp/cookbook_package/setFavorites?id=' + id
|
|
|
101
|
- let params = {
|
|
|
102
|
- id: id
|
|
|
103
|
- }
|
|
|
104
|
- app.post(url).then(r => {
|
|
|
105
|
- if (r.code == 1) {
|
|
|
106
|
- wx.showToast({
|
|
|
107
|
- title: r.msg,
|
|
|
108
|
- icon: 'none'
|
|
|
109
|
- })
|
|
|
110
|
- that.fetchGoods();
|
|
|
111
|
- }
|
290
|
+ showMore: false,
|
112
|
})
|
291
|
})
|
113
|
- },
|
|
|
114
|
- //促销进商品详情
|
|
|
115
|
- jump_goodsDetial2(e) {
|
|
|
116
|
- wx.navigateTo({
|
|
|
117
|
- url: '../goodsDetial2/goodsDetial2?id=' + e.currentTarget.dataset.id
|
292
|
+ } else {
|
|
|
293
|
+ that.setData({
|
|
|
294
|
+ showMore: false,
|
|
|
295
|
+ showList: showList
|
118
|
})
|
296
|
})
|
119
|
- },
|
|
|
120
|
- //关闭弹窗
|
|
|
121
|
- close_mask_carts() {
|
|
|
122
|
- this.setData({
|
|
|
123
|
- shows: false
|
|
|
124
|
- });
|
|
|
125
|
- },
|
|
|
126
|
- //根据id获取内容
|
|
|
127
|
- fetchGoods() {
|
|
|
128
|
- let url = '/wxapp/cookbook_package/getPackageInfo';
|
|
|
129
|
- let params = {
|
|
|
130
|
- id: this.data.id
|
|
|
131
|
- };
|
|
|
132
|
- let that = this
|
|
|
133
|
- let showList = []
|
|
|
134
|
- let arr1 = []
|
|
|
135
|
- let skuid1 = 0
|
|
|
136
|
- let skuid_price1 = 0
|
|
|
137
|
- let old_skuid_price1 = 0
|
|
|
138
|
- let skuid_arr = that.data.skuid_arr;
|
|
|
139
|
- let is_vip = that.data.is_vip
|
|
|
140
|
- console.log(is_vip + 'shibushis')
|
|
|
141
|
- app.post(url, params).then(r => {
|
|
|
142
|
- // console.log(r);
|
|
|
143
|
- r.data.list.forEach(function (ele, indexxx) {
|
|
|
144
|
- if (is_vip == 1) {
|
|
|
145
|
- ele.ggprice = ele.vip_price
|
|
|
146
|
- } else {
|
|
|
147
|
- ele.ggprice = ele.price
|
|
|
148
|
- }
|
|
|
149
|
- if (ele.is_default == 1) {
|
|
|
150
|
- showList.push(ele)
|
|
|
151
|
- }
|
|
|
152
|
- ele.t = false
|
|
|
153
|
- if(indexxx<r.data.info.num){
|
|
|
154
|
- ele.t=true
|
|
|
155
|
- }
|
|
|
156
|
- ele.attr.attr_sku.forEach(function (eles, indexxxx) {
|
|
|
157
|
- for (let i = 0; i < eles.item.length; i++) {
|
|
|
158
|
- eles.item[i].t = false
|
|
|
159
|
- eles.item[0].t = true;
|
|
|
160
|
- arr1.push(eles.item[0].id)
|
|
|
161
|
- }
|
|
|
162
|
- })
|
|
|
163
|
- arr1.sort();
|
|
|
164
|
- let arr2 = [...new Set(arr1)]
|
|
|
165
|
- ele.arr = arr2
|
|
|
166
|
- let str1 = arr2.join('_');
|
|
|
167
|
- let sys_attrprice1 = r.data.list[indexxx].sys_attrprice
|
|
|
168
|
-
|
|
|
169
|
- if (ele.attr.attr_sku.length == 0) {
|
|
|
170
|
- return;
|
|
|
171
|
- } else {
|
|
|
172
|
- for (let i in sys_attrprice1) {
|
|
|
173
|
- if (i == str1) {
|
|
|
174
|
- skuid1 = sys_attrprice1[i].skuid
|
|
|
175
|
- skuid_price1 = sys_attrprice1[i].price
|
|
|
176
|
- old_skuid_price1 = sys_attrprice1[i].old_price
|
|
|
177
|
- }
|
|
|
178
|
- }
|
|
|
179
|
- }
|
|
|
180
|
- ele.ggid = skuid1
|
|
|
181
|
- if (ele.ggid) {
|
|
|
182
|
- skuid_arr.push(skuid1)
|
|
|
183
|
- }
|
|
|
184
|
- str1 = ''
|
|
|
185
|
- arr1 = []
|
|
|
186
|
- })
|
|
|
187
|
- if (r.data.groupType) {
|
|
|
188
|
- var days = ''
|
|
|
189
|
- var hours = ''
|
|
|
190
|
- var minutes = ''
|
|
|
191
|
- var seconds = ''
|
|
|
192
|
- var percent = 0
|
|
|
193
|
- function time() {
|
|
|
194
|
- var cut_time = r.data.groupType.count_down_time
|
|
|
195
|
- days = Math.floor((cut_time) / (60 * 60 * 24));
|
|
|
196
|
- hours = Math.floor((cut_time) / (60 * 60)) % 24;
|
|
|
197
|
- minutes = Math.floor((cut_time) / (60)) % 60;
|
|
|
198
|
- seconds = cut_time % 60;
|
|
|
199
|
- percent = Math.floor(r.data.info.group_number * 100 / r.data.info.group_min_number)
|
297
|
+ }
|
|
|
298
|
+ }
|
|
|
299
|
+ },
|
|
|
300
|
+ //attr选择规格
|
|
|
301
|
+ chooseStandard(e) {
|
|
|
302
|
+ let origin = e.currentTarget.dataset.origin
|
|
|
303
|
+ if (e.currentTarget.dataset.shop.attr.attr_sku.length == 0) {
|
|
|
304
|
+ wx.showToast({
|
|
|
305
|
+ title: '暂无规格',
|
|
|
306
|
+ icon: "none",
|
|
|
307
|
+ duration: 1300
|
|
|
308
|
+ })
|
|
|
309
|
+ } else {
|
|
|
310
|
+ this.setData({
|
|
|
311
|
+ goods1: e.currentTarget.dataset.shop,
|
|
|
312
|
+ show1: true,
|
|
|
313
|
+ origin: origin,
|
|
|
314
|
+ });
|
|
|
315
|
+ }
|
|
|
316
|
+ },
|
|
|
317
|
+ //关闭弹框
|
|
|
318
|
+ close_mask_cart1() {
|
|
|
319
|
+ this.setData({
|
|
|
320
|
+ show1: false
|
|
|
321
|
+ })
|
|
|
322
|
+ },
|
|
|
323
|
+ //加购筛选
|
|
|
324
|
+ changeIds1(e) {
|
|
|
325
|
+ let t = this;
|
|
|
326
|
+ let goods = t.data.showList;
|
|
|
327
|
+ let iindex = e.currentTarget.dataset.origin
|
|
|
328
|
+ //父级索引
|
|
|
329
|
+ let parent = e.currentTarget.dataset.parent
|
|
|
330
|
+ goods.forEach(function(ele, index) {
|
|
|
331
|
+ if (iindex == index) {
|
|
|
332
|
+ let new_arr = ele.arr
|
|
|
333
|
+ let listAll = ele.attr.attr_sku;
|
|
|
334
|
+ // 父级索引
|
|
|
335
|
+ let x = e.currentTarget.dataset.index;
|
|
|
336
|
+ // 当前点击Id
|
|
|
337
|
+ let nowId = e.currentTarget.dataset.gid;
|
|
|
338
|
+ //当前点击value
|
|
|
339
|
+ let nowValue = e.currentTarget.dataset.item;
|
|
|
340
|
+ // 子集索引
|
|
|
341
|
+ let nowIndex = e.currentTarget.dataset.index;
|
|
|
342
|
+ // 当前可否多选
|
|
|
343
|
+ let is_checkMore = false
|
|
|
344
|
+ let foo = new_arr.indexOf(nowId)
|
|
|
345
|
+ if (foo > -1) {
|
|
|
346
|
+ new_arr.splice(foo, 1)
|
|
|
347
|
+ } else {
|
|
|
348
|
+ ele.attr.attr_sku.forEach(function(eles, indexxxx) {
|
|
|
349
|
+ if (indexxxx == parent) {
|
|
|
350
|
+ for (let i = 0; i < eles.item.length; i++) {
|
|
|
351
|
+ let havId = ele.attr.attr_sku[indexxxx].item[i].id
|
|
|
352
|
+ let have = new_arr.indexOf(havId)
|
|
|
353
|
+ if (have > -1) {
|
|
|
354
|
+ new_arr.splice(have, 1)
|
200
|
}
|
355
|
}
|
201
|
- time();
|
|
|
202
|
- // setInterval(time, 1000);
|
|
|
203
|
- that.setData({
|
|
|
204
|
- day: days,
|
|
|
205
|
- hour: hours,
|
|
|
206
|
- minute: minutes,
|
|
|
207
|
- second: seconds,
|
|
|
208
|
- percent: percent,
|
|
|
209
|
- goods: r.data,
|
|
|
210
|
- gPrice: r.data.info.price,
|
|
|
211
|
- collocation: r.data.collocation,
|
|
|
212
|
- comment: r.data.comment,
|
|
|
213
|
- // star_arr: star_arr,
|
|
|
214
|
- is_group: r.data.info.group_min_number
|
|
|
215
|
- });
|
|
|
216
|
- } else {
|
|
|
217
|
- that.setData({
|
|
|
218
|
- goods: r.data,
|
|
|
219
|
- gPrice: r.data.info.price,
|
|
|
220
|
- // comment: r.data.comment,
|
|
|
221
|
- packageList: r.data.list,
|
|
|
222
|
- showList: showList
|
|
|
223
|
- });
|
356
|
+ }
|
224
|
}
|
357
|
}
|
225
|
- });
|
|
|
226
|
- },
|
|
|
227
|
- //渲染评论列表
|
|
|
228
|
- fetchCommentList() {
|
|
|
229
|
- let url = '/wxapp/product/comment?id=' + this.data.id
|
|
|
230
|
- app.post(url).then(r => {
|
|
|
231
|
- this.setData({
|
|
|
232
|
- commentCount: r.data.length
|
|
|
233
|
- });
|
|
|
234
|
- })
|
|
|
235
|
- },
|
|
|
236
|
- //点击更换菜品
|
|
|
237
|
- replaceDishes() {
|
|
|
238
|
- this.setData({
|
|
|
239
|
- showMore: true
|
358
|
+ })
|
|
|
359
|
+ }
|
|
|
360
|
+ // 当前点击父级值
|
|
|
361
|
+ let tempArry = JSON.parse(JSON.stringify(ele.attr.attr_sku[parent]));
|
|
|
362
|
+ !tempArry.chooseIndex ? tempArry.chooseIndex = [] : '';
|
|
|
363
|
+ // 是否多选
|
|
|
364
|
+ if (is_checkMore) {} else {
|
|
|
365
|
+ tempArry.chooseIndex.pop();
|
|
|
366
|
+ tempArry.chooseIndex.push(nowId);
|
|
|
367
|
+ for (let obj of tempArry.item) {
|
|
|
368
|
+ obj.t = false
|
|
|
369
|
+ }
|
|
|
370
|
+ tempArry.item[nowIndex].t = true;
|
|
|
371
|
+ }
|
|
|
372
|
+ ele.attr.attr_sku[parent] = tempArry;
|
|
|
373
|
+ }
|
|
|
374
|
+ })
|
|
|
375
|
+ t.setData({
|
|
|
376
|
+ goods1: goods[iindex]
|
|
|
377
|
+ })
|
|
|
378
|
+ // let goods = t.data.goodsList;
|
|
|
379
|
+ goods.forEach(function(ele, indexaa) {
|
|
|
380
|
+ if (iindex == indexaa) {
|
|
|
381
|
+ let new_arr = ele.arr
|
|
|
382
|
+ let sys_attrprice = goods[indexaa].sys_attrprice;
|
|
|
383
|
+ let new_arr_item = [];
|
|
|
384
|
+ let str = ''
|
|
|
385
|
+ let skuid = 0
|
|
|
386
|
+ let skuid_price = 0
|
|
|
387
|
+ let old_skuid_price = 0
|
|
|
388
|
+ let vip_skuid_price = 0
|
|
|
389
|
+ ele.attr.attr_sku.forEach(function(eles, indexx) {
|
|
|
390
|
+ if (indexx == parent) {
|
|
|
391
|
+ new_arr = new_arr.concat(eles.chooseIndex);
|
|
|
392
|
+ }
|
240
|
})
|
393
|
})
|
241
|
- wx.pageScrollTo({
|
|
|
242
|
- scrollTop: 0,
|
394
|
+ new_arr = new_arr.sort()
|
|
|
395
|
+ str = new_arr.join('_')
|
|
|
396
|
+ ele.arr = new_arr
|
|
|
397
|
+ t.setData({
|
|
|
398
|
+ goodsList: goods
|
243
|
})
|
399
|
})
|
244
|
- },
|
400
|
+ new_arr_item = new_arr_item.join(',');
|
|
|
401
|
+ new_arr_item = new_arr_item.replace(/,/g, " ");
|
|
|
402
|
+ for (let i in sys_attrprice) {
|
|
|
403
|
+ if (i == str) {
|
|
|
404
|
+ skuid = sys_attrprice[i].skuid
|
|
|
405
|
+ skuid_price = sys_attrprice[i].price
|
|
|
406
|
+ old_skuid_price = sys_attrprice[i].old_price
|
|
|
407
|
+ vip_skuid_price = sys_attrprice[i].vip_price
|
245
|
|
408
|
|
246
|
- /**
|
|
|
247
|
- * 生命周期函数--监听页面加载
|
|
|
248
|
- */
|
|
|
249
|
- onLoad: function (options) {
|
|
|
250
|
- console.log(options)
|
|
|
251
|
- this.fetchVip();
|
|
|
252
|
- var query = wx.createSelectorQuery();
|
|
|
253
|
- var offset = query.select('.itme_list5');
|
|
|
254
|
- this.setData({
|
|
|
255
|
- id: options.id
|
|
|
256
|
- });
|
|
|
257
|
- // this.fetchGoods();
|
|
|
258
|
- this.fetchCommentList();
|
|
|
259
|
- },
|
|
|
260
|
- // 返回上一页
|
|
|
261
|
- get_back() {
|
|
|
262
|
- wx.navigateBack({})
|
|
|
263
|
- },
|
|
|
264
|
- //弹框返回
|
|
|
265
|
- closeShowMore() {
|
|
|
266
|
- let that = this
|
|
|
267
|
- let goods = that.data.goods
|
|
|
268
|
- let num = goods.info.num
|
|
|
269
|
- let showList = []
|
|
|
270
|
- let n = 0
|
|
|
271
|
- goods.list.forEach(function (ele, index) {
|
|
|
272
|
- if (ele.t) {
|
|
|
273
|
- showList.push(ele)
|
|
|
274
|
- n++;
|
|
|
275
|
- }
|
|
|
276
|
- })
|
|
|
277
|
- if ((n < goods.info.num && n > 0) || n > goods.info.num) {
|
|
|
278
|
- wx.showToast({
|
|
|
279
|
- title: '您最多只能选择' + num + '种商品',
|
|
|
280
|
- icon: 'none'
|
|
|
281
|
- })
|
|
|
282
|
- return;
|
|
|
283
|
- } else {
|
|
|
284
|
- if (showList.length == 0) {
|
|
|
285
|
- that.setData({
|
|
|
286
|
- showMore: false,
|
|
|
287
|
- })
|
409
|
+ ele.ggid = skuid;
|
|
|
410
|
+ var ggprice = 0
|
|
|
411
|
+ if (t.data.is_vip == 1) {
|
|
|
412
|
+ ggprice = vip_skuid_price
|
288
|
} else {
|
413
|
} else {
|
289
|
- that.setData({
|
|
|
290
|
- showMore: false,
|
|
|
291
|
- showList: showList
|
|
|
292
|
- })
|
414
|
+ ggprice = skuid_price
|
293
|
}
|
415
|
}
|
|
|
416
|
+ ele.ggprice = ggprice
|
|
|
417
|
+ ele.arr = new_arr
|
|
|
418
|
+ }
|
294
|
}
|
419
|
}
|
295
|
- },
|
|
|
296
|
- //attr选择规格
|
|
|
297
|
- chooseStandard(e) {
|
|
|
298
|
- let origin = e.currentTarget.dataset.origin
|
|
|
299
|
- if (e.currentTarget.dataset.shop.attr.attr_sku.length == 0) {
|
420
|
+ }
|
|
|
421
|
+ })
|
|
|
422
|
+ t.setData({
|
|
|
423
|
+ goodsList: goods
|
|
|
424
|
+ })
|
|
|
425
|
+ console.log(101010101)
|
|
|
426
|
+ },
|
|
|
427
|
+ //skuid加入skuid_arr
|
|
|
428
|
+ hide_mask1(e) {
|
|
|
429
|
+ var skuid_arr = this.data.skuid_arr
|
|
|
430
|
+ var skuid1 = this.data.skuid1
|
|
|
431
|
+ var indexs = e.currentTarget.dataset.index
|
|
|
432
|
+ if (skuid1 != 0) {
|
|
|
433
|
+ // skuid_arr.push(skuid1)
|
|
|
434
|
+ }
|
|
|
435
|
+ var goods = this.data.showList
|
|
|
436
|
+ goods.forEach(function(ele, index) {
|
|
|
437
|
+ if (index == indexs) {
|
|
|
438
|
+ for (let i = 0; i < ele.attr.attr_sku.length; i++) {
|
|
|
439
|
+ if (ele.arr.length == 1) {
|
300
|
wx.showToast({
|
440
|
wx.showToast({
|
301
|
- title: '暂无规格',
|
|
|
302
|
- icon: "none",
|
|
|
303
|
- duration: 1300
|
441
|
+ title: '请选择全部属性',
|
|
|
442
|
+ icon: 'none'
|
304
|
})
|
443
|
})
|
305
|
- } else {
|
|
|
306
|
- this.setData({
|
|
|
307
|
- goods1: e.currentTarget.dataset.shop,
|
|
|
308
|
- show1: true,
|
|
|
309
|
- origin: origin,
|
|
|
310
|
- });
|
444
|
+ }
|
311
|
}
|
445
|
}
|
312
|
- },
|
|
|
313
|
- //关闭弹框
|
|
|
314
|
- close_mask_cart1() {
|
|
|
315
|
- this.setData({
|
|
|
316
|
- show1: false
|
|
|
317
|
- })
|
|
|
318
|
- },
|
|
|
319
|
- //加购筛选
|
|
|
320
|
- changeIds1(e) {
|
|
|
321
|
- let t = this;
|
|
|
322
|
- let goods = t.data.showList;
|
|
|
323
|
- let iindex = e.currentTarget.dataset.origin
|
|
|
324
|
- //父级索引
|
|
|
325
|
- let parent = e.currentTarget.dataset.parent
|
|
|
326
|
- goods.forEach(function (ele, index) {
|
|
|
327
|
- if (iindex == index) {
|
|
|
328
|
- let new_arr = ele.arr
|
|
|
329
|
- let listAll = ele.attr.attr_sku;
|
|
|
330
|
- // 父级索引
|
|
|
331
|
- let x = e.currentTarget.dataset.index;
|
|
|
332
|
- // 当前点击Id
|
|
|
333
|
- let nowId = e.currentTarget.dataset.gid;
|
|
|
334
|
- //当前点击value
|
|
|
335
|
- let nowValue = e.currentTarget.dataset.item;
|
|
|
336
|
- // 子集索引
|
|
|
337
|
- let nowIndex = e.currentTarget.dataset.index;
|
|
|
338
|
- // 当前可否多选
|
|
|
339
|
- let is_checkMore = false
|
|
|
340
|
- let foo = new_arr.indexOf(nowId)
|
|
|
341
|
- if (foo > -1) {
|
|
|
342
|
- new_arr.splice(foo, 1)
|
|
|
343
|
- } else {
|
|
|
344
|
- ele.attr.attr_sku.forEach(function (eles, indexxxx) {
|
|
|
345
|
- if (indexxxx == parent) {
|
|
|
346
|
- for (let i = 0; i < eles.item.length; i++) {
|
|
|
347
|
- let havId = ele.attr.attr_sku[indexxxx].item[i].id
|
|
|
348
|
- let have = new_arr.indexOf(havId)
|
|
|
349
|
- if (have > -1) {
|
|
|
350
|
- new_arr.splice(have, 1)
|
|
|
351
|
- }
|
|
|
352
|
- }
|
|
|
353
|
- }
|
|
|
354
|
- })
|
|
|
355
|
- }
|
|
|
356
|
- // 当前点击父级值
|
|
|
357
|
- let tempArry = JSON.parse(JSON.stringify(ele.attr.attr_sku[parent]));
|
|
|
358
|
- !tempArry.chooseIndex ? tempArry.chooseIndex = [] : '';
|
|
|
359
|
- // 是否多选
|
|
|
360
|
- if (is_checkMore) { } else {
|
|
|
361
|
- tempArry.chooseIndex.pop();
|
|
|
362
|
- tempArry.chooseIndex.push(nowId);
|
|
|
363
|
- for (let obj of tempArry.item) {
|
|
|
364
|
- obj.t = false
|
|
|
365
|
- }
|
|
|
366
|
- tempArry.item[nowIndex].t = true;
|
|
|
367
|
- }
|
|
|
368
|
- ele.attr.attr_sku[parent] = tempArry;
|
|
|
369
|
- }
|
|
|
370
|
- })
|
|
|
371
|
- t.setData({
|
|
|
372
|
- goods1: goods[iindex]
|
|
|
373
|
- })
|
|
|
374
|
- // let goods = t.data.goodsList;
|
|
|
375
|
- goods.forEach(function (ele, indexaa) {
|
|
|
376
|
- if (iindex == indexaa) {
|
|
|
377
|
- let new_arr = ele.arr
|
|
|
378
|
- let sys_attrprice = goods[indexaa].sys_attrprice;
|
|
|
379
|
- let new_arr_item = [];
|
|
|
380
|
- let str = ''
|
|
|
381
|
- let skuid = 0
|
|
|
382
|
- let skuid_price = 0
|
|
|
383
|
- let old_skuid_price = 0
|
|
|
384
|
- let vip_skuid_price = 0
|
|
|
385
|
- ele.attr.attr_sku.forEach(function (eles, indexx) {
|
|
|
386
|
- if (indexx == parent) {
|
|
|
387
|
- new_arr = new_arr.concat(eles.chooseIndex);
|
|
|
388
|
- }
|
|
|
389
|
- })
|
|
|
390
|
- new_arr = new_arr.sort()
|
|
|
391
|
- str = new_arr.join('_')
|
|
|
392
|
- ele.arr = new_arr
|
|
|
393
|
- t.setData({
|
|
|
394
|
- goodsList: goods
|
|
|
395
|
- })
|
|
|
396
|
- new_arr_item = new_arr_item.join(',');
|
|
|
397
|
- new_arr_item = new_arr_item.replace(/,/g, " ");
|
|
|
398
|
- for (let i in sys_attrprice) {
|
|
|
399
|
- if (i == str) {
|
|
|
400
|
- skuid = sys_attrprice[i].skuid
|
|
|
401
|
- skuid_price = sys_attrprice[i].price
|
|
|
402
|
- old_skuid_price = sys_attrprice[i].old_price
|
|
|
403
|
- vip_skuid_price = sys_attrprice[i].vip_price
|
|
|
404
|
-
|
|
|
405
|
- ele.ggid = skuid;
|
|
|
406
|
- var ggprice = 0
|
|
|
407
|
- if (t.data.is_vip == 1) {
|
|
|
408
|
- ggprice = vip_skuid_price
|
|
|
409
|
- } else {
|
|
|
410
|
- ggprice = skuid_price
|
|
|
411
|
- }
|
|
|
412
|
- ele.ggprice = ggprice
|
|
|
413
|
- ele.arr = new_arr
|
|
|
414
|
- }
|
|
|
415
|
- }
|
|
|
416
|
- }
|
|
|
417
|
- })
|
|
|
418
|
- t.setData({
|
|
|
419
|
- goodsList: goods
|
|
|
420
|
- })
|
|
|
421
|
- console.log(101010101)
|
|
|
422
|
- },
|
|
|
423
|
- //skuid加入skuid_arr
|
|
|
424
|
- hide_mask1(e) {
|
|
|
425
|
- var skuid_arr = this.data.skuid_arr
|
|
|
426
|
- var skuid1 = this.data.skuid1
|
|
|
427
|
- var indexs = e.currentTarget.dataset.index
|
|
|
428
|
- if (skuid1 != 0) {
|
|
|
429
|
- // skuid_arr.push(skuid1)
|
446
|
+ }
|
|
|
447
|
+ })
|
|
|
448
|
+ this.setData({
|
|
|
449
|
+ show1: false,
|
|
|
450
|
+ skuid_arr: skuid_arr
|
|
|
451
|
+ })
|
|
|
452
|
+ },
|
|
|
453
|
+ //立即购买
|
|
|
454
|
+ go_pay_sale() {
|
|
|
455
|
+ var that = this
|
|
|
456
|
+ var goodsList = that.data.showList
|
|
|
457
|
+ var skuid_arr = []
|
|
|
458
|
+ var total_price = 0
|
|
|
459
|
+ goodsList.forEach(function(ele, index) {
|
|
|
460
|
+ var skuid = ele.ggid
|
|
|
461
|
+ if (ele.ggprice) {
|
|
|
462
|
+ ele.ggprice = ele.ggprice.substring(0, ele.ggprice.length - 3)
|
|
|
463
|
+ }
|
|
|
464
|
+ var price = ele.ggprice * 1
|
|
|
465
|
+ if (ele.stock > 0) {
|
|
|
466
|
+ if (ele.ggid && ele.ggid != 0) {
|
|
|
467
|
+ total_price += price
|
|
|
468
|
+ skuid_arr.push(skuid)
|
|
|
469
|
+ } else {
|
|
|
470
|
+ wx.showToast({
|
|
|
471
|
+ title: '本件商品没有规格属性',
|
|
|
472
|
+ icon: 'none',
|
|
|
473
|
+ duration: 1000
|
|
|
474
|
+ })
|
|
|
475
|
+ ele.t = false
|
|
|
476
|
+ that.setData({
|
|
|
477
|
+ goodsList: goodsList
|
|
|
478
|
+ })
|
430
|
}
|
479
|
}
|
431
|
- var goods = this.data.showList
|
|
|
432
|
- goods.forEach(function (ele, index) {
|
|
|
433
|
- if (index == indexs) {
|
|
|
434
|
- for (let i = 0; i < ele.attr.attr_sku.length; i++) {
|
|
|
435
|
- if (ele.arr.length == 1) {
|
|
|
436
|
- wx.showToast({
|
|
|
437
|
- title: '请选择全部属性',
|
|
|
438
|
- icon: 'none'
|
|
|
439
|
- })
|
|
|
440
|
- }
|
|
|
441
|
- }
|
|
|
442
|
- }
|
|
|
443
|
- })
|
|
|
444
|
- this.setData({
|
|
|
445
|
- show1: false,
|
|
|
446
|
- skuid_arr: skuid_arr
|
|
|
447
|
- })
|
|
|
448
|
- },
|
|
|
449
|
- //立即购买
|
|
|
450
|
- go_pay_sale() {
|
|
|
451
|
- var that = this
|
|
|
452
|
- var goodsList = that.data.showList
|
|
|
453
|
- var skuid_arr = []
|
|
|
454
|
- var total_price = 0
|
|
|
455
|
- goodsList.forEach(function (ele, index) {
|
|
|
456
|
- var skuid = ele.ggid
|
|
|
457
|
- if (ele.ggprice) {
|
|
|
458
|
- ele.ggprice = ele.ggprice.substring(0, ele.ggprice.length - 3)
|
|
|
459
|
- }
|
|
|
460
|
- var price = ele.ggprice * 1
|
|
|
461
|
- if (ele.stock > 0) {
|
|
|
462
|
- if (ele.ggid && ele.ggid != 0) {
|
|
|
463
|
- total_price += price
|
|
|
464
|
- skuid_arr.push(skuid)
|
|
|
465
|
- } else {
|
|
|
466
|
- wx.showToast({
|
|
|
467
|
- title: '本件商品没有规格属性',
|
|
|
468
|
- icon: 'none',
|
|
|
469
|
- duration: 1000
|
|
|
470
|
- })
|
|
|
471
|
- ele.t = false
|
|
|
472
|
- that.setData({
|
|
|
473
|
- goodsList: goodsList
|
|
|
474
|
- })
|
|
|
475
|
- }
|
|
|
476
|
- } else {
|
|
|
477
|
- wx.showToast({
|
|
|
478
|
- title: '商品已卖完',
|
|
|
479
|
- icon: 'none'
|
|
|
480
|
- })
|
|
|
481
|
- }
|
|
|
482
|
- })
|
|
|
483
|
- console.log(total_price + "总价")
|
|
|
484
|
- wx.navigateTo({
|
|
|
485
|
- url: '../../my/settle_account/settle_account?pakSale=' + skuid_arr + '&pakId=' + that.data.goods.info.id
|
480
|
+ } else {
|
|
|
481
|
+ wx.showToast({
|
|
|
482
|
+ title: '商品已卖完',
|
|
|
483
|
+ icon: 'none'
|
486
|
})
|
484
|
})
|
487
|
- },
|
|
|
488
|
- //选区食品包
|
|
|
489
|
- changeFlag(e) {
|
|
|
490
|
- let indexs = e.currentTarget.dataset.index
|
|
|
491
|
- let that = this
|
|
|
492
|
- let list = that.data.packageList
|
|
|
493
|
- let n=0
|
|
|
494
|
- list.forEach(function (ele, index) {
|
|
|
495
|
- if (indexs == index) {
|
|
|
496
|
- ele.t = !ele.t
|
|
|
497
|
- }
|
|
|
498
|
- if(ele.t){
|
|
|
499
|
- n++
|
|
|
500
|
- }
|
|
|
501
|
- if(n>that.data.goods.info.num){
|
|
|
502
|
- wx.showToast({
|
|
|
503
|
- title: '您最多可选择'+that.data.goods.info.num+'种商品',
|
|
|
504
|
- icon:'none'
|
|
|
505
|
- })
|
|
|
506
|
- }
|
|
|
507
|
- })
|
|
|
508
|
- that.setData({
|
|
|
509
|
- packageList: list
|
|
|
510
|
- })
|
|
|
511
|
- },
|
|
|
512
|
- // 跳转图文食谱
|
|
|
513
|
- get_recipe() {
|
|
|
514
|
- wx.navigateTo({
|
|
|
515
|
- url: '../production_steps/production_steps?id=' + this.data.id,
|
|
|
516
|
- })
|
|
|
517
|
- },
|
|
|
518
|
- // 跳转购物车
|
|
|
519
|
- get_car() {
|
|
|
520
|
- this.setData({
|
|
|
521
|
- show: true
|
|
|
522
|
- });
|
|
|
523
|
- },
|
|
|
524
|
- //隐藏mask
|
|
|
525
|
- hide_masks() {
|
|
|
526
|
- var that = this
|
|
|
527
|
- if (that.data.skuid != '') {
|
|
|
528
|
- that.setData({
|
|
|
529
|
- shows: false
|
|
|
530
|
- });
|
|
|
531
|
- var str = ''
|
|
|
532
|
- str = that.data.id_arr.join(',');
|
|
|
533
|
- if (that.data.id_arr.length > 1) {
|
|
|
534
|
- var gPrice = that.data.num * that.data.gPrice
|
|
|
535
|
- console.log(gPrice);
|
|
|
536
|
- if (that.data.is_group == 0) {
|
|
|
537
|
- wx.navigateTo({
|
|
|
538
|
- url: '../../my/settle_account/settle_account?ids=' + that.data.skuid + '&gid=' + that.data.id + '&num=' + that.data.num + '&gPrice=' + gPrice
|
|
|
539
|
- })
|
|
|
540
|
- } else {
|
|
|
541
|
- wx.navigateTo({
|
|
|
542
|
- url: '../../my/settle_account/settle_account?ids=' + that.data.skuid + '&gid=' + that.data.id + '&num=' + that.data.num + '&gPrice=' + gPrice + '&is_group=' + that.data.is_group
|
|
|
543
|
- })
|
|
|
544
|
- }
|
|
|
545
|
- }
|
|
|
546
|
- } else {
|
485
|
+ }
|
|
|
486
|
+ })
|
|
|
487
|
+ console.log(total_price + "总价")
|
|
|
488
|
+ wx.navigateTo({
|
|
|
489
|
+ url: '../../my/settle_account/settle_account?pakSale=' + skuid_arr + '&pakId=' + that.data.goods.info.id
|
|
|
490
|
+ })
|
|
|
491
|
+ },
|
|
|
492
|
+ //选区食品包
|
|
|
493
|
+ changeFlag(e) {
|
|
|
494
|
+ let indexs = e.currentTarget.dataset.index
|
|
|
495
|
+ let that = this
|
|
|
496
|
+ let list = that.data.packageList
|
|
|
497
|
+ let n = that.data.countn
|
|
|
498
|
+ list.forEach(function(ele, index) {
|
|
|
499
|
+ if (indexs == index) {
|
|
|
500
|
+ if(ele.t){
|
|
|
501
|
+ n--
|
|
|
502
|
+ ele.t=false
|
|
|
503
|
+ }else{
|
|
|
504
|
+ n++
|
|
|
505
|
+ if(n>that.data.goods.info.num){
|
547
|
wx.showToast({
|
506
|
wx.showToast({
|
548
|
- title: '请先选择商品属性组合',
|
|
|
549
|
- icon: 'none'
|
507
|
+ title: '您最多选择'+that.data.goods.info.num+'种商品',
|
|
|
508
|
+ icon:'none'
|
550
|
})
|
509
|
})
|
|
|
510
|
+ ele.t = false
|
|
|
511
|
+ n--
|
|
|
512
|
+ }else{
|
|
|
513
|
+ ele.t=true
|
|
|
514
|
+ }
|
551
|
}
|
515
|
}
|
552
|
- },
|
|
|
553
|
- //跳至图文详情
|
|
|
554
|
- jump_detail() {
|
|
|
555
|
- this.setData({
|
|
|
556
|
- active: false
|
|
|
557
|
- });
|
|
|
558
|
- wx.pageScrollTo({
|
|
|
559
|
- scrollTop: 1200,
|
|
|
560
|
- duration: 300
|
|
|
561
|
- })
|
|
|
562
|
- },
|
|
|
563
|
- jump_goods() {
|
|
|
564
|
- this.setData({
|
|
|
565
|
- active: true
|
|
|
566
|
- });
|
|
|
567
|
- wx.pageScrollTo({
|
|
|
568
|
- scrollTop: 0,
|
|
|
569
|
- duration: 300
|
|
|
570
|
- })
|
|
|
571
|
- },
|
|
|
572
|
- //收藏
|
|
|
573
|
- collection() {
|
|
|
574
|
- this.setData({
|
|
|
575
|
- shoucang: !this.data.shoucang
|
|
|
576
|
- });
|
|
|
577
|
- },
|
516
|
+ }
|
|
|
517
|
+ })
|
|
|
518
|
+ that.setData({
|
|
|
519
|
+ packageList: list,
|
|
|
520
|
+ countn: n
|
|
|
521
|
+ })
|
|
|
522
|
+ },
|
|
|
523
|
+ // 跳转图文食谱
|
|
|
524
|
+ get_recipe() {
|
|
|
525
|
+ wx.navigateTo({
|
|
|
526
|
+ url: '../production_steps/production_steps?id=' + this.data.id,
|
|
|
527
|
+ })
|
|
|
528
|
+ },
|
|
|
529
|
+ // 跳转购物车
|
|
|
530
|
+ get_car() {
|
|
|
531
|
+ this.setData({
|
|
|
532
|
+ show: true
|
|
|
533
|
+ });
|
|
|
534
|
+ },
|
|
|
535
|
+ //隐藏mask
|
|
|
536
|
+ hide_masks() {
|
|
|
537
|
+ var that = this
|
|
|
538
|
+ if (that.data.skuid != '') {
|
|
|
539
|
+ that.setData({
|
|
|
540
|
+ shows: false
|
|
|
541
|
+ });
|
|
|
542
|
+ var str = ''
|
|
|
543
|
+ str = that.data.id_arr.join(',');
|
|
|
544
|
+ if (that.data.id_arr.length > 1) {
|
|
|
545
|
+ var gPrice = that.data.num * that.data.gPrice
|
|
|
546
|
+ console.log(gPrice);
|
|
|
547
|
+ if (that.data.is_group == 0) {
|
|
|
548
|
+ wx.navigateTo({
|
|
|
549
|
+ url: '../../my/settle_account/settle_account?ids=' + that.data.skuid + '&gid=' + that.data.id + '&num=' + that.data.num + '&gPrice=' + gPrice
|
|
|
550
|
+ })
|
|
|
551
|
+ } else {
|
|
|
552
|
+ wx.navigateTo({
|
|
|
553
|
+ url: '../../my/settle_account/settle_account?ids=' + that.data.skuid + '&gid=' + that.data.id + '&num=' + that.data.num + '&gPrice=' + gPrice + '&is_group=' + that.data.is_group
|
|
|
554
|
+ })
|
|
|
555
|
+ }
|
|
|
556
|
+ }
|
|
|
557
|
+ } else {
|
|
|
558
|
+ wx.showToast({
|
|
|
559
|
+ title: '请先选择商品属性组合',
|
|
|
560
|
+ icon: 'none'
|
|
|
561
|
+ })
|
|
|
562
|
+ }
|
|
|
563
|
+ },
|
|
|
564
|
+ //跳至图文详情
|
|
|
565
|
+ jump_detail() {
|
|
|
566
|
+ this.setData({
|
|
|
567
|
+ active: false
|
|
|
568
|
+ });
|
|
|
569
|
+ wx.pageScrollTo({
|
|
|
570
|
+ scrollTop: 1200,
|
|
|
571
|
+ duration: 300
|
|
|
572
|
+ })
|
|
|
573
|
+ },
|
|
|
574
|
+ jump_goods() {
|
|
|
575
|
+ this.setData({
|
|
|
576
|
+ active: true
|
|
|
577
|
+ });
|
|
|
578
|
+ wx.pageScrollTo({
|
|
|
579
|
+ scrollTop: 0,
|
|
|
580
|
+ duration: 300
|
|
|
581
|
+ })
|
|
|
582
|
+ },
|
|
|
583
|
+ //收藏
|
|
|
584
|
+ collection() {
|
|
|
585
|
+ this.setData({
|
|
|
586
|
+ shoucang: !this.data.shoucang
|
|
|
587
|
+ });
|
|
|
588
|
+ },
|
578
|
|
589
|
|
579
|
- /**
|
|
|
580
|
- * 生命周期函数--监听页面初次渲染完成
|
|
|
581
|
- */
|
|
|
582
|
- onReady: function () {
|
590
|
+ /**
|
|
|
591
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
592
|
+ */
|
|
|
593
|
+ onReady: function() {
|
583
|
|
594
|
|
584
|
- },
|
595
|
+ },
|
585
|
|
596
|
|
586
|
- /**
|
|
|
587
|
- * 生命周期函数--监听页面显示
|
|
|
588
|
- */
|
|
|
589
|
- onShow: function () {
|
597
|
+ /**
|
|
|
598
|
+ * 生命周期函数--监听页面显示
|
|
|
599
|
+ */
|
|
|
600
|
+ onShow: function() {
|
590
|
|
601
|
|
591
|
- },
|
602
|
+ },
|
592
|
|
603
|
|
593
|
- /**
|
|
|
594
|
- * 生命周期函数--监听页面隐藏
|
|
|
595
|
- */
|
|
|
596
|
- onHide: function () {
|
604
|
+ /**
|
|
|
605
|
+ * 生命周期函数--监听页面隐藏
|
|
|
606
|
+ */
|
|
|
607
|
+ onHide: function() {
|
597
|
|
608
|
|
598
|
- },
|
609
|
+ },
|
599
|
|
610
|
|
600
|
- /**
|
|
|
601
|
- * 生命周期函数--监听页面卸载
|
|
|
602
|
- */
|
|
|
603
|
- onUnload: function () {
|
611
|
+ /**
|
|
|
612
|
+ * 生命周期函数--监听页面卸载
|
|
|
613
|
+ */
|
|
|
614
|
+ onUnload: function() {
|
604
|
|
615
|
|
605
|
- },
|
616
|
+ },
|
606
|
|
617
|
|
607
|
- /**
|
|
|
608
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
609
|
- */
|
|
|
610
|
- onPullDownRefresh: function () {
|
618
|
+ /**
|
|
|
619
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
620
|
+ */
|
|
|
621
|
+ onPullDownRefresh: function() {
|
611
|
|
622
|
|
612
|
- },
|
623
|
+ },
|
613
|
|
624
|
|
614
|
- /**
|
|
|
615
|
- * 页面上拉触底事件的处理函数
|
|
|
616
|
- */
|
|
|
617
|
- onReachBottom: function () {
|
625
|
+ /**
|
|
|
626
|
+ * 页面上拉触底事件的处理函数
|
|
|
627
|
+ */
|
|
|
628
|
+ onReachBottom: function() {
|
618
|
|
629
|
|
619
|
- },
|
630
|
+ },
|
620
|
|
631
|
|
621
|
- /**
|
|
|
622
|
- * 用户点击右上角分享
|
|
|
623
|
- */
|
|
|
624
|
- onShareAppMessage: function () {
|
|
|
625
|
- var shareObj = {
|
|
|
626
|
- // title: options.target.dataset.title, // 默认是小程序的名称(可以写slogan等)
|
|
|
627
|
- path: '/pages/start/start',
|
|
|
628
|
- imgUrl: '',
|
|
|
629
|
- title: ''
|
|
|
630
|
- }
|
|
|
631
|
- // if (options.from == 'button') {
|
|
|
632
|
- // // 此处可以修改 shareObj 中的内容
|
|
|
633
|
- // shareObj.path = '/pages/start/start?status=' + options.target.dataset.status
|
|
|
634
|
- // }
|
|
|
635
|
- return shareObj;
|
632
|
+ /**
|
|
|
633
|
+ * 用户点击右上角分享
|
|
|
634
|
+ */
|
|
|
635
|
+ onShareAppMessage: function() {
|
|
|
636
|
+ var shareObj = {
|
|
|
637
|
+ // title: options.target.dataset.title, // 默认是小程序的名称(可以写slogan等)
|
|
|
638
|
+ path: '/pages/start/start',
|
|
|
639
|
+ imgUrl: '',
|
|
|
640
|
+ title: ''
|
636
|
}
|
641
|
}
|
|
|
642
|
+ // if (options.from == 'button') {
|
|
|
643
|
+ // // 此处可以修改 shareObj 中的内容
|
|
|
644
|
+ // shareObj.path = '/pages/start/start?status=' + options.target.dataset.status
|
|
|
645
|
+ // }
|
|
|
646
|
+ return shareObj;
|
|
|
647
|
+ }
|
637
|
}) |
648
|
}) |