|
@@ -1,3 +1,19 @@
|
|
|
|
+function isObject(obj){
|
|
|
|
+ return Object.prototype.toString.call(obj) === '[object Object]';
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 递归赋值
|
|
|
|
+function recursiveAssign(target, source){
|
|
|
|
+ if(!isObject(target) || !isObject(source)) return;
|
|
|
|
+ for (const key in target) {
|
|
|
|
+ if(source.hasOwnProperty(key)){
|
|
|
|
+ target[key] = source[key];
|
|
|
|
+ }else{
|
|
|
|
+ recursiveAssign(target[key], source);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// 商品详情
|
|
// 商品详情
|
|
var productMixins = function () {
|
|
var productMixins = function () {
|
|
return {
|
|
return {
|
|
@@ -26,6 +42,17 @@ var productMixins = function () {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ // 切换sku
|
|
|
|
+ switchSkuRef(product, skuId){
|
|
|
|
+ if(product.skus && product.skus.length > 0){
|
|
|
|
+ const sku = product.skus.find(function(item){
|
|
|
|
+ return item.skuId === skuId;
|
|
|
|
+ });
|
|
|
|
+ if(!sku) return;
|
|
|
|
+ recursiveAssign(product, sku);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
handleAddShopCart(){ //加入购物车
|
|
handleAddShopCart(){ //加入购物车
|
|
if(this.isDetailsBtnDisable){ return }
|
|
if(this.isDetailsBtnDisable){ return }
|
|
if(this.addStatus){
|
|
if(this.addStatus){
|
|
@@ -82,14 +109,12 @@ var productMixins = function () {
|
|
},
|
|
},
|
|
handleChoisSku(sku,index){
|
|
handleChoisSku(sku,index){
|
|
this.skuIndex = index;
|
|
this.skuIndex = index;
|
|
- this.priceObj.originalPrice = sku.originalPrice;
|
|
|
|
- this.priceObj.normalPrice = sku.normalPrice;
|
|
|
|
- this.priceObj.price = sku.price;
|
|
|
|
this.addParams.skuId = sku.skuId;
|
|
this.addParams.skuId = sku.skuId;
|
|
this.number = this.priceObj.minBuyNumber = sku.minBuyNumber;
|
|
this.number = this.priceObj.minBuyNumber = sku.minBuyNumber;
|
|
this.productStock = sku.stock;
|
|
this.productStock = sku.stock;
|
|
this.ladderList = sku.ladderPriceList ? sku.ladderPriceList : [];
|
|
this.ladderList = sku.ladderPriceList ? sku.ladderPriceList : [];
|
|
this.isDetailsBtnDisable = sku.stock === 0;
|
|
this.isDetailsBtnDisable = sku.stock === 0;
|
|
|
|
+ this.switchSkuRef(this.priceObj, sku.skuId)
|
|
$('#prosductStock').text(sku.stock);
|
|
$('#prosductStock').text(sku.stock);
|
|
$('#proMinBuyNumber').text(sku.minBuyNumber);
|
|
$('#proMinBuyNumber').text(sku.minBuyNumber);
|
|
},
|
|
},
|