product.detail.js 18.9 KB
webpackJsonp([2],{0:function(o,e,t){function n(){var o=i(".cart-bar"),e=setInterval(function(){o?(window.reMarginFooter(".cart-bar"),clearInterval(e)):o=i(".cart-bar")},200)}var i=t(1),a=t(12),s=t(4),d=t(7),r=i(".goodsDiscount .discount-folder"),c=i(".goodsDiscount .first-item span"),l=document.getElementById("goodsDiscount"),u=l&&new s(l),h=i(l).find(".first-item"),f=i(".cart-bar"),m=i('input[name="limitCodeUrl"]').val(),p=t(21);t(3),n(),t(47),d(i("img.lazy")),i("#goodsDiscount h1").length<1&&i(".dropdown").remove(),new a(".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===r.children().length&&(r.css("display","none"),c.html("")),u&&r.children().length>0&&u.on("tap",function(){r.is(":hidden")?(h.removeClass("short-text"),c.removeClass("icon-down").addClass("icon-up").html("&#xe608;"),r.slideDown()):(h.addClass("short-text"),c.removeClass("icon-up").addClass("icon-down").html("&#xe609;"),r.slideUp())}),i("#limit-sale").on("touchend",function(o){var e,t,n=i("#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),i(".dialog-wrapper").off("touchstart").on("touchstart",function(o){o.stopPropagation(),i(o.target).hasClass("dialog-wrapper")&&p.hideDialog()}))}),t(45),t(44),t(48),i.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")}}}),i(".good-detail-page").length>0&&i("#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,i.text(t).show(),a=setTimeout(function(){"block"===i.css("display")&&i.hide()},n))}var i,a,s=t(1);!function(){var o='<div id="yoho-tip" class="yoho-tip"></div>';s(".yoho-page").append(o),i=s("#yoho-tip"),i.on("touchend",function(){i.hide(),clearTimeout(a)})}(),e.show=n},3:function(o,e,t){function n(o){var e,t,n=document.cookie;return document.cookie&&""!==document.cookie&&(t=n.indexOf(o+"="),t>-1&&(t+=o.length+1,e=decodeURIComponent(f.trim(n.substring(t,n.indexOf(";",t)))))),e}function i(o,e,t){var n,i,a,s,d="";"undefined"!=typeof e&&(t=t||{},null===e&&(e="",t.expires=-1),t.expires&&("number"==typeof t.expires||t.expires.toUTCString)&&("number"==typeof t.expires?(s=new Date,s.setTime(s.getTime()+24*t.expires*60*60*1e3)):s=t.expires,d="; expires="+s.toUTCString()),n=t.path?"; path="+t.path:"",i=t.domain?"; domain="+t.domain:"",a=t.secure?"; secure":"",document.cookie=[o,"=",encodeURIComponent(e),d,n,i,a].join(""))}function a(){var o=!!navigator.cookieEnabled;return"undefined"!=typeof navigator.cookieEnabled||o||(document.cookie="testcookie",o=-1!==document.cookie.indexOf("testcookie")),o}function s(){var o,e=n("_UID");return"undefined"==typeof e?0:(o=e.split("::"),"undefined"==typeof o||o.length<4?0:o)}function d(){var o=s();return 0===o?0:o[1]}function r(){var o=n("_g");return"undefined"==typeof o?"":JSON.parse(o).k}function c(){var o;0!==p.length&&(o=Math.min(f(window).height(),window.screen.availHeight),f("body").height()<=o-parseInt(p.css("height"),0)?p.addClass("bottom"):p.removeClass("bottom"))}function l(o){var e=f(o).outerHeight();o&&p.css("margin-bottom",e+"px")}function u(){var o,e,t=[],n=window.location.search.slice(1).split("&");for(e=0;e<n.length;e++)o=n[e].split("="),t.push(o[0]),t[o[0]]=o[1];return t}function h(o){return o.replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")}var f=t(1),m=t(4),p=f("#yoho-footer"),g=f(".yoho-page"),v=f(".yoho-header");!function(){var o,e=p.children(".op-row"),t=f(".back-to-top"),n=s();c(),0===n?e.prepend('<a href="http://m.yohobuy.com/signin.html?refer='+location.href+'">登录</a><span class="sep-line">|</span><a href="http://m.yohobuy.com/reg.html">注册</a>'):e.prepend('<span>Hi,</span><a class="user-name" href="http://m.yohobuy.com/home?tmp='+Math.random()+'">'+n[0]+'</a><a href="http://m.yohobuy.com/passport/signout/index">退出</a>'),t.length>0&&(o=new m(t[0]),o.on("tap",function(o){return f(window).scrollTop(0),o.srcEvent.preventDefault(),!1})),p.removeClass("hide")}(),function(o,e,t,n,i){var a=e.createElement(t),s=e.getElementsByTagName(t)[0];o.YohoAcquisitionObject=i,o[i]=function(){o[i].p=arguments},a.async=1,a.src=n,s.parentNode.insertBefore(a,s)}(window,document,"script",("https:"===document.location.protocol?"https":"http")+"://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js","_yas"),function(){var o=d();o=0===o?"":o,window._ozuid=o,window._yas&&window._yas(1*new Date,"1.0.17","yohobuy_m",o,"","")}(),v.on("touchstart","a",function(){v.find("a").removeClass("highlight"),f(this).addClass("highlight")}).on("touchend touchcancel","a",function(){f(this).removeClass("highlight")}),g.on("touchstart",".tap-hightlight",function(){f(this).siblings(".tap-hightlight").removeClass("highlight"),f(this).addClass("highlight")}).on("touchend touchcancel",".tap-hightlight",function(){f(this).removeClass("highlight")}),f(".nav-home").on("touchstart",function(){f(".homebuttom").toggleClass("hide")}),function(){var o,e,t=0,n="webkit moz ms o".split(" "),i=window.requestAnimationFrame,a=window.cancelAnimationFrame;for(e=0;e<n.length&&(!i||!a);e++)o=n[e],i=i||window[o+"RequestAnimationFrame"],a=a||window[o+"CancelAnimationFrame"]||window[o+"CancelRequestAnimationFrame"];i&&a||(i=function(o){var e=(new Date).getTime(),n=Math.max(0,16-(e-t)),i=window.setTimeout(function(){o(e+n)},n);return t=e+n,i},a=function(o){window.clearTimeout(o)}),window.requestAnimationFrame=i,window.cancelAnimationFrame=a}(),f.extend({queryString:u}),11===p.find(".user-name").text().length&&p.find(".user-name").html(h(p.find(".user-name").text())),window.cookie=n,window.setCookie=i,window.isCookiesEnabled=a,window.getUser=s,window.getUid=d,window.getShoppingKey=r,window.rePosFooter=c,window.reMarginFooter=l,window.queryString=u()},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=r),o.append(e),s=o.children(".loading-mask"),d("body").on("touchstart touchmove touchend",".loading-mask",function(){return!1})}function i(){c||(n(),c=!0),s.removeClass("hide")}function a(){s.addClass("hide")}var s,d=t(1),r=d(".yoho-page"),c=!1;e.init=n,e.showLoadingMask=i,e.hideLoadingMask=a,e.show=i,e.hide=a},21:function(o,e,t){var n=t(1),i=t(19),a=t(4);e.showDialog=function(o,e,t,s){function d(){var o,e=null;return null===e&&(e='<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>',o=i.compile(e)),o}var r,c,l,u,h;r=d()(o),n(".dialog-wrapper").remove(),n("body").append(n(r)),c=n(".dialog-box"),u=n(".dialog-wrapper"),h=new a(document.getElementById("dialog-wrapper")),o.fast?u.css({display:"block"}):u.fadeIn(),s&&(n(".dialog-wrapper .dialog-footer > span").css("width","100%"),n(".dialog-wrapper .dialog-content").css({"padding-left":"1.85rem","padding-right":"1.85rem"}),u.css("z-index","10")),c.css({top:"50%",marginTop:-(c.height()/2)}),o.autoHide&&(l=1e3,o.autoHide>1&&(l=o.autoHide),setTimeout(function(){u.fadeOut()},l)),u.on("touchmove",function(){return!1}),h.on("tap",function(o){if(n(o.target).hasClass("dialog-left-btn"))"function"==typeof t&&t(),u.fadeOut();else if(n(o.target).hasClass("dialog-right-btn"))return e();o.preventDefault(),o.srcEvent.stopPropagation()})},e.hideDialog=function(){n(".dialog-wrapper").remove()}},25:function(o,e,t){function n(){var o=U(".chose-panel").find(".num .btn>.iconfont");o.hasClass("disabled")?null:o.addClass("disabled"),G.off("touchstart",".btn-minus"),G.off("touchstart",".btn-plus")}function i(){x=!1,T=!1,q=null,B=U.queryString(),v=U(".chose-panel").find(".thumb"),_=U(".chose-panel .main .chose-items"),S=U(".chose-items"),I=U(".size-list ul"),E=U(".color-list ul"),w=U("#left-num"),M=U(".cart-bar"),C=0,k=0,F=0}function a(o,e){U("#chose-btn-sure").html("确认"),F=1,A=o,z=e}function s(o,e){n(),U("#chose-btn-sure").html("立即购买"),L=o,j=e}function d(){var o=U(".chose-panel"),e=U("#promotionId");o&&o.remove(),e&&e.remove()}function r(){return x||T?x?T?!0:(H.show("请选择尺码~"),!1):(H.show("请选择颜色~"),!1):(H.show("请选择颜色和尺码~"),!1)}function c(o,e){o&&(R.html(o),""!==U("#promotionId").val()&&n(),i()),U(".chose-panel").show(),p=U("#good-num"),P=e,N.disableScroll(_)}function l(){U(".chose-panel").hide(),N.enableScroll(_),M.length>0&&M.show()}function u(){g=S.find(".chosed"),2===g.closest(".zero-stock").length?U("#chose-btn-sure").css("background-color","#c0c0c0").html("已售罄"):L?U("#chose-btn-sure").css("background-color","#eb0313").html("立即购买"):U("#chose-btn-sure").css("background-color","#eb0313").html(F?"确认":"加入购物车")}function h(o){o>0?(V.length>0?S.find(".num .left-num").html("即将售罄"):S.find(".num .left-num").html("剩余"+o+"件"),w.val(o)):(S.find(".num .left-num").html(""),w.val(0))}function f(o){var e,t;if(C&&q&&q.length>0){for(q.removeClass("chosed"),e=I.eq(o).children(),t=0;t<e.length;t++)if(U(e[t]).data("id")===q.data("id"))return q=U(e[t]),B="#"+q.data("id"),C=U(B).data("index"),q.addClass("chosed"),q.data("num");return q=null,T=!1,E.eq(C).addClass("hide"),E.eq(0).removeClass("hide"),C=0,-1}return 0}function m(o){return k&&D&&D.length>0?(D.removeClass("chosed"),D=U(E.eq(o).children().get(k-1)),D.addClass("chosed"),D.data("num")):0}var p,g,v,w,b,y,C,k,x,T,q,I,D,E,P,S,B,_,M,F,z,A,L,j,U=t(1),H=t(2),O=t(5),N=t(40),R=U("#chose-panel"),V=U(".soonSoldOut-tag"),G=U(".yoho-page");i(),G.on("touchstart",".chose-panel",function(o){var e=U(o.target);if(!(e.closest(".main").length>0))return l(),!1}),G.on("touchstart",".color-list .block",function(){var o,e=U(this),t=e.index();e.hasClass("chosed")?(S.find(".num .left-num").html(""),w.val(0),x=!1,I.eq(k).addClass("hide"),I.eq(0).removeClass("hide"),k=0,f(0)):(x=!0,I.eq(k).addClass("hide"),o=f(t+1),h(o),I.eq(t+1).removeClass("hide"),k=t+1,D=e,v.addClass("hide").eq(t).removeClass("hide")),e.siblings(".chosed").removeClass("chosed"),-1===o?(D=U(E.eq(0).children().get(t)),D.addClass("chosed")):e.toggleClass("chosed"),U("#good-num").val(1),u()}).on("touchstart",".size-list .block",function(){var o,e,t=U(this);t.hasClass("chosed")?(S.find(".num .left-num").html(""),w.val(0),T=!1,E.eq(C).addClass("hide"),E.eq(0).removeClass("hide"),C=0,m(0)):(T=!0,o=U("#"+t.data("id")).data("index")-1,E.eq(C).addClass("hide"),e=m(o+1),h(e),E.eq(o+1).removeClass("hide"),C=o+1,q=t),t.siblings(".chosed").removeClass("chosed"),t.toggleClass("chosed"),U("#good-num").val(1),u()}),G.on("touchstart",".btn-minus",function(){var o=parseInt(p.val(),10);return b=U("#left-num").val(),r()?1===o||b-0===0?void H.show("您选择的数量不能为零~"):0>o?void H.show("您选择的数量不能为负数~"):void p.val(o-1):void 0}).on("touchstart",".btn-plus",function(){var o=parseInt(p.val(),10);return b=U("#left-num").val(),r()&&o-0!==b&&0!==b?o>b-1?void H.show("您选择的数量超过了最大库存量~"):void p.val(o+1):void 0}).on("touchstart","#chose-btn-sure",function(){var o,e,t,n,i=U("#good-num").val()-0,a=parseInt(p.val(),10);if(r()&&"已售罄"!==U("#chose-btn-sure").html()){if(b=U("#left-num").val()-0,a>b)return void H.show("您选择的数量超过了最大库存量~");if(0>a)return void H.show("您选择的数量小于一件~");if(g=U(".block-list>ul>li.chosed"),2===g.length&&0===g.closest(".zero-stock").length){if(o=q.data("skuid"),e=U("#promotionId").val(),y)return!1;if(y=!0,O.showLoadingMask(),F)t={new_product_sku:o,old_product_sku:A,buy_number:i,selected:z},n="/cart/index/modify";else{if(L)return U(this).css("background-color","#ccc").removeAttr("id"),n=U("#limitProductPay").val()+"?limitproductcode="+L+"&sku="+o+"&skn="+j+"&buy_number="+i,d(),O.showLoadingMask(),U.ajax({url:n}).then(function(o){o.error?(H.show(o.message),setTimeout(function(){location.reload()},2e3)):location.href=n}).fail(function(){H.show("网络异常!"),setTimeout(function(){location.reload()},2e3)}),!1;t={productSku:o,buyNumber:i,promotionId:e,isEdit:F,cartType:B.cartType},n="/cart/index/add"}U.ajax({method:"POST",url:n,data:t}).done(function(o){var e;O.hideLoadingMask(),200!==o.code||F||(e=o.data.goods_count,e>99&&(e="99+"),U(".num-tag").html(e).removeClass("hide"),y=!1,P&&P()),o.message&&!F&&H.show(o.message),l(),F&&(O.showLoadingMask(),setTimeout(function(){window.location.href="/cart/index/index?cartType="+U("#cartType").val()},1))}).fail(function(){H.show("网络出了点问题~")}).always(function(){y=!1})}}}),e.init=i,e.show=c,e.remove=d,e.setEditModeWithSknId=a,e.disableNumEdit=n,e.setLimitGoodModeWithSknId=s},40:function(o,e,t){function n(o){o=o||window.event,o.preventDefault&&o.preventDefault(),o.returnValue=!1}function i(o){o=o||window.event,o.stopPropagation&&o.stopPropagation(),o.cancelBubble=!1}function a(o){var e=o.wheelDelta||o.originalEvent.wheelDelta||o.detail||0,t=r(this).get(0);return i(o),r(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",a),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,i=o.originalEvent.changedTouches[0].pageY-t,a=r(this).get(0);return o.stopPropagation(),Math.abs(i)<Math.abs(n)?(o.preventDefault(),!1):r(a).height()+a.scrollTop>=a.scrollHeight&&0>i?(o.preventDefault(),!1):0===a.scrollTop&&i>0?(o.preventDefault(),!1):void 0}),r(document).on("mousewheel",n),r(document).on("touchmove",n)}function d(o){o.off("touchstart"),o.off("touchmove"),o.off("mousewheel"),r(document).off("mousewheel",n),r(document).off("touchmove",n)}var r=t(1);e.enableScroll=d,e.disableScroll=s},44:function(o,e,t){var n,i,a=t(1),s=t(2),d=t(4),r=document.getElementById("nav-tab"),c=r&&new d(r),l=document.getElementById("goto-consult"),u=l&&new d(l),h=document.getElementById("readmore"),f=h&&new d(h);!function(){i=a("#nav-tab .consults-num").html()-0,n=a("#nav-tab .comments-num").html()-0,a("#nav-tab li").each(function(){a(this).removeClass("focus")}),a("#feedback-content .content").each(function(){a(this).addClass("hide")}),0!==n?(a("#nav-tab .comment-nav").addClass("focus"),a("#feedback-content .comment-content").removeClass("hide")):0!==i&&(a("#nav-tab .consult-nav").addClass("focus"),a("#feedback-content .consult-content").removeClass("hide"))}(),c&&c.on("tap",function(o){var e=a(o.target).closest("li"),t=e.index();e.hasClass("comment-nav")&&0===n?s.show("暂无商品评价"):e.hasClass("focus")||(a("#nav-tab li").each(function(){a(this).removeClass("focus")}),a("#feedback-content .content").each(function(){a(this).addClass("hide")}),e.addClass("focus"),a("#feedback-content .content:eq("+t+")").removeClass("hide"))}),u&&u.on("tap",function(){location.href=a(l).find("a").attr("href")}),a(".goods-consults-page").length>0&&a("#yoho-header").css("position","fixed").css("top","0"),a(".goods-consults-page").length>0&&a("#yoho-footer").css("border-top","1px solid #e0e0e0"),f&&f.on("tap",function(){return a(".readmore").hide(),a(".goods-consults.customer-consults").removeClass("customer-consults"),!1}),t(46)},45: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 i(o,e){var t=null;r(o).each(function(n){t=r(o).slice(n,n+e),t.length===e&&n%e===0&&r(t).wrapAll(r('<div class="js-wraper"></div>'))})}function a(){p||g||(p=!0,u.showLoadingMask(),r.ajax({type:"GET",url:f,success:function(o){d=r("#productDesc"),d.append(o),window.rePosFooter(),c(d.find("img.lazy")),new l("#size-swiper-container",{slidesPerView:"auto"}),new l("#reference-swiper-container",{slidesPerView:"auto"}),n(r("#size-swiper-container")),n(r("#reference-swiper-container")),i(".detail .column",2),p=!1,g=!0,u.hideLoadingMask()},error:function(){h.show("网络断开连接了~"),p=!1,u.hideLoadingMask()}}))}function s(){(!g||r(window).scrollTop()+m>=r(document).height()-200)&&a()}var d,r=t(1),c=t(7),l=t(12),u=t(5),h=t(2),f=r("#introUrl").val(),m=r(window).height(),p=!1,g=!1;r(window).scroll(function(){window.requestAnimationFrame(s)})},46: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 i,a,s=t(1),d=t(4),r=t(2),c=s("#goods-consults")[0],l=c&&new d(c);!function(){var o=window.location.search.substring(1);i=o.split("&")[0].split("=")[1],a=o.split("&")[1]?o.split("&")[1].split("=")[1]:null}(),l&&l.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:i,total:a}}).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(){r.show("网络断开连接了~")}))})},47:function(o,e,t){var n=t(1),i=t(2),a=t(25),s=n("#productId").val(),d=n("#productSkn").val(),r=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?i.show("取消收藏成功"):"ok"===o&&i.show("收藏成功")):400===e.code?location.href=e.data:i.show(e.message)},error:function(){i.show("网络断开连接了~")}}),window._yas&&window._yas.sendCustomInfo({pd:s,fa:e},!0),!1}),n("#addtoCart").on("touchstart",function(){return n(".cart-bar").hide(),r&&a.setLimitGoodModeWithSknId(r,d),a.show(),window._yas&&window._yas.sendCustomInfo({pd:s,by:1},!0),!1})},48:function(o,e,t){function n(){u||l||(u=!0,r&&s.get(r).then(function(o){o.length<5?d.css("display","none"):(d.html(o).show(),s("#swiper-recommend").length&&new a("#swiper-recommend",{slidesPerView:"auto",grabCursor:!0,slideElement:"a",lazyLoading:!0,watchSlidesVisibility:!0})),u=!1,l=!0,window.rePosFooter()}).fail(function(){d.hide()}))}function i(){(!l||s(window).scrollTop()+c>=s(document).height()-200)&&n()}var a=t(12),s=t(1),d=s(".recommend-for-you"),r=s("#preferenceUrl").val(),c=s(window).height(),l=!1,u=!1;s(window).scroll(function(){window.requestAnimationFrame(i)})}});