$(function(){ $('.productView').owlCarousel({ loop : true, items : 1, nav : true, navText : ['',''], }); /* 上方切換列,該分類所有商品 */ $(".top_productbox").owlCarousel({ loop : false, responsive:{ 0:{ items : 2 }, 320:{ items : 3 }, 480:{ items : 6 }, 660:{ items : 8 }, 768:{ items : 9 }, 1023:{ items : 10 } }, nav : true, navText : ['',''], }); //猜你喜歡,瀏覽紀錄,其他人也買了 $("article .recommend_l,article .history_l,article .other_l").owlCarousel({ nav : true, navText : ['',''], responsive:{ 0:{ items : 2 }, 480:{ items : 3 }, 768:{ items : 4 }, 1024:{ items : 5 } }, }); /*評論預覽商品圖*/ $(".pic-box").on("click",".pic-over",function(){ var _this = $(this), pic_src = _this.find("img").attr('src'); _this.parents(".pic-box").find(".click").removeClass("click"); _this.addClass("click"); _this.parents(".pic-box").find(".pic-viewer").addClass("click") .find('img').attr({src: pic_src}); }); $('.pic-box').on('click', '.close', function(event) { var _this = $(this).parents(".pic-box"); _this.find(".pic-viewer").removeClass("click"); _this.find(".click").removeClass("click"); }); /* 使用者已選購區塊 */ var owl_main = $(".mainbox .orderSlide"); owl_main.owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 } }, nav : true, navText : ['',''], onRefresh : callback, }); var owl_add = $(".addbox .orderSlide"); owl_add.owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 } }, nav : true, navText : ['',''], onRefresh : callback, }); function callback(event){ setTimeout(function(){ $('.hidebox').animate({'opacity':1}).removeClass('hidebox'); }, 300); } /* 加購商品選購效果 */ $('article .content-add ').on('click','.button-primary',function(){ var img = $(this).parents('.productItem'), img_src = img.find('img').attr('src'), img_title = img.find('.title').html(), img_price = img.find('.font-big').html(), img_id = $(this).attr("SID"), img_num = img.find('.num-select').val(); var html = '
'+img_title+'
NT$'+img_price+'
刪除
'; var smailBox = $('.addbox .orderSlide'), smailBox_top = smailBox.offset().top, smailBox_left = smailBox.offset().left, smailBox_width = smailBox.width()/2, smailBox_height = smailBox.height()-20; for(var i=0;i
'+img_title+'
NT$'+img_price+'
刪除
'; var now_order = $('.mainbox .'+ img_class); var change_n = n-now_order.length; if(change_n>0){ for(var i=0;i 768 && change!=960 ){ change = 960; moreview = true; zoonbox(pic_h,pic_w) }else if(_window.width() <= 768 && change!= 768){ change = 768; $('.productBox').on('click','.fa-search-plus',function(){ var pic_path = $(this).prev('.viewbox').attr('pic_path'); console.log(pic_path); var str='
'; $('body').append(str); }); $('body').on('click', '.picBigView .fa-times', function(event) { $('.picBigView').remove(); }); }; $('article').on('click','.open-preview',function(){ var nowitem = $('.productImg .active').prevAll('.owl-item').length-2; $('article .previewbox').css('display','block') .find('img').eq(nowitem).css('display','block'); }); $('article').on('click','.close',function(){ $('article .previewbox').removeAttr('style') .find('img').removeAttr('style'); }); _window.on('resize',function(){ if(_window.width() <= 1023 && change_1023 != 1023){ change_1023 = 1023; }else if(_window.width() > 1023 && change_1023 != 1200){ change_1023 = 1200; } if(_window.width() > 768 && change != 960){ change = 960; zoonbox(pic_h,pic_w) $('.productBox').off('click','.fa-search-plus'); }else if(_window.width() <= 768 && change != 768){ change = 768; $('.productBox').off('mouseenter mousemove mouseleave','.pic'); $('.productBox').on('click','.fa-search-plus',function(){ var pic_path = $(this).prev('.viewbox').attr('pic_path'); console.log(pic_path); var str='
'; $('body').append(str); }); $('body').on('click', '.picBigView .fa-times', function(event) { $('.picBigView').remove(); }); }; }); }); /* 放大鏡效果 */ function zoonbox(pic_h,pic_w){ var mouse_in = false; $('.productBox').off('mouseenter mousemove mouseleave','.pic'); $('.productBox').on('mouseenter','.pic',function(){ $(this).find('.viewbox').css('opacity','1'); mouse_in = true; }).on('mousemove','.pic',function(e){ if(!mouse_in){ $(this).find('.viewbox').css('opacity','1'); mouse_in = true; } // $(this).find('.viewbox').css('opacity','1'); var move_h = (e.offsetY/pic_h)*-(900-pic_h); var move_w = (e.offsetX/pic_w)*-(900-pic_w); $(this).find('.viewbox').css({ 'background-position-y':move_h, 'background-position-x':move_w }); }).on('mouseleave','.pic',function(){ $(this).find('.viewbox').css('opacity','0'); mouse_in = false; }); } }(jQuery));