|
|
|
@ -25,19 +25,55 @@ Page({ |
|
|
|
allowance_data: null, |
|
|
|
//购物车数量
|
|
|
|
producNum: 1, |
|
|
|
skuIndex:null, |
|
|
|
skuIndex: null, |
|
|
|
aniSkuIndex: -1, |
|
|
|
cartCount: 0, |
|
|
|
cartImgInfo: null, |
|
|
|
cartTop: 0, |
|
|
|
top: 0, |
|
|
|
skuList: [], //立即预定的列表
|
|
|
|
sku_ids: [ |
|
|
|
353954, |
|
|
|
353950, |
|
|
|
353949, |
|
|
|
353951, |
|
|
|
353947, |
|
|
|
353953, |
|
|
|
353685, |
|
|
|
353684, |
|
|
|
353952, |
|
|
|
353686, |
|
|
|
353948, |
|
|
|
354730, |
|
|
|
354409, |
|
|
|
354359, |
|
|
|
345343, |
|
|
|
354756, |
|
|
|
354385, |
|
|
|
354360, |
|
|
|
354361, |
|
|
|
354362, |
|
|
|
355466, |
|
|
|
355465, |
|
|
|
356230, |
|
|
|
356223, |
|
|
|
356207, |
|
|
|
346648, |
|
|
|
357518, |
|
|
|
356233, |
|
|
|
354381, |
|
|
|
354384, |
|
|
|
356324, |
|
|
|
354737, |
|
|
|
355467, |
|
|
|
] |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad: function (options) { |
|
|
|
console.log(options); |
|
|
|
if (!options.id) { |
|
|
|
util.back() |
|
|
|
return; |
|
|
|
@ -74,8 +110,8 @@ Page({ |
|
|
|
// 如果带有指定skuid的话 那么取指定的sku展示
|
|
|
|
if (options.skuid) { |
|
|
|
let pItem = null; |
|
|
|
for (let i = 0; i < res.data.product.length; i++) {//3
|
|
|
|
for (let j = 0; j < res.data.product[i].sku.length; j++) {//4
|
|
|
|
for (let i = 0; i < res.data.product.length; i++) { //3
|
|
|
|
for (let j = 0; j < res.data.product[i].sku.length; j++) { //4
|
|
|
|
if (res.data.product[i].sku[j].id == options.skuid) { |
|
|
|
res.data.product[i].sku = [res.data.product[i].sku[j]]; |
|
|
|
pItem = res.data.product[i]; |
|
|
|
@ -86,6 +122,21 @@ Page({ |
|
|
|
if (pItem) { |
|
|
|
res.data.product = [pItem]; |
|
|
|
} |
|
|
|
|
|
|
|
} else if (options.zhuanti_type == "yihuFree") { |
|
|
|
|
|
|
|
let skuArr = this.data.sku_ids |
|
|
|
let newArr = [] |
|
|
|
for (let i = 0; i < res.data.product.length; i++) { //3
|
|
|
|
for (let j = 0; j < res.data.product[i].sku.length; j++) { //4
|
|
|
|
for (let k = 0; k < skuArr.length; k++) { |
|
|
|
if (res.data.product[i].sku[j].id == skuArr[k]) { |
|
|
|
newArr.push(res.data.product[i].sku[j]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
res.data.product[i].sku = newArr; |
|
|
|
} |
|
|
|
} |
|
|
|
// res.data.listimg = res.data.listimg?res.data.listimg.split(","):[];
|
|
|
|
res.data.product.map(product => { |
|
|
|
@ -250,7 +301,7 @@ Page({ |
|
|
|
// },
|
|
|
|
selectSku: function (e) { |
|
|
|
console.log(e.currentTarget.dataset.item); |
|
|
|
if (e.currentTarget.dataset.item.stock == 0 && e.currentTarget.dataset.item.is_third_stock!=1) { |
|
|
|
if (e.currentTarget.dataset.item.stock == 0 && e.currentTarget.dataset.item.is_third_stock != 1) { |
|
|
|
wx.showToast({ |
|
|
|
title: "该商品暂无库存", |
|
|
|
icon: 'none' |
|
|
|
@ -301,10 +352,10 @@ Page({ |
|
|
|
...sku, |
|
|
|
...product |
|
|
|
} |
|
|
|
|
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/order/scene/index', |
|
|
|
}) |
|
|
|
|
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/order/scene/index', |
|
|
|
}) |
|
|
|
} else { |
|
|
|
commonApi.user_post("cart/add_sku", { |
|
|
|
sku_id: this.data.skuList[this.data.skuIndex].id, |
|
|
|
@ -313,7 +364,7 @@ Page({ |
|
|
|
if (res.code == 1) { |
|
|
|
commonApi.user_post('cart/get_list', {}).then(res => { |
|
|
|
this.setData({ |
|
|
|
cartCount: res.data.length//5
|
|
|
|
cartCount: res.data.length //5
|
|
|
|
}) |
|
|
|
}) |
|
|
|
// 加动效
|
|
|
|
@ -661,7 +712,7 @@ Page({ |
|
|
|
}) |
|
|
|
return; |
|
|
|
} |
|
|
|
if (this.data.info.product[0].type=='line') { |
|
|
|
if (this.data.info.product[0].type == 'line') { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/order/road/index?id=' + this.data.info.product[0].id |
|
|
|
}) |
|
|
|
@ -691,9 +742,10 @@ Page({ |
|
|
|
* 生命周期函数--监听页面显示 |
|
|
|
*/ |
|
|
|
onShow: function () { |
|
|
|
console.log(11111); |
|
|
|
commonApi.user_post('cart/get_list', {}).then(res => { |
|
|
|
this.setData({ |
|
|
|
cartCount: res.data.length//1
|
|
|
|
cartCount: res.data.length //1
|
|
|
|
}) |
|
|
|
}) |
|
|
|
if (!wx.getStorageSync('jstrip_token')) { |
|
|
|
@ -734,8 +786,9 @@ Page({ |
|
|
|
//// 获取补贴结束
|
|
|
|
|
|
|
|
} else { |
|
|
|
console.log(2222); |
|
|
|
setTimeout(() => { |
|
|
|
this.onShow() |
|
|
|
// this.onShow()
|
|
|
|
}, 200) |
|
|
|
} |
|
|
|
|
|
|
|
|