|
@@ -36,7 +36,8 @@ Page({ |
|
@@ -36,7 +36,8 @@ Page({ |
36
|
goods1: {},
|
36
|
goods1: {},
|
37
|
origin: 0,
|
37
|
origin: 0,
|
38
|
skuid_arr: [],
|
38
|
skuid_arr: [],
|
39
|
- is_vip: 0
|
39
|
+ is_vip: 0,
|
|
|
40
|
+ countn: null
|
40
|
},
|
41
|
},
|
41
|
fetchVip() {
|
42
|
fetchVip() {
|
42
|
let url = '/wxapp/user/index'
|
43
|
let url = '/wxapp/user/index'
|
|
@@ -140,7 +141,7 @@ Page({ |
|
@@ -140,7 +141,7 @@ Page({ |
140
|
console.log(is_vip + 'shibushis')
|
141
|
console.log(is_vip + 'shibushis')
|
141
|
app.post(url, params).then(r => {
|
142
|
app.post(url, params).then(r => {
|
142
|
// console.log(r);
|
143
|
// console.log(r);
|
143
|
- r.data.list.forEach(function (ele, indexxx) {
|
144
|
+ r.data.list.forEach(function(ele, indexxx) {
|
144
|
if (is_vip == 1) {
|
145
|
if (is_vip == 1) {
|
145
|
ele.ggprice = ele.vip_price
|
146
|
ele.ggprice = ele.vip_price
|
146
|
} else {
|
147
|
} else {
|
|
@@ -150,10 +151,10 @@ Page({ |
|
@@ -150,10 +151,10 @@ Page({ |
150
|
showList.push(ele)
|
151
|
showList.push(ele)
|
151
|
}
|
152
|
}
|
152
|
ele.t = false
|
153
|
ele.t = false
|
153
|
- if(indexxx<r.data.info.num){
|
|
|
154
|
- ele.t=true
|
154
|
+ if (indexxx < r.data.info.num) {
|
|
|
155
|
+ ele.t = true
|
155
|
}
|
156
|
}
|
156
|
- ele.attr.attr_sku.forEach(function (eles, indexxxx) {
|
157
|
+ ele.attr.attr_sku.forEach(function(eles, indexxxx) {
|
157
|
for (let i = 0; i < eles.item.length; i++) {
|
158
|
for (let i = 0; i < eles.item.length; i++) {
|
158
|
eles.item[i].t = false
|
159
|
eles.item[i].t = false
|
159
|
eles.item[0].t = true;
|
160
|
eles.item[0].t = true;
|
|
@@ -190,6 +191,7 @@ Page({ |
|
@@ -190,6 +191,7 @@ Page({ |
190
|
var minutes = ''
|
191
|
var minutes = ''
|
191
|
var seconds = ''
|
192
|
var seconds = ''
|
192
|
var percent = 0
|
193
|
var percent = 0
|
|
|
194
|
+
|
193
|
function time() {
|
195
|
function time() {
|
194
|
var cut_time = r.data.groupType.count_down_time
|
196
|
var cut_time = r.data.groupType.count_down_time
|
195
|
days = Math.floor((cut_time) / (60 * 60 * 24));
|
197
|
days = Math.floor((cut_time) / (60 * 60 * 24));
|
|
@@ -211,7 +213,8 @@ Page({ |
|
@@ -211,7 +213,8 @@ Page({ |
211
|
collocation: r.data.collocation,
|
213
|
collocation: r.data.collocation,
|
212
|
comment: r.data.comment,
|
214
|
comment: r.data.comment,
|
213
|
// star_arr: star_arr,
|
215
|
// star_arr: star_arr,
|
214
|
- is_group: r.data.info.group_min_number
|
216
|
+ is_group: r.data.info.group_min_number,
|
|
|
217
|
+ countn: r.data.info.num
|
215
|
});
|
218
|
});
|
216
|
} else {
|
219
|
} else {
|
217
|
that.setData({
|
220
|
that.setData({
|
|
@@ -219,7 +222,8 @@ Page({ |
|
@@ -219,7 +222,8 @@ Page({ |
219
|
gPrice: r.data.info.price,
|
222
|
gPrice: r.data.info.price,
|
220
|
// comment: r.data.comment,
|
223
|
// comment: r.data.comment,
|
221
|
packageList: r.data.list,
|
224
|
packageList: r.data.list,
|
222
|
- showList: showList
|
225
|
+ showList: showList,
|
|
|
226
|
+ countn: r.data.info.num
|
223
|
});
|
227
|
});
|
224
|
}
|
228
|
}
|
225
|
});
|
229
|
});
|
|
@@ -246,7 +250,7 @@ Page({ |
|
@@ -246,7 +250,7 @@ Page({ |
246
|
/**
|
250
|
/**
|
247
|
* 生命周期函数--监听页面加载
|
251
|
* 生命周期函数--监听页面加载
|
248
|
*/
|
252
|
*/
|
249
|
- onLoad: function (options) {
|
253
|
+ onLoad: function(options) {
|
250
|
console.log(options)
|
254
|
console.log(options)
|
251
|
this.fetchVip();
|
255
|
this.fetchVip();
|
252
|
var query = wx.createSelectorQuery();
|
256
|
var query = wx.createSelectorQuery();
|
|
@@ -268,15 +272,15 @@ Page({ |
|
@@ -268,15 +272,15 @@ Page({ |
268
|
let num = goods.info.num
|
272
|
let num = goods.info.num
|
269
|
let showList = []
|
273
|
let showList = []
|
270
|
let n = 0
|
274
|
let n = 0
|
271
|
- goods.list.forEach(function (ele, index) {
|
275
|
+ goods.list.forEach(function(ele, index) {
|
272
|
if (ele.t) {
|
276
|
if (ele.t) {
|
273
|
showList.push(ele)
|
277
|
showList.push(ele)
|
274
|
n++;
|
278
|
n++;
|
275
|
}
|
279
|
}
|
276
|
})
|
280
|
})
|
277
|
- if ((n < goods.info.num && n > 0) || n > goods.info.num) {
|
281
|
+ if ((n < goods.info.num && n >= 0) || n > goods.info.num) {
|
278
|
wx.showToast({
|
282
|
wx.showToast({
|
279
|
- title: '您最多只能选择' + num + '种商品',
|
283
|
+ title: '您最多能选择' + num + '种商品',
|
280
|
icon: 'none'
|
284
|
icon: 'none'
|
281
|
})
|
285
|
})
|
282
|
return;
|
286
|
return;
|
|
@@ -323,7 +327,7 @@ Page({ |
|
@@ -323,7 +327,7 @@ Page({ |
323
|
let iindex = e.currentTarget.dataset.origin
|
327
|
let iindex = e.currentTarget.dataset.origin
|
324
|
//父级索引
|
328
|
//父级索引
|
325
|
let parent = e.currentTarget.dataset.parent
|
329
|
let parent = e.currentTarget.dataset.parent
|
326
|
- goods.forEach(function (ele, index) {
|
330
|
+ goods.forEach(function(ele, index) {
|
327
|
if (iindex == index) {
|
331
|
if (iindex == index) {
|
328
|
let new_arr = ele.arr
|
332
|
let new_arr = ele.arr
|
329
|
let listAll = ele.attr.attr_sku;
|
333
|
let listAll = ele.attr.attr_sku;
|
|
@@ -341,7 +345,7 @@ Page({ |
|
@@ -341,7 +345,7 @@ Page({ |
341
|
if (foo > -1) {
|
345
|
if (foo > -1) {
|
342
|
new_arr.splice(foo, 1)
|
346
|
new_arr.splice(foo, 1)
|
343
|
} else {
|
347
|
} else {
|
344
|
- ele.attr.attr_sku.forEach(function (eles, indexxxx) {
|
348
|
+ ele.attr.attr_sku.forEach(function(eles, indexxxx) {
|
345
|
if (indexxxx == parent) {
|
349
|
if (indexxxx == parent) {
|
346
|
for (let i = 0; i < eles.item.length; i++) {
|
350
|
for (let i = 0; i < eles.item.length; i++) {
|
347
|
let havId = ele.attr.attr_sku[indexxxx].item[i].id
|
351
|
let havId = ele.attr.attr_sku[indexxxx].item[i].id
|
|
@@ -357,7 +361,7 @@ Page({ |
|
@@ -357,7 +361,7 @@ Page({ |
357
|
let tempArry = JSON.parse(JSON.stringify(ele.attr.attr_sku[parent]));
|
361
|
let tempArry = JSON.parse(JSON.stringify(ele.attr.attr_sku[parent]));
|
358
|
!tempArry.chooseIndex ? tempArry.chooseIndex = [] : '';
|
362
|
!tempArry.chooseIndex ? tempArry.chooseIndex = [] : '';
|
359
|
// 是否多选
|
363
|
// 是否多选
|
360
|
- if (is_checkMore) { } else {
|
364
|
+ if (is_checkMore) {} else {
|
361
|
tempArry.chooseIndex.pop();
|
365
|
tempArry.chooseIndex.pop();
|
362
|
tempArry.chooseIndex.push(nowId);
|
366
|
tempArry.chooseIndex.push(nowId);
|
363
|
for (let obj of tempArry.item) {
|
367
|
for (let obj of tempArry.item) {
|
|
@@ -372,7 +376,7 @@ Page({ |
|
@@ -372,7 +376,7 @@ Page({ |
372
|
goods1: goods[iindex]
|
376
|
goods1: goods[iindex]
|
373
|
})
|
377
|
})
|
374
|
// let goods = t.data.goodsList;
|
378
|
// let goods = t.data.goodsList;
|
375
|
- goods.forEach(function (ele, indexaa) {
|
379
|
+ goods.forEach(function(ele, indexaa) {
|
376
|
if (iindex == indexaa) {
|
380
|
if (iindex == indexaa) {
|
377
|
let new_arr = ele.arr
|
381
|
let new_arr = ele.arr
|
378
|
let sys_attrprice = goods[indexaa].sys_attrprice;
|
382
|
let sys_attrprice = goods[indexaa].sys_attrprice;
|
|
@@ -382,7 +386,7 @@ Page({ |
|
@@ -382,7 +386,7 @@ Page({ |
382
|
let skuid_price = 0
|
386
|
let skuid_price = 0
|
383
|
let old_skuid_price = 0
|
387
|
let old_skuid_price = 0
|
384
|
let vip_skuid_price = 0
|
388
|
let vip_skuid_price = 0
|
385
|
- ele.attr.attr_sku.forEach(function (eles, indexx) {
|
389
|
+ ele.attr.attr_sku.forEach(function(eles, indexx) {
|
386
|
if (indexx == parent) {
|
390
|
if (indexx == parent) {
|
387
|
new_arr = new_arr.concat(eles.chooseIndex);
|
391
|
new_arr = new_arr.concat(eles.chooseIndex);
|
388
|
}
|
392
|
}
|
|
@@ -429,7 +433,7 @@ Page({ |
|
@@ -429,7 +433,7 @@ Page({ |
429
|
// skuid_arr.push(skuid1)
|
433
|
// skuid_arr.push(skuid1)
|
430
|
}
|
434
|
}
|
431
|
var goods = this.data.showList
|
435
|
var goods = this.data.showList
|
432
|
- goods.forEach(function (ele, index) {
|
436
|
+ goods.forEach(function(ele, index) {
|
433
|
if (index == indexs) {
|
437
|
if (index == indexs) {
|
434
|
for (let i = 0; i < ele.attr.attr_sku.length; i++) {
|
438
|
for (let i = 0; i < ele.attr.attr_sku.length; i++) {
|
435
|
if (ele.arr.length == 1) {
|
439
|
if (ele.arr.length == 1) {
|
|
@@ -452,7 +456,7 @@ Page({ |
|
@@ -452,7 +456,7 @@ Page({ |
452
|
var goodsList = that.data.showList
|
456
|
var goodsList = that.data.showList
|
453
|
var skuid_arr = []
|
457
|
var skuid_arr = []
|
454
|
var total_price = 0
|
458
|
var total_price = 0
|
455
|
- goodsList.forEach(function (ele, index) {
|
459
|
+ goodsList.forEach(function(ele, index) {
|
456
|
var skuid = ele.ggid
|
460
|
var skuid = ele.ggid
|
457
|
if (ele.ggprice) {
|
461
|
if (ele.ggprice) {
|
458
|
ele.ggprice = ele.ggprice.substring(0, ele.ggprice.length - 3)
|
462
|
ele.ggprice = ele.ggprice.substring(0, ele.ggprice.length - 3)
|
|
@@ -490,23 +494,30 @@ Page({ |
|
@@ -490,23 +494,30 @@ Page({ |
490
|
let indexs = e.currentTarget.dataset.index
|
494
|
let indexs = e.currentTarget.dataset.index
|
491
|
let that = this
|
495
|
let that = this
|
492
|
let list = that.data.packageList
|
496
|
let list = that.data.packageList
|
493
|
- let n=0
|
|
|
494
|
- list.forEach(function (ele, index) {
|
497
|
+ let n = that.data.countn
|
|
|
498
|
+ list.forEach(function(ele, index) {
|
495
|
if (indexs == index) {
|
499
|
if (indexs == index) {
|
496
|
- ele.t = !ele.t
|
|
|
497
|
- }
|
|
|
498
|
if(ele.t){
|
500
|
if(ele.t){
|
|
|
501
|
+ n--
|
|
|
502
|
+ ele.t=false
|
|
|
503
|
+ }else{
|
499
|
n++
|
504
|
n++
|
500
|
- }
|
|
|
501
|
if(n>that.data.goods.info.num){
|
505
|
if(n>that.data.goods.info.num){
|
502
|
wx.showToast({
|
506
|
wx.showToast({
|
503
|
- title: '您最多可选择'+that.data.goods.info.num+'种商品',
|
507
|
+ title: '您最多选择'+that.data.goods.info.num+'种商品',
|
504
|
icon:'none'
|
508
|
icon:'none'
|
505
|
})
|
509
|
})
|
|
|
510
|
+ ele.t = false
|
|
|
511
|
+ n--
|
|
|
512
|
+ }else{
|
|
|
513
|
+ ele.t=true
|
|
|
514
|
+ }
|
|
|
515
|
+ }
|
506
|
}
|
516
|
}
|
507
|
})
|
517
|
})
|
508
|
that.setData({
|
518
|
that.setData({
|
509
|
- packageList: list
|
519
|
+ packageList: list,
|
|
|
520
|
+ countn: n
|
510
|
})
|
521
|
})
|
511
|
},
|
522
|
},
|
512
|
// 跳转图文食谱
|
523
|
// 跳转图文食谱
|
|
@@ -579,49 +590,49 @@ Page({ |
|
@@ -579,49 +590,49 @@ Page({ |
579
|
/**
|
590
|
/**
|
580
|
* 生命周期函数--监听页面初次渲染完成
|
591
|
* 生命周期函数--监听页面初次渲染完成
|
581
|
*/
|
592
|
*/
|
582
|
- onReady: function () {
|
593
|
+ onReady: function() {
|
583
|
|
594
|
|
584
|
},
|
595
|
},
|
585
|
|
596
|
|
586
|
/**
|
597
|
/**
|
587
|
* 生命周期函数--监听页面显示
|
598
|
* 生命周期函数--监听页面显示
|
588
|
*/
|
599
|
*/
|
589
|
- onShow: function () {
|
600
|
+ onShow: function() {
|
590
|
|
601
|
|
591
|
},
|
602
|
},
|
592
|
|
603
|
|
593
|
/**
|
604
|
/**
|
594
|
* 生命周期函数--监听页面隐藏
|
605
|
* 生命周期函数--监听页面隐藏
|
595
|
*/
|
606
|
*/
|
596
|
- onHide: function () {
|
607
|
+ onHide: function() {
|
597
|
|
608
|
|
598
|
},
|
609
|
},
|
599
|
|
610
|
|
600
|
/**
|
611
|
/**
|
601
|
* 生命周期函数--监听页面卸载
|
612
|
* 生命周期函数--监听页面卸载
|
602
|
*/
|
613
|
*/
|
603
|
- onUnload: function () {
|
614
|
+ onUnload: function() {
|
604
|
|
615
|
|
605
|
},
|
616
|
},
|
606
|
|
617
|
|
607
|
/**
|
618
|
/**
|
608
|
* 页面相关事件处理函数--监听用户下拉动作
|
619
|
* 页面相关事件处理函数--监听用户下拉动作
|
609
|
*/
|
620
|
*/
|
610
|
- onPullDownRefresh: function () {
|
621
|
+ onPullDownRefresh: function() {
|
611
|
|
622
|
|
612
|
},
|
623
|
},
|
613
|
|
624
|
|
614
|
/**
|
625
|
/**
|
615
|
* 页面上拉触底事件的处理函数
|
626
|
* 页面上拉触底事件的处理函数
|
616
|
*/
|
627
|
*/
|
617
|
- onReachBottom: function () {
|
628
|
+ onReachBottom: function() {
|
618
|
|
629
|
|
619
|
},
|
630
|
},
|
620
|
|
631
|
|
621
|
/**
|
632
|
/**
|
622
|
* 用户点击右上角分享
|
633
|
* 用户点击右上角分享
|
623
|
*/
|
634
|
*/
|
624
|
- onShareAppMessage: function () {
|
635
|
+ onShareAppMessage: function() {
|
625
|
var shareObj = {
|
636
|
var shareObj = {
|
626
|
// title: options.target.dataset.title, // 默认是小程序的名称(可以写slogan等)
|
637
|
// title: options.target.dataset.title, // 默认是小程序的名称(可以写slogan等)
|
627
|
path: '/pages/start/start',
|
638
|
path: '/pages/start/start',
|