var homeData = new Vue({ el: '#container', data: { userId:0, images: [], listLoading:true, advertising: [], asideNav: [], productIdArr:[], liveList:[],//右侧直播模块 cmImageList:[],//右侧活动模块 infoList:[],//右侧文章模块 pageList:[],//左侧楼层 supplierImage:'',//供应商banner supplierWwwLink:'',//供应商banner 链接 supplierList:[],//供应商列表 topMenuList:[] }, filters: { statusType:function(value) { switch (value) { case '1': return '未开始'; break; case '2': return '直播中'; break; case '3': return '已结束'; break; } }, statusTypeClass:function(value) { switch (value) { case '1': return 'icon-wart'; break; case '2': return 'icon-live'; break; case '3': return 'icon-end'; break; } }, NumFormat:function(value) {//处理金额 return Number(value).toFixed(2); }, }, methods: { GetBanners: function(){ var _self = this; PublicApi.GetHomeBanner({},function(response){ if(response.code == 0){ _self.images = response.data; _self.listLoading =false; _self.SwiperBanner(); }else{ CAIMEI.Alert(response.msg, '确定'); } }); }, SwiperBanner: function(){ setTimeout(function(){ if (isPC) { $('#swiper-container').slide({ mainCell:".swiper-wrapper-banner", titCell:".swiper-pagination-banner span", effect: "leftLoop", prevCell:".swiper-button-prev", nextCell:".swiper-button-next", interTime: 3000, autoPlay: true, autoPage: false, trigger: "mouseover" }); } else { var swiper = new Swiper('#swiper-container', { loop : true, autoplay: { delay: 3000, disableOnInteraction: false }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev' }, pagination: { el: '.swiper-pagination', clickable :true } }); } },300); }, GetHomeFloorData: function(){ var _self = this; PublicApi.GetHomeData({userId:GLOBAL_USER_ID,soure:1},function(response){ if(response.code == 0){ var data = response.data; // var floorList = []; _self.pageList = data.homePageFloor; _self.liveList = data.liveList; _self.supplierList = data.supplierImage.qualitySupplierList; _self.supplierImage = data.supplierImage.wwwImage; _self.supplierWwwLink = data.supplierImage.wwwLink; _self.pageList.forEach(function(page){ if(page.floorContent){ if(isPC){ if(page.floorContent.templateType == '1' || page.floorContent.templateType == '3'){ if (page.floorImageList.length>7){ page.isPageMore = true; } }else if(page.floorContent.templateType == '2' || page.floorContent.templateType == '4' || page.floorContent.templateType == '7'){ if (page.floorImageList.length>5){ page.isPageMore = true; } }else if(page.floorContent.templateType == '5'){ if (page.floorImageList.length>10){ page.isPageMore = true; } } }else{ if(page.floorContent.templateType == '1' || page.floorContent.templateType == '3'){ if (page.floorImageList.length>3){ page.isPageMore = true; } }else if(page.floorContent.templateType == '2' || page.floorContent.templateType == '4'){ if (page.floorImageList.length>2){ page.isPageMore = true; } }else if(page.floorContent.templateType == '5'){ if (page.floorImageList.length>4){ page.isPageMore = true; } } } } }); console.log(_self.pageList) _self.GetHomeRightData(); setTimeout(function() { // 设置侧边导航数据 _self.SetAsideNav(); _self.SwiperFloor(); },500); }else{ CAIMEI.Alert(response.msg, '确定'); } }); }, GetHomeRightData: function(){ var _self = this; PublicApi.GetHomeRightData({ source: 1 },function(response){ if(response.code == 0){ var data = response.data; _self.liveList = data.liveList; _self.cmImageList = data.cmImageList; _self.infoList = data.infoList; }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 }, showMorePageFn:function(page){ page.isPageMore = !page.isPageMore; }, getAdvertising: function(){ var _self = this; $.getJSON("/home/advertising").done(function (r) { if (r.code === 0 && r.data) { _self.advertising = r.data; } }); }, SetAsideNav: function(){ var _self = this; var titArr = $('.section_page_title').find('h1'); for (var i=0; i0) { setTimeout(function(){ height += parent.find(".navItem").height(); parent.css("height",height); },200); } } } }, created: function() { var userInfo = localStorage.getItem('userInfo'); if(userInfo){ this.userId = JSON.parse(userInfo).userId; } this.GetBanners(); this.GetHomeFloorData(); }, mounted: function() { // this.getAdvertising(); // 侧边栏滚动判断 var distance = 0; $(window).scroll(function () { if($('body').attr("style") && $('body').attr("style").indexOf('fixed')>0){ return false; } var scoll = Math.max($('html').scrollTop(), $('body').scrollTop()); if(scoll >300){ $('#sideNav').show(); if(isPC){ $('#advertising').show(); // 鼠标滚动楼层 setTimeout(function () { distance = scoll; },0); $('.section_page_title').each(function (i,e) { //每个元素距离顶部的距离 var top = $(e).offset().top; if(scoll > distance){ if(scoll >= (top-300)){ $('#sideNav').find('a').eq(i).addClass('on').siblings().removeClass("on"); } }else { if(scoll >= (top-600)){ $('#sideNav').find('a').eq(i).addClass('on').siblings().removeClass("on"); } } }); } }else { $('#sideNav').hide(); $('#advertising').hide(); } }); // 侧边导航 setTimeout(function(){ $('#sideNav').on("click", 'a[data-id]',function () { var id = $(this).attr('data-id'); var floorScroll = $('.section_page_title [data-id='+id+']').offset().top-200; $('html,body').animate({scrollTop: floorScroll},600); }); },2000); //关闭广告图 $('#advertising').on('click','.close',function () { $(this).parents('.item').hide(); })   } });