...
|
...
|
@@ -87,7 +87,7 @@ Page({ |
|
|
productOnlyProvideByYohoStore: false,
|
|
|
productNotForSale: false,
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
onLoad: function(options) {
|
|
|
let productSkn = options.productSkn ? options.productSkn : '';
|
|
|
|
|
|
if (!productSkn) {
|
...
|
...
|
@@ -103,7 +103,7 @@ Page({ |
|
|
yas = new Yas(app);
|
|
|
yas.pageOpenReport();
|
|
|
},
|
|
|
onPageScroll: function ({scrollTop}) {
|
|
|
onPageScroll: function({scrollTop}) {
|
|
|
const show = scrollTop > windowHeight * 2;
|
|
|
|
|
|
if (show !== this.data.showBackTop) {
|
...
|
...
|
@@ -112,12 +112,12 @@ Page({ |
|
|
});
|
|
|
}
|
|
|
},
|
|
|
backTop: function () {
|
|
|
backTop: function() {
|
|
|
wx.pageScrollTo({
|
|
|
scrollTop: 0
|
|
|
});
|
|
|
},
|
|
|
onShareAppMessage: function (res) {
|
|
|
onShareAppMessage: function(res) {
|
|
|
let params = {
|
|
|
FROM: res.from,
|
|
|
SHARE_RESUIL: 0,
|
...
|
...
|
@@ -130,18 +130,18 @@ Page({ |
|
|
return {
|
|
|
title: params.TITLE, // 分享标题
|
|
|
desc: params.DESC, // 分享描述
|
|
|
path: params.PATH , // 分享路径
|
|
|
success: function () {
|
|
|
path: params.PATH, // 分享路径
|
|
|
success: function() {
|
|
|
params.SHARE_RESUIL = 1;
|
|
|
yas.report('YB_SHARE_RESULT_L', params);
|
|
|
},
|
|
|
fail: function () {
|
|
|
fail: function() {
|
|
|
params.SHARE_RESUIL = 2;
|
|
|
yas.report('YB_SHARE_RESULT_L', params);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
share: function () {
|
|
|
share: function() {
|
|
|
this.setData({
|
|
|
'actionSheet.show': true
|
|
|
});
|
...
|
...
|
@@ -151,6 +151,7 @@ Page({ |
|
|
'actionSheet.show': false
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 当行动按钮中有一个被点击时触发
|
|
|
// index 代表被点击按钮在传入参数 actions 中的位置
|
|
|
handleZanActionsheetClick({index}) {
|
...
|
...
|
@@ -164,12 +165,12 @@ Page({ |
|
|
});
|
|
|
}
|
|
|
},
|
|
|
hideSnap: function () {
|
|
|
hideSnap: function() {
|
|
|
this.setData({
|
|
|
showSnapshootShare: false
|
|
|
})
|
|
|
});
|
|
|
},
|
|
|
shopRecList: function (shopId) {
|
|
|
shopRecList: function(shopId) {
|
|
|
listModel.productList({
|
|
|
page: 1,
|
|
|
limit: 20,
|
...
|
...
|
@@ -189,7 +190,7 @@ Page({ |
|
|
let item = {};
|
|
|
|
|
|
Object.keys(keyAdapter).forEach(key => {
|
|
|
item[key] = product[keyAdapter[key]]
|
|
|
item[key] = product[keyAdapter[key]];
|
|
|
});
|
|
|
list.push(item);
|
|
|
});
|
...
|
...
|
@@ -199,7 +200,7 @@ Page({ |
|
|
}
|
|
|
});
|
|
|
},
|
|
|
preferList: function () {
|
|
|
preferList: function() {
|
|
|
listModel.productList({
|
|
|
page: 1,
|
|
|
limit: 20
|
...
|
...
|
@@ -218,7 +219,7 @@ Page({ |
|
|
let item = {};
|
|
|
|
|
|
Object.keys(keyAdapter).forEach(key => {
|
|
|
item[key] = product[keyAdapter[key]]
|
|
|
item[key] = product[keyAdapter[key]];
|
|
|
});
|
|
|
list.push(item);
|
|
|
});
|
...
|
...
|
@@ -228,7 +229,7 @@ Page({ |
|
|
}
|
|
|
});
|
|
|
},
|
|
|
productInfo: function () {
|
|
|
productInfo: function() {
|
|
|
detailModel.productInfo(this.data.productSkn)
|
|
|
.then(res => {
|
|
|
if (res.code === 200) {
|
...
|
...
|
@@ -251,23 +252,24 @@ Page({ |
|
|
|
|
|
let isSoldOutSoon = false;
|
|
|
let tags = res.data.tags;
|
|
|
|
|
|
if (tags) {
|
|
|
isSoldOutSoon = tags.includes('is_soon_sold_out');
|
|
|
}
|
|
|
|
|
|
//pickerData
|
|
|
// pickerData
|
|
|
let pickData = this.data.pickerData;
|
|
|
|
|
|
pickData.view.goodsList = res.data.goods_list;
|
|
|
pickData.view.isSoldOutSoon = isSoldOutSoon;
|
|
|
|
|
|
//默认显示第一种颜色的尺码
|
|
|
// 默认显示第一种颜色的尺码
|
|
|
pickData.view.sizeList = res.data.goods_list.length ? res.data.goods_list[0].size_list : [];
|
|
|
|
|
|
let plusButtonEnable = false;
|
|
|
let minusButtonEnable = false;
|
|
|
|
|
|
//根据库存设置该尺码是否可以选择
|
|
|
// 根据库存设置该尺码是否可以选择
|
|
|
let size_length = 0;
|
|
|
|
|
|
if (pickData.view.sizeList) {
|
...
|
...
|
@@ -277,7 +279,7 @@ Page({ |
|
|
pickData.view.sizeList && pickData.view.sizeList.map((item, index) => {
|
|
|
item.enable = item.storage_number > 0;
|
|
|
if (index === 0 && size_length === 1 && this.data.colorSelected) {
|
|
|
//当颜色被选中 并且只有一个size 时 才会自动 做选中尺码操作
|
|
|
// 当颜色被选中 并且只有一个size 时 才会自动 做选中尺码操作
|
|
|
pickData.view.buyButtonEnable = item.enable;
|
|
|
if (item.enable) {
|
|
|
item.selected = true;
|
...
|
...
|
@@ -316,6 +318,7 @@ Page({ |
|
|
storage_sum: res.data.storage_sum,
|
|
|
snapshootShareData: snapData,
|
|
|
shopId: res.data.shop_id,
|
|
|
|
|
|
// 暂时没用
|
|
|
// brand_id: res.data.brand_id,
|
|
|
// isLimitBuy:res.data.isLimitBuy,
|
...
|
...
|
@@ -331,9 +334,9 @@ Page({ |
|
|
// bundle_type: res.data.bundle_type,
|
|
|
// store_show_status: res.data.store_show_status,
|
|
|
// attribute: res.data.attribute,
|
|
|
productOnlyProvideByYohoAPP: res.data.is_secKill === 'Y' || res.data.is_advance === 'Y' || res.data.attribute === 3 || res.data.attribute === 4 || res.data.isLimitBuy || res.data.is_deposit_advance==='Y',
|
|
|
productOnlyProvideByYohoAPP: res.data.is_secKill === 'Y' || res.data.is_advance === 'Y' || res.data.attribute === 3 || res.data.attribute === 4 || res.data.isLimitBuy || res.data.is_deposit_advance === 'Y',
|
|
|
productOnlyProvideByYohoStore: res.data.store_show_status === 3 || res.data.store_show_status === 4,
|
|
|
productNotForSale: res.data.attribute===2,
|
|
|
productNotForSale: res.data.attribute === 2,
|
|
|
showBottomTipView: true
|
|
|
});
|
|
|
|
...
|
...
|
@@ -341,7 +344,7 @@ Page({ |
|
|
}
|
|
|
});
|
|
|
},
|
|
|
supportService: function () {
|
|
|
supportService: function() {
|
|
|
let params = {
|
|
|
product_skn: this.data.productSkn,
|
|
|
coupon_limit_status: 0
|
...
|
...
|
@@ -354,7 +357,7 @@ Page({ |
|
|
});
|
|
|
});
|
|
|
},
|
|
|
productIntro: function () {
|
|
|
productIntro: function() {
|
|
|
let params = {
|
|
|
productskn: this.data.productSkn
|
|
|
};
|
...
|
...
|
@@ -380,7 +383,7 @@ Page({ |
|
|
});
|
|
|
});
|
|
|
},
|
|
|
buyImmediate: function () {
|
|
|
buyImmediate: function() {
|
|
|
if (this.data.productOnlyProvideByYohoAPP || this.data.productOnlyProvideByYohoStore || this.data.productNotForSale) {
|
|
|
return wx.showToast({
|
|
|
title: '该商品暂时不支持当前小程序购买,请到Yoho!Buy有货查看',
|
...
|
...
|
@@ -389,7 +392,9 @@ Page({ |
|
|
});
|
|
|
}
|
|
|
|
|
|
if (this.data.storage_sum === 0) return;
|
|
|
if (this.data.storage_sum === 0) {
|
|
|
return;
|
|
|
}
|
|
|
this.setData({buyImmediate: true});
|
|
|
|
|
|
if (app.getUid()) {
|
...
|
...
|
@@ -398,15 +403,15 @@ Page({ |
|
|
tapToLogin();
|
|
|
}
|
|
|
},
|
|
|
hidePicker: function (e) {
|
|
|
hidePicker: function(e) {
|
|
|
if (e.target.id === 'picker-bg') {
|
|
|
Picker.pickerHide(this);
|
|
|
}
|
|
|
},
|
|
|
chooseColor: function (event) {
|
|
|
chooseColor: function(event) {
|
|
|
let pickData = this.data.pickerData;
|
|
|
|
|
|
//先遍历将所有颜色、尺码置为未选中状态
|
|
|
// 先遍历将所有颜色、尺码置为未选中状态
|
|
|
pickData.view.goodsList && pickData.view.goodsList.map(item => {
|
|
|
item.selected = false;
|
|
|
item.size_list.map(subItem => {
|
...
|
...
|
@@ -415,20 +420,20 @@ Page({ |
|
|
});
|
|
|
});
|
|
|
|
|
|
//将当前颜色置为选中状态
|
|
|
// 将当前颜色置为选中状态
|
|
|
let tempItem = event.target.dataset.key;
|
|
|
|
|
|
//遍历颜色尺码,根据库存切换显示状态
|
|
|
// 遍历颜色尺码,根据库存切换显示状态
|
|
|
tempItem && tempItem.size_list && tempItem.size_list.map(item => {
|
|
|
item.enable = item.storage_number > 0;
|
|
|
});
|
|
|
tempItem.selected = true;
|
|
|
this.data.selectedProductId = tempItem.goods_id;
|
|
|
|
|
|
//设置标志位,表示已经选择颜色
|
|
|
// 设置标志位,表示已经选择颜色
|
|
|
let colorSelected = true;
|
|
|
|
|
|
//重置库存、当前选中sku的值
|
|
|
// 重置库存、当前选中sku的值
|
|
|
pickData.storageNumber = 0;
|
|
|
pickData.selectedSKU = 0;
|
|
|
this.data.selectedSKU = 0;
|
...
|
...
|
@@ -437,7 +442,8 @@ Page({ |
|
|
pickData.view.sizeList = tempItem.size_list;
|
|
|
|
|
|
pickData.view.minusButtonEnable = false;
|
|
|
//将购买数量设为初始状态
|
|
|
|
|
|
// 将购买数量设为初始状态
|
|
|
pickData.view.buyNumber = 1;
|
|
|
|
|
|
this.setData({
|
...
|
...
|
@@ -445,27 +451,28 @@ Page({ |
|
|
pickerData: pickData
|
|
|
});
|
|
|
},
|
|
|
chooseSize: function (event) {
|
|
|
chooseSize: function(event) {
|
|
|
let pickData = this.data.pickerData;
|
|
|
|
|
|
//现遍历将所有尺码置为未选中状态
|
|
|
// 现遍历将所有尺码置为未选中状态
|
|
|
pickData.view.sizeList && pickData.view.sizeList.map(item => {
|
|
|
item.selected = false
|
|
|
item.selected = false;
|
|
|
});
|
|
|
|
|
|
//将当前尺码置为选中状态
|
|
|
// 将当前尺码置为选中状态
|
|
|
let tempItem = event.currentTarget.dataset.key;
|
|
|
|
|
|
tempItem.selected = true;
|
|
|
pickData.view.sizeList[parseInt(event.currentTarget.id)] = tempItem;
|
|
|
|
|
|
//设置数量加减按钮启用状态
|
|
|
// 设置数量加减按钮启用状态
|
|
|
pickData.view.plusButtonEnable = (!pickData.view.buy_limit_number || pickData.view.buy_limit_number > 1) && tempItem.storage_number > 1;
|
|
|
|
|
|
pickData.view.minusButtonEnable = false;
|
|
|
pickData.view.buyButtonEnable = true;
|
|
|
|
|
|
if (pickData.view.bundle_count === 0) {
|
|
|
pickData.view.buyNumber = 1
|
|
|
pickData.view.buyNumber = 1;
|
|
|
}
|
|
|
|
|
|
if (tempItem.storage_number <= 0) {
|
...
|
...
|
@@ -475,7 +482,7 @@ Page({ |
|
|
duration: 2000
|
|
|
});
|
|
|
|
|
|
pickData.view.buyButtonEnable = false
|
|
|
pickData.view.buyButtonEnable = false;
|
|
|
}
|
|
|
|
|
|
this.setData({
|
...
|
...
|
@@ -484,7 +491,7 @@ Page({ |
|
|
storageNumber: tempItem.storage_number
|
|
|
});
|
|
|
},
|
|
|
bindMinus: function () {
|
|
|
bindMinus: function() {
|
|
|
let pickerData = this.data.pickerData;
|
|
|
let buyNumber = parseInt(pickerData.view.buyNumber);
|
|
|
|
...
|
...
|
@@ -492,9 +499,9 @@ Page({ |
|
|
if (buyNumber > pickerData.view.bundle_count) {
|
|
|
pickerData.view.minusButtonEnable = true;
|
|
|
} else {
|
|
|
this.minReachedLimitAction(pickerData.view.bundle_count)
|
|
|
this.minReachedLimitAction(pickerData.view.bundle_count);
|
|
|
pickerData.view.minusButtonEnable = false;
|
|
|
return
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -520,8 +527,8 @@ Page({ |
|
|
this.setData({pickerData});
|
|
|
},
|
|
|
|
|
|
//增加购买数量
|
|
|
bindPlus: function () {
|
|
|
// 增加购买数量
|
|
|
bindPlus: function() {
|
|
|
if (!this.data.colorSelected) {
|
|
|
return wx.showToast({
|
|
|
title: '请选择颜色',
|
...
|
...
|
@@ -571,7 +578,7 @@ Page({ |
|
|
this.setData({pickerData});
|
|
|
},
|
|
|
|
|
|
plusReachedMaxAction: function () {
|
|
|
plusReachedMaxAction: function() {
|
|
|
return wx.showToast({
|
|
|
title: '对不起,没有更多库存了',
|
|
|
icon: 'none',
|
...
|
...
|
@@ -579,7 +586,7 @@ Page({ |
|
|
});
|
|
|
},
|
|
|
|
|
|
plusReachedLimitAction: function (n) {
|
|
|
plusReachedLimitAction: function(n) {
|
|
|
return wx.showToast({
|
|
|
title: '限购' + n + '件',
|
|
|
icon: 'none',
|
...
|
...
|
@@ -588,14 +595,14 @@ Page({ |
|
|
|
|
|
},
|
|
|
|
|
|
minReachedLimitAction: function (n) {
|
|
|
minReachedLimitAction: function(n) {
|
|
|
return wx.showToast({
|
|
|
title: n + '件' + '起售',
|
|
|
icon: 'none',
|
|
|
duration: 1000
|
|
|
});
|
|
|
},
|
|
|
goPayment: function (e) {
|
|
|
goPayment: function(e) {
|
|
|
if (!this.data.colorSelected) {
|
|
|
return wx.showToast({
|
|
|
title: '请选择颜色',
|
...
|
...
|
@@ -614,16 +621,16 @@ Page({ |
|
|
|
|
|
this._dataReport();
|
|
|
if (this.data.buyImmediate) {
|
|
|
this.payNow(e)
|
|
|
this.payNow(e);
|
|
|
}
|
|
|
},
|
|
|
payNow: function () {
|
|
|
payNow: function() {
|
|
|
router.go('cartEnsure', {
|
|
|
productSku: this.data.selectedSKU,
|
|
|
buyNumber: this.data.pickerData.view.buyNumber
|
|
|
});
|
|
|
},
|
|
|
_dataReport: function () {
|
|
|
_dataReport: function() {
|
|
|
yas.report('YB_GDS_DT_BILL', {
|
|
|
PRD_SKN: this.data.productSkn,
|
|
|
RPD_SKU: this.data.selectedSKU,
|
...
|
...
|
|