123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- // 商品详情
- 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:'<div class="cartAlert"><h6>商品已成功加入购物车!</h6><p>当前购物车共<em>'+response.data+'</em>种商品</p></div>',
- 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('<i id="priceGrade" class="icon mIcon ' + priceGrade +'"></i>');
- el.remove();
- })
- });
- }
- },
- mounted: function() {
- this.hanSkuClickSEo();
- }
- }
- }();
|