var instrueMent = new Vue({ el:'#instrueMent', mixins: [cmSysVitaMixins], data:{ listLoading:true, categorylist:[], hotlist:[], recommendPage: 1, floorList: [], userId:0, typeSort:'', showflag:false, params:{ pageId:0, userId:0, source:1 }, isPC:window.isPC }, filters: { NumFormat:function(value) { return Number(value).toFixed(2); } }, methods:{ // 是否显示vip标签价格 showVipPriceTag: function(pros){ //非会员 // if(!GLOBAL_VIP_FLAG === 1) return false; // 商品所有机构可见 if(pros.priceFlag === 0 && pros.svipProductFlag === 1 ) return true; // 商品价格仅资质机构可见 if(pros.priceFlag === 2 && pros.svipProductFlag === 1 && GLOBAL_USER_IDENTITY === 2) return true; // 商品价格仅医美机构可见 if(pros.priceFlag === 3 && pros.svipProductFlag === 1 && GLOBAL_USER_IDENTITY === 2 && GLOBAL_CLUB_TYPE === 1) return true; // 其它 return false; }, closeup:function(){ this.showflag = false; document.body.style.overflow=''; }, showNav:function(){ var _this = this; _this.showflag = !_this.showflag; if (_this.showflag){ document.body.style.overflow='hidden'; }else { document.body.style.overflow=''; } }, // 商品楼层轮播 swiperFloor: function(){ setTimeout(function(){ // 商品轮播 if (isPC) { var cell = $(".swiper-pagination-floor"); var size = Math.ceil(cell.attr("data-id")/5); var span = ''; for (var i = 0; i < size; i++) { span += ''; } cell.html(span); $('.mySwiperSlide').slide({ mainCell:".recommendBox-wrapper", titCell:".swiper-pagination-floor span", effect: "leftLoop", autoPlay: false, scroll:5, vis:5 }); } else { var swiper = new Swiper('.mySwiperSlide', { slidesPerView: 2, slidesPerColumn: 2, spaceBetween:0, slidesPerGroup: 2, autoplay: { delay: 3000, disableOnInteraction: false }, pagination: { el: '.swiper-pagination' } }); } // 图片懒加载 setTimeout(function(){ $("#recommendBox img[data-original]").lazyload(); },0) },500); }, GetHomeData: function(){//获取楼层 var _self = this; ProductApi.GethomeData(_self.params,function(response){ if(response.code == 0){ var data = response.data; _self.floorList = data.floorList; _self.cmSysParams.pageLabel = data.contentLabel; setTimeout(function(){ // 图片懒加载 $("img[data-original]").lazyload(); _self.swiperFloor(); // 设置页面查看更多 _self.setReadeMore(); },500); }else{ CAIMEI.Alert(response.msg, '确定'); } }); }, PromotionsFormat:function(promo){//促销活动类型数据处理 if(promo!=null){ if(promo.type == 1 && promo.mode == 1){ return true }else{ return false } } return false }, // 设置页面查看更多按钮显示 setReadeMore: function(){ $(".section_page_more").each(function(){ var id = $(this).attr('data-id')*1; var size = $(this).attr('data-size')*1; var el = $(this); var readMore = false; if (isPC) { if([1,3].indexOf(id) !== -1 && size>7) { readMore = true; } if([2,4].indexOf(id) !== -1 && size>5) { readMore = true; } if([5,6,7].indexOf(id) !== -1 && size>10) { readMore = true; } } else { if([1,3].indexOf(id) !== -1 && size>3) { readMore = true; } if([2,4].indexOf(id) !== -1 && size>2) { readMore = true; } if([5,6,7].indexOf(id) !== -1 && size>4) { readMore = true; } } if (readMore) { el.addClass("show"); } else { el.parents(".section_page").find(".section_page_main").addClass("max"); } }); }, // 点击查看更多 showMoreItem: function(e){ var el = e.currentTarget; $(el).parents(".section_page").find(".section_page_main").addClass("max"); $(el).parents(".section_page_more").hide(); }, // 设置页面商品价格 setPriceShown: function(){ var productIds = []; var userId = GLOBAL_USER_ID; var shopId = GLOBAL_SHOP_ID; var userIdentity = GLOBAL_USER_IDENTITY; $(".main_price_text").each(function(){ var id = $(this).attr('data-id'); if (productIds.indexOf(id) === -1) { productIds .push(id); } }); // 获取商品价格列表 $.getJSON(coreServer+"/commodity/price/list",{ userId: GLOBAL_USER_ID, productIds: productIds.join(',') }).done(function (res) { if (res.code === 0 && res.data) { var priceList = res.data; $(".main_price_none").hide(); $(".price_grade_club").hide(); $(".price_grade_shop").hide(); $(".main_price_login").show(); priceList.map(function(price){ // userIdentity用户身份: 0、个人 1、协销 2、会员机构 3、供应商 4,普通机构 // priceFlag: 0公开价格 1不公开价格 2仅对会员机构公开 var parent = $(".main_price_text.product_"+ price.productId); var priceFlag = parent.find(".main_price_login").attr('data-id')*1; if (priceFlag===3 || userIdentity===2 || (priceFlag === 0 && userIdentity===4 ) || (userIdentity===3 && shopId === price.shopId*1)) { parent.find(".price_o_num").text(Number(price.originalPrice).toFixed(2)); parent.find(".price_num").text(Number(price.price).toFixed(2)); if(price.promotions && price.promotions.type*1===1 && price.promotions.mode*1===1){ parent.find(".main_price_show").hide(); parent.find(".main_price_show.none").show(); parent.find(".price_unit").show(); } } else if (userIdentity===4 && priceFlag === 2){ parent.find(".main_price_show").hide(); parent.find(".price_grade_club").show(); } else { parent.find(".main_price_show").hide(); parent.find(".price_grade_shop").show(); } }); } }); } }, created: function () { this.cmSysParams.pageType = 13; }, mounted: function(){ var _self = this; var userInfo = localStorage.getItem('userInfo'); if(userInfo){ _self.userId = _self.params.userId = JSON.parse(userInfo).userId; } //this.params.pageId = getUrlParam('id'); var paramsArr = window.location.pathname.split(".")[0].split("-"); this.params.pageId = paramsArr.length>=1 ? paramsArr[1] : ''; // 获取设置商品价格 if (GLOBAL_USER_ID) { this.GetHomeData(); }else { //获取页面标签名称 this.cmSysParams.pageLabel = $('#contentLabel').val(); // 设置页面查看更多 this.setReadeMore(); // 推荐专区商品轮播 this.swiperFloor(); } // Dom加载后 this.$nextTick(function(){ // 图片懒加载 $("img[data-original]").lazyload(); }); } })