// 商品详情
var productMixins = function () {
return {
data() {
return {
addParams:{
skuId:0,
productCount:0,
productId:0,
userId:0,
source:1
},
handleSkuId:0,
currentIndex:0,
skuIndex:0,
skuSupportingIndex:0,
ladderList: [],//阶梯价
isDetailsBtnDisable:false
}
},
filters: {
NumFormat(value) {
console.log('value',value)
//处理金额
return Number(value).toFixed(2)
}
},
methods: {
handleAddShopCart(){ //加入购物车
if(this.isDetailsBtnDisable){ return }
if(this.addStatus){
this.addStatus = false;
this.addParams.productCount = this.number;
this.handleClubAddCart(this.addParams)
}
},
handleClubAddCart(params){// 调用加入购物车
var _self = this;
ShoppingApi.ClubAddCart(params,function (response){
if(response.code == 0){
_self.addStatus = true;
$.confirm({
useBootstrap: false,
boxWidth: (isPC?'338px':'74.6vw'),
title: false,
content:'
商品已成功加入购物车!
当前购物车共'+response.data+'种商品
',
closeIcon: true,
animation: 'opacity',
closeAnimation: 'opacity',
animateFromElement: false,
scrollToPreviousElement: false,
buttons: {
login: {
text: '去结算',
btnClass: 'btn-to-cart',
action: function(){
window.location.href = '/shopping/cart.html';
}
},
close: {
text: '继续购物',
btnClass: 'btn-to-goon',
action:function(){
}
}
}
});
globalHead.getHeadCart(_self.userId);
}else{
CAIMEI.dialog('加入购物车失败!',true,function () {
_self.addStatus = true;
});
}
})
},
handleBuyNowSubmit(){ // type:(1购物车提交[对应表cm_cart],2直接购买提交, 3协销下单)
if(this.isDetailsBtnDisable){ return }
if(this.productId && this.number){
window.location.href = '/shopping/confirm.html?type=2&productId='+this.productId+'&count='+this.number+'&skuId='+this.addParams.skuId;
}
},
handleChoisSku(sku,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.number = this.priceObj.minBuyNumber = sku.minBuyNumber;
this.productStock = sku.stock;
this.ladderList = sku.ladderPriceList ? sku.ladderPriceList : [];
this.isDetailsBtnDisable = sku.stock === 0;
$('#prosductStock').text(sku.stock);
$('#proMinBuyNumber').text(sku.minBuyNumber);
},
hanSkuClickSEo(){// 静态化下控制点击
var grade = $(".unitTags").eq(0).attr('data-grade');
$('#priceGrade').addClass(`i${grade}`);
$(".unitTags").each(function() {
var _this = $(this);
_this.click(function () {
_this.addClass("active");
_this.siblings().removeClass('active');
var priceGrade = 'i'+_this.attr('data-grade');
const el = $('#priceGrade');
el.parent().append('');
el.remove();
})
});
}
},
mounted: function() {
this.hanSkuClickSEo();
}
}
}();