...
|
...
|
@@ -62,28 +62,6 @@ class ChosePanel { |
|
|
$('.chose-panel').hide();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置商品模式
|
|
|
*/
|
|
|
_setModes() {
|
|
|
this.modes = { // 商品特性
|
|
|
// disableNum: this.disableNum, // 禁用编辑
|
|
|
// showBuyNow: this.data.showBuyNow // 是否显示双按钮
|
|
|
|
|
|
// isSoldOutSoon: false, //是否展示即将售罄
|
|
|
// goodsList: [],
|
|
|
// sizeList: [],
|
|
|
// image: '',
|
|
|
// goodPrice: '',
|
|
|
// price: '',
|
|
|
// buyNumber: 1,
|
|
|
// minusButtonEnable: false,
|
|
|
// plusButtonEnable: true,
|
|
|
// buyButtonEnable: true,
|
|
|
// buy_limit_number: 1
|
|
|
};
|
|
|
}
|
|
|
|
|
|
_render() {
|
|
|
let html;
|
|
|
|
...
|
...
|
@@ -95,33 +73,43 @@ class ChosePanel { |
|
|
}
|
|
|
|
|
|
this._setVariable();
|
|
|
this._initBlockStatus();
|
|
|
innerScroll.disableScroll($choseArea);
|
|
|
}
|
|
|
|
|
|
_getButtonText() {
|
|
|
if (this.modes.showBuyNow) {
|
|
|
return {
|
|
|
double: true,
|
|
|
text: '加入购物车'
|
|
|
};
|
|
|
}
|
|
|
if (this.modes.tickets || this.modes.limitCode || this.modes.seckill) {
|
|
|
return {
|
|
|
double: false,
|
|
|
text: '立即购买'
|
|
|
};
|
|
|
}
|
|
|
return {
|
|
|
double: false,
|
|
|
text: '加入购物车'
|
|
|
};
|
|
|
}
|
|
|
|
|
|
_defaultBuyNum() {
|
|
|
return (this.modes.discount && this.data.discountBuy.num) ||
|
|
|
(this.data.cartInfo && this.data.cartInfo.num) || 1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化属性按钮状态不满足库存的灰色
|
|
|
*/
|
|
|
_initBlockStatus() {
|
|
|
// 获取sku列表中库存小于最小购买数量的属性,如果在其他sku中它们没有满足购买数量条件的可以灰色
|
|
|
let noStorageSkus = this.skus.filter(sku => sku.storage < this.minBuyNum);
|
|
|
|
|
|
$chosePanel.find('.thumb').attr('src', this.data.cartInfo.defaultThumb);
|
|
|
|
|
|
$('.block').removeClass('zero-stock');
|
|
|
noStorageSkus.forEach(sku => {
|
|
|
for (let propType in sku.prop) {
|
|
|
if (propType) {
|
|
|
let prop = sku.prop[propType];
|
|
|
let zeroStock = !this.skus.some(_ => _.prop[propType].valId === prop.valId &&
|
|
|
_.storage >= this.minBuyNum);
|
|
|
let $block = $(`.block[data-prop-id="${propType}"][data-value-id="${prop.valId}"]`);
|
|
|
|
|
|
if (zeroStock) {
|
|
|
$block.addClass('zero-stock');
|
|
|
} else {
|
|
|
$block.removeClass('zero-stock');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
_setVariable() {
|
|
|
$chosePanel = $('.chose-panel');
|
|
|
$choseArea = $('.chose-panel .main .chose-items');
|
...
|
...
|
@@ -150,21 +138,6 @@ class ChosePanel { |
|
|
return this._choseBtnSureClick(e, false);
|
|
|
});
|
|
|
$yohoPage.on('touchstart', '#chose-btn-buynow', (e) => {
|
|
|
// let sku = this._checkSku(this.buyNum);
|
|
|
|
|
|
// if (window._yas && window._yas.sendCustomInfo) {
|
|
|
// window._yas.sendCustomInfo({
|
|
|
// op: 'YB_GDS_BUYNOW_BTN',
|
|
|
// param: JSON.stringify({
|
|
|
// C_ID: this.C_ID,
|
|
|
// PRD_ID: this.data.cartInfo.productId,
|
|
|
// PRD_NUM: this.buyNum,
|
|
|
// PRD_SKN: this.data.cartInfo.productSkn,
|
|
|
// PRD_SKU: sku && sku.skuId
|
|
|
// })
|
|
|
// }, true);
|
|
|
// }
|
|
|
|
|
|
return this._choseBtnSureClick(e, true);
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -232,23 +205,29 @@ class ChosePanel { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 点击确定或者立即购买按钮
|
|
|
* 点击确定
|
|
|
*/
|
|
|
_choseBtnSureClick(e, buyNow) {
|
|
|
let selectSku = this._checkSku(this.buyNum);
|
|
|
_choseBtnSureClick() {
|
|
|
// let selectSku = this._checkSku(this.buyNum);
|
|
|
//
|
|
|
// if (selectSku) {
|
|
|
// this.close();
|
|
|
// this._resolve && this._resolve({
|
|
|
// sku: selectSku,
|
|
|
// buyNum: this.buyNum,
|
|
|
// buyNow: buyNow
|
|
|
// });
|
|
|
// return false;
|
|
|
// }
|
|
|
|
|
|
// todo mock
|
|
|
this.close();
|
|
|
this._resolve && this._resolve({
|
|
|
sku: {skuId: 693031},
|
|
|
buyNum: 1,
|
|
|
buyNow: true
|
|
|
});
|
|
|
|
|
|
if (selectSku) {
|
|
|
this.close();
|
|
|
this._resolve && this._resolve({
|
|
|
sku: selectSku,
|
|
|
skn: this.data.cartInfo.productSkn,
|
|
|
productId: this.data.cartInfo.productId,
|
|
|
buyNum: this.buyNum,
|
|
|
modes: this.modes,
|
|
|
buyNow: buyNow
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -274,21 +253,6 @@ class ChosePanel { |
|
|
tip.show('无法选择该属性的商品');
|
|
|
return false;
|
|
|
}
|
|
|
if (buyNum < this.minBuyNum) {
|
|
|
if (this.modes.discount) {
|
|
|
tip.show(`量贩商品,${this.minBuyNum}件起购`);
|
|
|
return false;
|
|
|
} else {
|
|
|
tip.show('您选择的数量不能为零~');
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
if (this.modes.tickets && buyNum > selectSku.limitNum) {
|
|
|
if (selectSku.limitNum) {
|
|
|
tip.show(`每人只可购买${selectSku.limitNum}张此门票`);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
if (this.modes.limit && buyNum > this.maxBuyNum) {
|
|
|
tip.show('您选择数量大于限购数量~');
|
|
|
return false;
|
...
|
...
|
@@ -339,29 +303,8 @@ class ChosePanel { |
|
|
});
|
|
|
});
|
|
|
}
|
|
|
if (window._yas && window._yas.sendCustomInfo && chosed) {
|
|
|
if (propId === 'color') {
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_GDS_COLOR_C',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: this.C_ID,
|
|
|
PRD_ID: this.data.cartInfo.productId,
|
|
|
COLOR: $selectBlock.text()
|
|
|
})
|
|
|
}, true);
|
|
|
} else if (propId === 'size') {
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_GDS_SIZE_C',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: this.C_ID,
|
|
|
PRD_ID: this.data.cartInfo.productId,
|
|
|
SIZE: $selectBlock.text()
|
|
|
})
|
|
|
}, true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this._refreshBlockStatus();
|
|
|
// this._refreshBlockStatus();
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|