...
|
...
|
@@ -36,7 +36,8 @@ Page({ |
|
|
goods1: {},
|
|
|
origin: 0,
|
|
|
skuid_arr: [],
|
|
|
is_vip: 0
|
|
|
is_vip: 0,
|
|
|
countn: null
|
|
|
},
|
|
|
fetchVip() {
|
|
|
let url = '/wxapp/user/index'
|
...
|
...
|
@@ -140,7 +141,7 @@ Page({ |
|
|
console.log(is_vip + 'shibushis')
|
|
|
app.post(url, params).then(r => {
|
|
|
// console.log(r);
|
|
|
r.data.list.forEach(function (ele, indexxx) {
|
|
|
r.data.list.forEach(function(ele, indexxx) {
|
|
|
if (is_vip == 1) {
|
|
|
ele.ggprice = ele.vip_price
|
|
|
} else {
|
...
|
...
|
@@ -150,10 +151,10 @@ Page({ |
|
|
showList.push(ele)
|
|
|
}
|
|
|
ele.t = false
|
|
|
if(indexxx<r.data.info.num){
|
|
|
ele.t=true
|
|
|
if (indexxx < r.data.info.num) {
|
|
|
ele.t = true
|
|
|
}
|
|
|
ele.attr.attr_sku.forEach(function (eles, indexxxx) {
|
|
|
ele.attr.attr_sku.forEach(function(eles, indexxxx) {
|
|
|
for (let i = 0; i < eles.item.length; i++) {
|
|
|
eles.item[i].t = false
|
|
|
eles.item[0].t = true;
|
...
|
...
|
@@ -190,6 +191,7 @@ Page({ |
|
|
var minutes = ''
|
|
|
var seconds = ''
|
|
|
var percent = 0
|
|
|
|
|
|
function time() {
|
|
|
var cut_time = r.data.groupType.count_down_time
|
|
|
days = Math.floor((cut_time) / (60 * 60 * 24));
|
...
|
...
|
@@ -211,7 +213,8 @@ Page({ |
|
|
collocation: r.data.collocation,
|
|
|
comment: r.data.comment,
|
|
|
// star_arr: star_arr,
|
|
|
is_group: r.data.info.group_min_number
|
|
|
is_group: r.data.info.group_min_number,
|
|
|
countn: r.data.info.num
|
|
|
});
|
|
|
} else {
|
|
|
that.setData({
|
...
|
...
|
@@ -219,7 +222,8 @@ Page({ |
|
|
gPrice: r.data.info.price,
|
|
|
// comment: r.data.comment,
|
|
|
packageList: r.data.list,
|
|
|
showList: showList
|
|
|
showList: showList,
|
|
|
countn: r.data.info.num
|
|
|
});
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -246,7 +250,7 @@ Page({ |
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
onLoad: function(options) {
|
|
|
console.log(options)
|
|
|
this.fetchVip();
|
|
|
var query = wx.createSelectorQuery();
|
...
|
...
|
@@ -268,15 +272,15 @@ Page({ |
|
|
let num = goods.info.num
|
|
|
let showList = []
|
|
|
let n = 0
|
|
|
goods.list.forEach(function (ele, index) {
|
|
|
goods.list.forEach(function(ele, index) {
|
|
|
if (ele.t) {
|
|
|
showList.push(ele)
|
|
|
n++;
|
|
|
}
|
|
|
})
|
|
|
if ((n < goods.info.num && n > 0) || n > goods.info.num) {
|
|
|
if ((n < goods.info.num && n >= 0) || n > goods.info.num) {
|
|
|
wx.showToast({
|
|
|
title: '您最多只能选择' + num + '种商品',
|
|
|
title: '您最多能选择' + num + '种商品',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
return;
|
...
|
...
|
@@ -323,7 +327,7 @@ Page({ |
|
|
let iindex = e.currentTarget.dataset.origin
|
|
|
//父级索引
|
|
|
let parent = e.currentTarget.dataset.parent
|
|
|
goods.forEach(function (ele, index) {
|
|
|
goods.forEach(function(ele, index) {
|
|
|
if (iindex == index) {
|
|
|
let new_arr = ele.arr
|
|
|
let listAll = ele.attr.attr_sku;
|
...
|
...
|
@@ -341,7 +345,7 @@ Page({ |
|
|
if (foo > -1) {
|
|
|
new_arr.splice(foo, 1)
|
|
|
} else {
|
|
|
ele.attr.attr_sku.forEach(function (eles, indexxxx) {
|
|
|
ele.attr.attr_sku.forEach(function(eles, indexxxx) {
|
|
|
if (indexxxx == parent) {
|
|
|
for (let i = 0; i < eles.item.length; i++) {
|
|
|
let havId = ele.attr.attr_sku[indexxxx].item[i].id
|
...
|
...
|
@@ -357,7 +361,7 @@ Page({ |
|
|
let tempArry = JSON.parse(JSON.stringify(ele.attr.attr_sku[parent]));
|
|
|
!tempArry.chooseIndex ? tempArry.chooseIndex = [] : '';
|
|
|
// 是否多选
|
|
|
if (is_checkMore) { } else {
|
|
|
if (is_checkMore) {} else {
|
|
|
tempArry.chooseIndex.pop();
|
|
|
tempArry.chooseIndex.push(nowId);
|
|
|
for (let obj of tempArry.item) {
|
...
|
...
|
@@ -372,7 +376,7 @@ Page({ |
|
|
goods1: goods[iindex]
|
|
|
})
|
|
|
// let goods = t.data.goodsList;
|
|
|
goods.forEach(function (ele, indexaa) {
|
|
|
goods.forEach(function(ele, indexaa) {
|
|
|
if (iindex == indexaa) {
|
|
|
let new_arr = ele.arr
|
|
|
let sys_attrprice = goods[indexaa].sys_attrprice;
|
...
|
...
|
@@ -382,7 +386,7 @@ Page({ |
|
|
let skuid_price = 0
|
|
|
let old_skuid_price = 0
|
|
|
let vip_skuid_price = 0
|
|
|
ele.attr.attr_sku.forEach(function (eles, indexx) {
|
|
|
ele.attr.attr_sku.forEach(function(eles, indexx) {
|
|
|
if (indexx == parent) {
|
|
|
new_arr = new_arr.concat(eles.chooseIndex);
|
|
|
}
|
...
|
...
|
@@ -429,7 +433,7 @@ Page({ |
|
|
// skuid_arr.push(skuid1)
|
|
|
}
|
|
|
var goods = this.data.showList
|
|
|
goods.forEach(function (ele, index) {
|
|
|
goods.forEach(function(ele, index) {
|
|
|
if (index == indexs) {
|
|
|
for (let i = 0; i < ele.attr.attr_sku.length; i++) {
|
|
|
if (ele.arr.length == 1) {
|
...
|
...
|
@@ -452,7 +456,7 @@ Page({ |
|
|
var goodsList = that.data.showList
|
|
|
var skuid_arr = []
|
|
|
var total_price = 0
|
|
|
goodsList.forEach(function (ele, index) {
|
|
|
goodsList.forEach(function(ele, index) {
|
|
|
var skuid = ele.ggid
|
|
|
if (ele.ggprice) {
|
|
|
ele.ggprice = ele.ggprice.substring(0, ele.ggprice.length - 3)
|
...
|
...
|
@@ -490,23 +494,30 @@ Page({ |
|
|
let indexs = e.currentTarget.dataset.index
|
|
|
let that = this
|
|
|
let list = that.data.packageList
|
|
|
let n=0
|
|
|
list.forEach(function (ele, index) {
|
|
|
let n = that.data.countn
|
|
|
list.forEach(function(ele, index) {
|
|
|
if (indexs == index) {
|
|
|
ele.t = !ele.t
|
|
|
}
|
|
|
if(ele.t){
|
|
|
n--
|
|
|
ele.t=false
|
|
|
}else{
|
|
|
n++
|
|
|
}
|
|
|
if(n>that.data.goods.info.num){
|
|
|
wx.showToast({
|
|
|
title: '您最多可选择'+that.data.goods.info.num+'种商品',
|
|
|
title: '您最多选择'+that.data.goods.info.num+'种商品',
|
|
|
icon:'none'
|
|
|
})
|
|
|
ele.t = false
|
|
|
n--
|
|
|
}else{
|
|
|
ele.t=true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
that.setData({
|
|
|
packageList: list
|
|
|
packageList: list,
|
|
|
countn: n
|
|
|
})
|
|
|
},
|
|
|
// 跳转图文食谱
|
...
|
...
|
@@ -579,49 +590,49 @@ Page({ |
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function () {
|
|
|
onReady: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
onShow: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function () {
|
|
|
onHide: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function () {
|
|
|
onUnload: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function () {
|
|
|
onPullDownRefresh: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
onReachBottom: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
onShareAppMessage: function() {
|
|
|
var shareObj = {
|
|
|
// title: options.target.dataset.title, // 默认是小程序的名称(可以写slogan等)
|
|
|
path: '/pages/start/start',
|
...
|
...
|
|