...
|
...
|
@@ -22,6 +22,7 @@ Page(Object.assign({ |
|
|
login: false,
|
|
|
shopId: 0,
|
|
|
productSkn: 0,
|
|
|
countInCart: 0,
|
|
|
productName: '',
|
|
|
marketPrice: '',
|
|
|
salesPrice: '',
|
...
|
...
|
@@ -110,6 +111,7 @@ Page(Object.assign({ |
|
|
this.supportService();
|
|
|
this.productIntro();
|
|
|
this.preferList();
|
|
|
this._getCountInCart();
|
|
|
}, 500);
|
|
|
|
|
|
yas = new Yas(app);
|
...
|
...
|
@@ -608,7 +610,32 @@ Page(Object.assign({ |
|
|
duration: 1000
|
|
|
});
|
|
|
},
|
|
|
goPayment: function(e) {
|
|
|
goCart: function() {
|
|
|
router.go('shoppingCart');
|
|
|
},
|
|
|
addToCart: function() {
|
|
|
if (this.data.productOnlyProvideByYohoAPP ||
|
|
|
this.data.productOnlyProvideByYohoStore ||
|
|
|
this.data.productNotForSale) {
|
|
|
return wx.showToast({
|
|
|
title: '该商品暂时不支持当前小程序购买,请到Yoho!Buy有货查看',
|
|
|
icon: 'none',
|
|
|
duration: 2000
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (this.data.storage_sum === 0) {
|
|
|
return;
|
|
|
}
|
|
|
this.setData({buyImmediate: false});
|
|
|
|
|
|
if (app.getUid()) {
|
|
|
Picker.pickerShow(this);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 确定选择
|
|
|
confirmChoose: function(e) {
|
|
|
if (!this.data.colorSelected) {
|
|
|
return wx.showToast({
|
|
|
title: '请选择颜色',
|
...
|
...
|
@@ -627,10 +654,56 @@ Page(Object.assign({ |
|
|
|
|
|
this._dataReport();
|
|
|
if (this.data.buyImmediate) {
|
|
|
this.payNow(e);
|
|
|
return this._payNow(e);
|
|
|
}
|
|
|
|
|
|
this._addToCart();
|
|
|
},
|
|
|
_addToCart() {
|
|
|
let params = {
|
|
|
product_sku: this.data.selectedSKU > 0 ? this.data.selectedSKU : 0,
|
|
|
buy_number: this.data.pickerData.view.buyNumber,
|
|
|
edit_product_sku: 0,
|
|
|
promotion_id: '',
|
|
|
goods_type: 0,
|
|
|
selected: 'Y'
|
|
|
};
|
|
|
|
|
|
detailModel.addToShoppingCart(params)
|
|
|
.then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this._getCountInCart();
|
|
|
Picker.pickerHide(this);
|
|
|
wx.showToast({
|
|
|
title: res.message,
|
|
|
icon: 'none',
|
|
|
duration: 2000
|
|
|
});
|
|
|
} else {
|
|
|
return Promise.reject();
|
|
|
}
|
|
|
})
|
|
|
.catch(err => {
|
|
|
wx.showToast({
|
|
|
title: err && err.message || '加入购物车失败,请稍后重试',
|
|
|
icon: 'none',
|
|
|
duration: 2000
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
_getCountInCart: function() {
|
|
|
detailModel.getCountInCart({product_skn: this.data.productSkn})
|
|
|
.then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this.setData({
|
|
|
countInCart: res.data.cart_goods_count,
|
|
|
});
|
|
|
} else {
|
|
|
return Promise.reject();
|
|
|
}
|
|
|
}).catch(() => {});
|
|
|
},
|
|
|
payNow: function() {
|
|
|
_payNow: function() {
|
|
|
router.go('cartEnsure', {
|
|
|
productSku: this.data.selectedSKU,
|
|
|
buyNumber: this.data.pickerData.view.buyNumber
|
...
|
...
|
|