product.detail.js 15.1 KB
webpackJsonp([1],{0:function(o,e,t){function n(){var o=a(".cart-bar"),e=setInterval(function(){o?(window.reMarginFooter(".cart-bar"),clearInterval(e)):o=a(".cart-bar")},200)}var a=t(1),i=t(12),s=t(4),d=t(6),l=a(".goodsDiscount .discount-folder"),c=a(".goodsDiscount .first-item span"),r=document.getElementById("goodsDiscount"),u=r&&new s(r),h=a(r).find(".first-item"),f=a(".cart-bar"),m=a('input[name="limitCodeUrl"]').val(),p=t(32);n(),t(40),d(a("img.lazy")),a("#goodsDiscount h1").length<1&&a(".dropdown").remove(),new i(".banner-swiper",{lazyLoading:!0,lazyLoadingInPrevNext:!0,paginationClickable:!0,pagination:".banner-top .pagination-inner",nextButton:".my-swiper-button-next",prevButton:".my-swiper-button-prev",spaceBetween:3}),0===l.children().length&&(l.css("display","none"),c.html("")),u&&l.children().length>0&&u.on("tap",function(){l.is(":hidden")?(h.removeClass("short-text"),c.removeClass("icon-down").addClass("icon-up").html("&#xe608;"),l.slideDown()):(h.addClass("short-text"),c.removeClass("icon-up").addClass("icon-down").html("&#xe609;"),l.slideUp())}),a("#limit-sale").on("touchend",function(o){var e,t,n=a("#loginUrl").val();o.stopPropagation(),n?window.location=n:(p.showDialog({dialogText:"进入有货APP,获取限购码",hasFooter:{rightBtnText:"打开Yoho!Buy有货APP"}},function(){t=document.createElement("iframe"),t.src=m,t.style.display="none",document.body.appendChild(t),window.location.href=m,e=Date.now(),window.setTimeout(function(){document.body.removeChild(t),Date.now()-e<3200&&(window.location.href="http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho")},3e3)},null,!0),a(".dialog-wrapper").off("touchstart").on("touchstart",function(o){o.stopPropagation(),a(o.target).hasClass("dialog-wrapper")&&p.hideDialog()}))}),t(38),t(37),t(41),a.ajax({type:"GET",url:"/cart/index/count",success:function(o){var e;if(200===o.code){if(e=o.data.cart_goods_count||0,0===e)return!1;e>99&&(e="99+"),f.find(".num-tag").html(e).removeClass("hide")}}}),a(".good-detail-page").length>0&&a("#yoho-footer").css("border-top","1px solid #e0e0e0")},2:function(o,e,t){function n(o,e){var t,n;"undefined"!=typeof o&&(t=o.toString(),n=e&&e>0?e:2e3,a.text(t).show(),i=setTimeout(function(){"block"===a.css("display")&&a.hide()},n))}var a,i,s=t(1);!function(){var o='<div id="yoho-tip" class="yoho-tip"></div>';s(".yoho-page").append(o),a=s("#yoho-tip"),a.on("touchend",function(){a.hide(),clearTimeout(i)})}(),e.show=n},5:function(o,e,t){function n(o){var e='<div class="loading-mask hide"><div class="loading"><div></div><div></div><div></div></div></div>';c=!0,o||(o=l),o.append(e),s=o.children(".loading-mask"),d("body").on("touchstart touchmove touchend",".loading-mask",function(){return!1})}function a(){c||(n(),c=!0),s.removeClass("hide")}function i(){s.addClass("hide")}var s,d=t(1),l=d(".yoho-page"),c=!1;e.init=n,e.showLoadingMask=a,e.hideLoadingMask=i,e.show=a,e.hide=i},22:function(o,e,t){function n(){var o=A(".chose-panel").find(".num .btn>.iconfont");o.hasClass("disabled")?null:o.addClass("disabled"),W.off("touchstart",".btn-minus"),W.off("touchstart",".btn-plus")}function a(){x=!1,T=!1,I=null,S=A.queryString(),v=A(".chose-panel").find(".thumb"),M=A(".chose-panel .main .chose-items"),E=A(".chose-items"),P=A(".size-list ul"),D=A(".color-list ul"),w=A("#left-num"),L=A(".cart-bar"),y=0,k=0,z=0}function i(o,e){A("#chose-btn-sure").html("确认"),z=1,j=o,_=e}function s(o,e){n(),A("#chose-btn-sure").html("立即购买"),F=o,H=e}function d(){var o=A(".chose-panel"),e=A("#promotionId");o&&o.remove(),e&&e.remove()}function l(){return x||T?x?T?!0:(O.show("请选择尺码~"),!1):(O.show("请选择颜色~"),!1):(O.show("请选择颜色和尺码~"),!1)}function c(o,e){o&&(G.html(o),""!==A("#promotionId").val()&&n(),a()),A(".chose-panel").show(),p=A("#good-num"),B=e,V.disableScroll(M)}function r(){A(".chose-panel").hide(),V.enableScroll(M),L.length>0&&L.show()}function u(){g=E.find(".chosed"),2===g.closest(".zero-stock").length?A("#chose-btn-sure").css("background-color","#c0c0c0").html("已售罄"):F?A("#chose-btn-sure").css("background-color","#eb0313").html("立即购买"):A("#chose-btn-sure").css("background-color","#eb0313").html(z?"确认":"加入购物车")}function h(o){o>0?(N.length>0?E.find(".num .left-num").html("即将售罄"):E.find(".num .left-num").html("剩余"+o+"件"),w.val(o)):(E.find(".num .left-num").html(""),w.val(0))}function f(o){var e,t;if(y&&I&&I.length>0){for(I.removeClass("chosed"),e=P.eq(o).children(),t=0;t<e.length;t++)if(A(e[t]).data("id")===I.data("id"))return I=A(e[t]),S="#"+I.data("id"),y=A(S).data("index"),I.addClass("chosed"),I.data("num");return I=null,T=!1,D.eq(y).addClass("hide"),D.eq(0).removeClass("hide"),y=0,-1}return 0}function m(o){return k&&q&&q.length>0?(q.removeClass("chosed"),q=A(D.eq(o).children().get(k-1)),q.addClass("chosed"),q.data("num")):0}var p,g,v,w,b,C,y,k,x,T,I,P,q,D,B,E,S,M,L,z,_,j,F,H,A=t(1),O=t(2),U=t(5),V=t(33),G=A("#chose-panel"),N=A(".soonSoldOut-tag"),W=A(".yoho-page");a(),W.on("touchstart",".chose-panel",function(o){var e=A(o.target);if(!(e.closest(".main").length>0))return r(),!1}),W.on("touchstart",".color-list .block",function(){var o,e=A(this),t=e.index();e.hasClass("chosed")?(E.find(".num .left-num").html(""),w.val(0),x=!1,P.eq(k).addClass("hide"),P.eq(0).removeClass("hide"),k=0,f(0)):(x=!0,P.eq(k).addClass("hide"),o=f(t+1),h(o),P.eq(t+1).removeClass("hide"),k=t+1,q=e,v.addClass("hide").eq(t).removeClass("hide")),e.siblings(".chosed").removeClass("chosed"),-1===o?(q=A(D.eq(0).children().get(t)),q.addClass("chosed")):e.toggleClass("chosed"),A("#good-num").val(1),u()}).on("touchstart",".size-list .block",function(){var o,e,t=A(this);t.hasClass("chosed")?(E.find(".num .left-num").html(""),w.val(0),T=!1,D.eq(y).addClass("hide"),D.eq(0).removeClass("hide"),y=0,m(0)):(T=!0,o=A("#"+t.data("id")).data("index")-1,D.eq(y).addClass("hide"),e=m(o+1),h(e),D.eq(o+1).removeClass("hide"),y=o+1,I=t),t.siblings(".chosed").removeClass("chosed"),t.toggleClass("chosed"),A("#good-num").val(1),u()}),W.on("touchstart",".btn-minus",function(){var o=parseInt(p.val(),10);return b=A("#left-num").val(),l()?1===o||b-0===0?void O.show("您选择的数量不能为零~"):0>o?void O.show("您选择的数量不能为负数~"):void p.val(o-1):void 0}).on("touchstart",".btn-plus",function(){var o=parseInt(p.val(),10);return b=A("#left-num").val(),l()&&o-0!==b&&0!==b?o>b-1?void O.show("您选择的数量超过了最大库存量~"):void p.val(o+1):void 0}).on("touchstart","#chose-btn-sure",function(){var o,e,t,n,a=A("#good-num").val()-0,i=parseInt(p.val(),10);if(l()&&"已售罄"!==A("#chose-btn-sure").html()){if(b=A("#left-num").val()-0,i>b)return void O.show("您选择的数量超过了最大库存量~");if(0>i)return void O.show("您选择的数量小于一件~");if(g=A(".block-list>ul>li.chosed"),2===g.length&&0===g.closest(".zero-stock").length){if(o=I.data("skuid"),e=A("#promotionId").val(),C)return!1;if(C=!0,U.showLoadingMask(),z)t={new_product_sku:o,old_product_sku:j,buy_number:a,selected:_},n="/cart/index/modify";else{if(F)return A(this).css("background-color","#ccc").removeAttr("id"),n=A("#limitProductPay").val()+"?limitproductcode="+F+"&sku="+o+"&skn="+H+"&buy_number="+a,d(),U.showLoadingMask(),A.ajax({url:n}).then(function(o){o.error?(O.show(o.message),setTimeout(function(){location.reload()},2e3)):location.href=n}).fail(function(){O.show("网络异常!"),setTimeout(function(){location.reload()},2e3)}),!1;t={productSku:o,buyNumber:a,promotionId:e,isEdit:z,cartType:S.cartType},n="/cart/index/add"}A.ajax({method:"POST",url:n,data:t}).done(function(o){var e;U.hideLoadingMask(),200!==o.code||z||(e=o.data.goods_count,e>99&&(e="99+"),A(".num-tag").html(e).removeClass("hide"),C=!1,B&&B()),o.message&&!z&&O.show(o.message),r(),z&&(U.showLoadingMask(),setTimeout(function(){window.location.href="/cart/index/index?cartType="+A("#cartType").val()},1))}).fail(function(){O.show("网络出了点问题~")}).always(function(){C=!1})}}}),e.init=a,e.show=c,e.remove=d,e.setEditModeWithSknId=i,e.disableNumEdit=n,e.setLimitGoodModeWithSknId=s},32:function(o,e,t){function n(){return null===i&&(i='<div id="dialog-wrapper" class="dialog-wrapper"><div class="dialog-box">{{# hasHeader}}{{/ hasHeader}}<div class="dialog-content">{{dialogText}}</div>{{# hasFooter}}<div class="dialog-footer">{{# leftBtnText}}<span class="dialog-left-btn tap-hightlight">{{.}}</span>{{/ leftBtnText}}{{# rightBtnText}}<span class="dialog-right-btn tap-hightlight">{{.}}</span>{{/ rightBtnText}}</div>{{/ hasFooter}}</div></div>',s=l.compile(i)),s}var a,i,s,d=t(1),l=t(19),c=t(4);e.showDialog=function(o,e,t,i){var l,r,u,h=s(o);s=n(),d(".dialog-wrapper").remove(),d("body").append(d(h)),l=d(".dialog-box"),a=d(".dialog-wrapper"),u=new c(document.getElementById("dialog-wrapper")),o.fast?a.css({display:"block"}):a.fadeIn(),i&&(d(".dialog-wrapper .dialog-footer > span").css("width","100%"),d(".dialog-wrapper .dialog-content").css({"padding-left":"1.85rem","padding-right":"1.85rem"}),a.css("z-index","10")),l.css({top:"50%",marginTop:-(l.height()/2)}),o.autoHide&&(r=1e3,o.autoHide>1&&(r=o.autoHide),setTimeout(function(){a.fadeOut()},r)),a.on("touchmove",function(){return!1}),u.on("tap",function(o){if(d(o.target).hasClass("dialog-left-btn"))"function"==typeof t&&t(),a.fadeOut();else if(d(o.target).hasClass("dialog-right-btn"))return e();o.preventDefault(),o.srcEvent.stopPropagation()})},e.hideDialog=function(){d(".dialog-wrapper").remove()}},33:function(o,e,t){function n(o){o=o||window.event,o.preventDefault&&o.preventDefault(),o.returnValue=!1}function a(o){o=o||window.event,o.stopPropagation&&o.stopPropagation(),o.cancelBubble=!1}function i(o){var e=o.wheelDelta||o.originalEvent.wheelDelta||o.detail||0,t=l(this).get(0);return a(o),l(t).height()+t.scrollTop>=t.scrollHeight&&0>e?(n(o),!1):0===t.scrollTop&&e>0?(n(o),!1):void 0}function s(o){var e,t;o.on("mousewheel",i),o.on("touchstart",function(o){e=o.originalEvent.changedTouches[0].pageX,t=o.originalEvent.changedTouches[0].pageY}),o.on("touchmove",function(o){var n=o.originalEvent.changedTouches[0].pageX-e,a=o.originalEvent.changedTouches[0].pageY-t,i=l(this).get(0);return o.stopPropagation(),Math.abs(a)<Math.abs(n)?(o.preventDefault(),!1):l(i).height()+i.scrollTop>=i.scrollHeight&&0>a?(o.preventDefault(),!1):0===i.scrollTop&&a>0?(o.preventDefault(),!1):void 0}),l(document).on("mousewheel",n),l(document).on("touchmove",n)}function d(o){o.off("touchstart"),o.off("touchmove"),o.off("mousewheel"),l(document).off("mousewheel",n),l(document).off("touchmove",n)}var l=t(1);e.enableScroll=d,e.disableScroll=s},37:function(o,e,t){var n,a,i=t(1),s=t(2),d=t(4),l=document.getElementById("nav-tab"),c=l&&new d(l),r=document.getElementById("goto-consult"),u=r&&new d(r),h=document.getElementById("readmore"),f=h&&new d(h);!function(){a=i("#nav-tab .consults-num").html()-0,n=i("#nav-tab .comments-num").html()-0,i("#nav-tab li").each(function(){i(this).removeClass("focus")}),i("#feedback-content .content").each(function(){i(this).addClass("hide")}),0!==n?(i("#nav-tab .comment-nav").addClass("focus"),i("#feedback-content .comment-content").removeClass("hide")):0!==a&&(i("#nav-tab .consult-nav").addClass("focus"),i("#feedback-content .consult-content").removeClass("hide"))}(),c&&c.on("tap",function(o){var e=i(o.target).closest("li"),t=e.index();e.hasClass("comment-nav")&&0===n?s.show("暂无商品评价"):e.hasClass("focus")||(i("#nav-tab li").each(function(){i(this).removeClass("focus")}),i("#feedback-content .content").each(function(){i(this).addClass("hide")}),e.addClass("focus"),i("#feedback-content .content:eq("+t+")").removeClass("hide"))}),u&&u.on("tap",function(){location.href=i(r).find("a").attr("href")}),i(".goods-consults-page").length>0&&i("#yoho-header").css("position","fixed").css("top","0"),i(".goods-consults-page").length>0&&i("#yoho-footer").css("border-top","1px solid #e0e0e0"),f&&f.on("tap",function(){return i(".readmore").hide(),i(".goods-consults.customer-consults").removeClass("customer-consults"),!1}),t(39)},38:function(o,e,t){function n(o){var e,t;o.length>0&&(e=o[0].getBoundingClientRect().right,t=o.find(".swiper-slide:last-child")[0].getBoundingClientRect().right,0>t-e?o.next(".tips").css("display","none"):o.next(".tips").css("display","block"))}function a(o,e){var t=null;l(o).each(function(n){t=l(o).slice(n,n+e),t.length===e&&n%e===0&&l(t).wrapAll(l('<div class="js-wraper"></div>'))})}function i(){p||g||(p=!0,u.showLoadingMask(),l.ajax({type:"GET",url:f,success:function(o){d=l("#productDesc"),d.append(o),window.rePosFooter(),c(d.find("img.lazy")),new r("#size-swiper-container",{slidesPerView:"auto"}),new r("#reference-swiper-container",{slidesPerView:"auto"}),n(l("#size-swiper-container")),n(l("#reference-swiper-container")),a(".detail .column",2),p=!1,g=!0,u.hideLoadingMask()},error:function(){h.show("网络断开连接了~"),p=!1,u.hideLoadingMask()}}))}function s(){(!g||l(window).scrollTop()+m>=l(document).height()-200)&&i()}var d,l=t(1),c=t(6),r=t(12),u=t(5),h=t(2),f=l("#introUrl").val(),m=l(window).height(),p=!1,g=!1;l(window).scroll(function(){window.requestAnimationFrame(s)})},39:function(o,e,t){function n(o){var e=o.find(".animate-count");e.css("display","inline"),e.animate({opacity:.25,fontSize:"0.7rem",right:"-=5"},300,function(){e.css("display","none")})}var a,i,s=t(1),d=t(4),l=t(2),c=s("#goods-consults")[0],r=c&&new d(c);!function(){var o=window.location.search.substring(1);a=o.split("&")[0].split("=")[1],i=o.split("&")[1]?o.split("&")[1].split("=")[1]:null}(),r&&r.on("tap",function(o){var e,t=s(o.target).closest("li"),d=t.closest(".consult-item").data("id"),c=t.find(".count").html()-0;t.hasClass("highlight")||(t.hasClass("fav")?e="/product/detail/consultupvote":t.hasClass("useful")&&(e="/product/detail/consultuseful"),s.ajax({method:"post",url:e,data:{id:d,productId:a,total:i}}).done(function(o){200===o.code?(n(t),t.addClass("highlight"),t.find(".count").html(c+1)):401===o.code&&(location.href=o.data)}).fail(function(){l.show("网络断开连接了~")}))})},40:function(o,e,t){var n=t(1),a=t(2),i=t(22),s=n("#productId").val(),d=n("#productSkn").val(),l=n("#limitProductCode").val();n("#likeBtn").on("touchstart",function(){var o,e,t=n(this);return t.hasClass("liked")?(o="cancel",e=0):(o="ok",e=1),n.ajax({type:"POST",url:"/product/opt/favoriteProduct",data:{id:s,opt:o},success:function(e){200===e.code?(t.toggleClass("liked"),"cancel"===o?a.show("取消收藏成功"):"ok"===o&&a.show("收藏成功")):400===e.code?location.href=e.data:a.show(e.message)},error:function(){a.show("网络断开连接了~")}}),window._yas&&window._yas.sendCustomInfo({pd:s,fa:e},!0),!1}),n("#addtoCart").on("touchstart",function(){return n(".cart-bar").hide(),l&&i.setLimitGoodModeWithSknId(l,d),i.show(),window._yas&&window._yas.sendCustomInfo({pd:s,by:1},!0),!1})},41:function(o,e,t){function n(){u||r||(u=!0,l&&s.get(l).then(function(o){o.length<5?d.css("display","none"):(d.html(o).show(),s("#swiper-recommend").length&&new i("#swiper-recommend",{slidesPerView:"auto",grabCursor:!0,slideElement:"a",lazyLoading:!0,watchSlidesVisibility:!0})),u=!1,r=!0,window.rePosFooter()}).fail(function(){d.hide()}))}function a(){(!r||s(window).scrollTop()+c>=s(document).height()-200)&&n()}var i=t(12),s=t(1),d=s(".recommend-for-you"),l=s("#preferenceUrl").val(),c=s(window).height(),r=!1,u=!1;s(window).scroll(function(){window.requestAnimationFrame(a)})}});