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