layui.use(['jquery','laypage'],function(){ var $ = layui.jquery , laypage = layui.laypage; if($("#product_details").length == 0){ // $(".product-nav .subset").hide(); //涓嶆槸璇︽儏椤 闅愯棌鑿滃崟 } else{ var anchor = location.hash.replace('#',''); if(anchor){ postiion_anchor(anchor); } function postiion_anchor(anchor){ var top = $(".anchor[data-anchor="+anchor+']').offset().top - 100; if(window.innerWidth<768) top -= 30; console.log(top) window.scrollTo(0,top); setTimeout(()=>{ window.scrollTo(0,top); },200) setTimeout(()=>{ window.scrollTo(0,top); },600) setTimeout(()=>{ window.scrollTo(0,top); },1200) } // 璇存槑涔︿笅杞 // 榧犳爣绉诲嚭 骞朵笖娌℃湁鎮仠鍦ㄦ枃浠朵笅杞絛om涓 闅愯棌涓嬭浇 $(".instructions").click(function(ev){ $(".downloadSelect").show(); return false; }).hover(function(){ $(".downloadSelect").show(); },function(){ setTimeout(function(){ if($('.downloadSelect').is(":hover") == false) $(".downloadSelect").hide(); },100) }) $(".downloadSelect").hover(function(){},function(){ $(this).hide(); }) // 璇︽儏椤 $(".content-body .swiper-slide").click(function(){ var imgSrc = []; $("#product_details .gallery-top img").each(function(){ imgSrc.push({src:$(this).attr("src")}); }) layer.photos({ photos: { "data": imgSrc, } ,anim: 5 //0-6鐨勯€夋嫨锛屾寚瀹氬脊鍑哄浘鐗囧姩鐢荤被鍨嬶紝榛樿闅忔満 }); }) var inspectionReportPage = 1; $(".inspectionReport").click(function(){ $("#inspectionReport").show(); }) // getInspectionReportData(true); $("#inspectionReport .btn").click(function(){ inspectionReportPage = 1; getInspectionReportData(true); }); $("#inspectionReport .reportClose").click(function(){ $("#inspectionReport").hide(); }) // 鑾峰彇鏁版嵁 function getInspectionReportData(reset){ $.post('/frontend/products/inspectionReportList',{"id":productsId,'page':inspectionReportPage,search:$("#inspectionReport input").val()},function(res){ var list = res.data; var html = ''; for(var i=0;i

'+list[i]['title']+'

'; } $("#inspectionReport .reportList").html(html); if(reset) pageInit(res.total); }) } // 鍒濆鍖栭〉鐮 function pageInit(count){ $("#reportPage .layui-laypage-page").remove(); if(count < 10) return; laypage.render({ elem: 'reportPage' ,count: count ,theme:'page' ,curr:inspectionReportPage ,jump: function(obj, first){ //棣栨涓嶆墽琛 if(!first){ inspectionReportPage = obj.curr; getInspectionReportData(); var href = $(".content-menu .subset .active").attr('href').replace('.html','') + '/' + obj.curr + '.html'; $.post('/productMenuContent'+href,function(res){ $(".content-body").html(res); }) } } }); } } $("#faq .problem").click(function(){ $(this).siblings('.active').find('.answer').slideUp(); $(this).siblings('.active').removeClass('active'); if($(this).hasClass('active')){ $(this).removeClass('active'); $(this).find('.answer').slideUp(); } else{ $(this).addClass('active'); $(this).find('.answer').slideDown(); } }) $(".content-menu .extend").click(function(ev){ $(this).find('.subset').eq(0).filter(':not(:animated)').slideToggle(); ev.stopPropagation(); if(sysConfig.controllername == 'products' && sysConfig.actionname == 'details') return; var href = $(this).attr('href'); $.post('/productMenuContent'+href,function(res){ $(".content-body").html(res); }) // 濡傛灉娌℃湁瀛愯彍鍗 鍒欏姞閫変腑鏍峰紡 if(href.indexOf('subset') != -1){ $(".content-menu .item.active").removeClass('active') $(".content-menu .active.extend").removeClass('active'); $(this).addClass('active'); } }) $(".content-menu .minbox .item").click(function(ev){ if(sysConfig.controllername == 'products' && sysConfig.actionname == 'details') return; var href = $(this).attr('href'); $(".content-menu .item.active").removeClass('active') $(this).addClass('active'); $(".content-menu .active.extend").removeClass('active'); $(this).parents('.extend').addClass('active'); ev.stopPropagation(); $.post('/productMenuContent'+href,function(res){ $(".content-body").html(res); }) }) if($("#product_list .content").length > 0){ var offsetTop = $("#product_list .content").offset().top - 140; setTimeout(function(){window.scrollTo(0, offsetTop)},150); } if(typeof(page) != 'undefined' && (page != 1 || count > 10)){ // var laypage = layui.laypage; // laypage.render({ // elem: 'page' //娉ㄦ剰锛岃繖閲岀殑 test1 鏄 ID锛屼笉鐢ㄥ姞 # 鍙 // ,count: count //鏁版嵁鎬绘暟锛屼粠鏈嶅姟绔緱鍒 // ,theme:'page' // ,curr:page // ,jump: function(obj, first){ // //obj鍖呭惈浜嗗綋鍓嶅垎椤电殑鎵€鏈夊弬鏁帮紝姣斿锛 // console.log(obj.curr); //寰楀埌褰撳墠椤碉紝浠ヤ究鍚戞湇鍔$璇锋眰瀵瑰簲椤电殑鏁版嵁銆 // //棣栨涓嶆墽琛 // if(!first){ // location = '/'+columnName+'/list_'+obj.curr+'.html'; //寰楀埌姣忛〉鏄剧ず鐨勬潯鏁 // } // } // }); laypage.render({ elem: 'page' //娉ㄦ剰锛岃繖閲岀殑 test1 鏄 ID锛屼笉鐢ㄥ姞 # 鍙 ,count: count //鏁版嵁鎬绘暟锛屼粠鏈嶅姟绔緱鍒 ,theme:'page' ,curr:page ,jump: function(obj, first){ //obj鍖呭惈浜嗗綋鍓嶅垎椤电殑鎵€鏈夊弬鏁帮紝姣斿锛 console.log(obj.curr); //寰楀埌褰撳墠椤碉紝浠ヤ究鍚戞湇鍔$璇锋眰瀵瑰簲椤电殑鏁版嵁銆 //棣栨涓嶆墽琛 if(!first){ if($('#page').attr('data-type') == 'search'){ return location.href = '/search/'+columnName+'?page='+obj.curr; } var href = $(".content-menu .subset .active").attr('href').replace('.html','') + '/' + obj.curr + '.html'; $.post('/productMenuContent'+href,function(res){ $(".content-body").html(res); }) } } }); } var galleryThumbs = new Swiper('#product_details .content-body .gallery-thumbs', { spaceBetween: 10, slidesPerView: 4, freeMode: true, watchSlidesVisibility: true, watchSlidesProgress: true, }); var galleryTop = new Swiper('#product_details .gallery-top', { spaceBetween: 10, navigation: { nextEl: '#product_details .swiper-button-next', prevEl: '#product_details .swiper-button-prev', }, thumbs: { swiper: galleryThumbs } }) if(typeof(pariceView) != 'undefined' && pariceView){ // 浜у搧浠锋牸璇︽儏椤 璋冩暣鍒版爣棰樹綅缃€傞渶瑕佸噺鍘诲鑸潯楂樺害 setTimeout(function(){ var scrollTop = $(".name").offset().top - $(window.innerWidth>768?'#head':"#menu").height(); $(window).scrollTop(scrollTop); },500) } $(".item.pay").click(function(){ if(pariceView){ location.href = '/products_details/'+productsId+'.html'; return; } var money = $('.specifications .active').attr('data-money'); var data = { id:productsId, specifications:$(".specifications .active").text(), num:$(".number input").val() } if(isNaN(money)){ showToastTel(); return; } if(!loginIs){ base.login(0); return; } data.orderType = 'product'; $.post('/orderNow',data,function(res){ location.href = '/orderCheckStep1.html'; }) }) $(".item.join").click(function(){ if(pariceView){ location.href = '/products_details/'+productsId+'.html'; return; } var money = $('.specifications .active').attr('data-money'); var data = { id:productsId, specifications:$(".specifications .active").text(), num:$(".number input").val() } if(isNaN(money)){ showToastTel(); return; } if(!loginIs){ base.login(0); return; } data.orderType = 'product'; $.post('/join_shopping_cart',data,function(res){ layer.msg(res.msg); }) }) function showToastTel(){ layer.open({ type: 1, skin: 'layui-layer-rim', title: ['娓╅Θ鎻愮ず', 'font-size:14px;background: linear-gradient(#fff, #f49110);'], shade: [0.7,'#000'], area: [window.innerWidth>800?'725px':''], content: '
璇锋嫧鎵撳鏈嶇儹绾军span style="color: #EE770B;">'+sysConfig.site_tel+'鍜ㄨ浜у搧浠锋牸
' }); } $(".specifications .item").click(function(){ $('.specifications .active').removeClass('active'); $(this).addClass('active'); var mlh = $(this).attr('data-mlh'); $(".info .catalogNumber").html(mlh); charging(); }) $(".number .btn").click(function(){ var num = $(".number input").val(); if($(this).index() == 2) num++; else num--; if(num < 1) return; $(".number input").val(num); charging(); }) $(".number input").change(function(){ var num = $(this).val(); if(num < 1) $(this).val(1); charging(); }) function charging(){ var money = $('.specifications .active').attr('data-money'); var num = $(".number input").val(); var discount = $('.specifications .active').attr('data-discount'); $(".more .money").html('锟?+(money )); if(discount){ $(".more .discount").show().find("span").html('锟?+discount); }else $(".more .discount").hide(); } })