Authored by Rock Zhang

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into feature/cart

Showing 29 changed files with 1588 additions and 670 deletions
framework @ e9d066dd
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
Subproject commit e9d066dd88a8e7e37103021c427a205a5cfcdcec
... ...
... ... @@ -179,6 +179,41 @@ class CartData
}
/**
* 增减购物车商品数量
*
* @param int $uid 用户ID
* @param string $sku 商品SKU
* @param int $increaseNum 增加的数目
* @param int $decreaseNum 减少的数目
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.increase';
$param['product_sku'] = $sku;
if (!empty($increaseNum)) {
$param['increase_number'] = $increaseNum;
}
if (!empty($decreaseNum)) {
$param['decrease_number'] = $decreaseNum;
}
if (!empty($uid)) {
$param['uid'] = $uid;
}
if ($shoppingKey !== null) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
define("index",["jquery","hammer","swiper","lazyload","mlellipsis","iscroll-probe","handlebars","source-map","index"],function(e,t,o){var n;e("js/common"),e("js/category/entry"),e("js/guang/entry"),e("js/home/entry"),e("js/index/entry"),e("js/passport/entry"),e("js/product/entry"),e("js/me/entry"),o.exports=n}),define("js/common",["jquery"],function(e,t,o){function n(e){var t,o,n=document.cookie;return document.cookie&&""!==document.cookie&&(o=n.indexOf(e+"="),o>-1&&(o+=e.length+1,t=decodeURIComponent(c.trim(n.substring(o,n.indexOf(";",o)))))),t}function i(e,t,o){var n,i,a,s,r="";"undefined"!=typeof t&&(o=o||{},null===t&&(t="",o.expires=-1),o.expires&&("number"==typeof o.expires||o.expires.toUTCString)&&("number"==typeof o.expires?(s=new Date,s.setTime(s.getTime()+24*o.expires*60*60*1e3)):s=o.expires,r="; expires="+s.toUTCString()),n=o.path?"; path="+o.path:"",i=o.domain?"; domain="+o.domain:"",a=o.secure?"; secure":"",document.cookie=[e,"=",encodeURIComponent(t),r,n,i,a].join(""))}function a(){var e,t=n("_UID");return"undefined"==typeof t?0:(e=t.split("::"),"undefined"==typeof e||e.length<4?0:e)}function s(){var e=a();return 0===e?0:e[1]}function r(){var e=n("_g");return"undefined"==typeof e?"":JSON.parse(e).k}function l(){var e;0!==u.length&&(e=Math.min(c(window).height(),window.screen.availHeight),c("body").height()<=e-parseInt(u.css("height"),0)?u.addClass("bottom"):u.removeClass("bottom"))}function d(e){var t=c(e).outerHeight();e&&u.css("margin-bottom",t+"px")}var c=e("jquery"),u=c("#yoho-footer"),h=c(".yoho-page"),p=c(".yoho-header");!function(){var e=u.children(".op-row"),t=a();l(),0===t?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()+'">'+t[0]+'</a><a href="http://m.yohobuy.com/passport/signout/index?token='+t[3]+'">退出</a>'),e.find(".back-to-top").on("touchend",function(){return c(window).scrollTop(0),!1}),u.removeClass("hide")}(),function(e,t,o,n,i){var a=t.createElement(o),s=t.getElementsByTagName(o)[0];e.YohoAcquisitionObject=i,e[i]=function(){e[i].p=arguments},a.async=1,a.src=n,s.parentNode.insertBefore(a,s)}(window,document,"script","http://cdn.yoho.cn/yas-jssdk/1.0.13.6.3/yas-debug.js","_yas"),function(){var e=s();e=0===e?"":e,window._ozuid=e,window._yas&&window._yas(1*new Date,"1.0.13.6.3","yohobuy_m",e,"","")}(),p.on("touchstart","a",function(){p.find("a").removeClass("highlight"),c(this).addClass("highlight")}).on("touchend touchcancel","a",function(){c(this).removeClass("highlight")}),h.on("touchstart",".tap-hightlight",function(){c(this).siblings(".tap-hightlight").removeClass("highlight"),c(this).addClass("highlight")}).on("touchend touchcancel",".tap-hightlight",function(){c(this).removeClass("highlight")}),c(".nav-home").on("touchstart",function(){c(".homebuttom").toggleClass("none")}),function(){var e,t,o=0,n="webkit moz ms o".split(" "),i=window.requestAnimationFrame,a=window.cancelAnimationFrame;for(t=0;t<n.length&&(!i||!a);t++)e=n[t],i=i||window[e+"RequestAnimationFrame"],a=a||window[e+"CancelAnimationFrame"]||window[e+"CancelRequestAnimationFrame"];i&&a||(i=function(e,t){var n=(new Date).getTime(),i=Math.max(0,16-(n-o)),a=window.setTimeout(function(){e(n+i)},i);return o=n+i,a},a=function(e){window.clearTimeout(e)}),window.requestAnimationFrame=i,window.cancelAnimationFrame=a}(),c.extend({queryString:function(){var e,t,o=[],n=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(t=0;t<n.length;t++)e=n[t].split("="),o.push(e[0]),o[e[0]]=e[1];return o}}),window.cookie=n,window.setCookie=i,window.getUser=a,window.getUid=s,window.getShoppingKey=r,window.rePosFooter=l,window.reMarginFooter=d}),define("js/category/entry",["jquery","hammer","swiper","lazyload","index"],function(e,t,o){e("js/category/index"),e("js/category/brand")}),define("js/category/index",["jquery"],function(e,t,o){var n=e("jquery"),i=n(".category-nav"),a=n(".category-container"),s=a.children(".content"),r=a.find(".sub-level li"),l=a.find(".primary-level li"),d=s.not(".hide");!function(){var e=n(".yoho-header"),t=n("#search-input"),o=n(window).height()-e.outerHeight()-t.outerHeight()-i.outerHeight();a.css("min-height",o),s.height(o)}(),n("#search-input").focus(function(){n(this).blur()}),i.bind("contextmenu",function(e){return!1}),n(".category-container").bind("contextmenu",function(e){return!1}),i.on("touchend touchcancel",function(e){var t=n(e.target).closest("li"),o=t.index();t.hasClass("focus")||(i.find("li.focus").removeClass("focus"),t.addClass("focus"),d.addClass("hide"),d=s.eq(o).removeClass("hide"))}),a.on("touchend",function(e){var t,o,i,a=n(e.target);if(o=a.closest(".p-level-item"),o.length>0){if(i=o.index(),t=a.closest(".content").find(".sub-level"),a.hasClass("focus"))return;a.closest(".primary-level").children(".focus").removeClass("focus"),a.addClass("focus"),t.not(".hide").addClass("hide"),t.eq(i).removeClass("hide")}}),a.find(".primary-level").on("touchstart touchend touchcancel","li",function(){l.removeClass("highlight"),n(this).addClass("highlight")}).on("touchend touchcancel","li",function(){n(this).removeClass("highlight")}),a.find(".sub-level").on("touchstart","li",function(){r.removeClass("highlight"),n(this).addClass("highlight")}).on("touchend touchcancel","li",function(){n(this).removeClass("highlight")}),i.on("touchstart","li",function(){i.find("li").removeClass("bytouch"),n(this).addClass("bytouch")}).on("touchend touchcancel","li",function(){i.find("li").removeClass("bytouch")})}),define("js/category/brand",["jquery","hammer","swiper","lazyload","index"],function(e,t,o){function n(){var e=p(window).scrollTop();v.eq(0).offset().top<d&&r.hide(),v.each(function(){var t=p(this).offset().top-C;e>=t&&r.css({display:"block"}).find("h2").html(p(this).find(".title-bar").text())})}function i(){var e=p(".brand-list").find("p");e.on("touchstart",function(){e.css("background","#fff"),p(this).css("background","#eee")}).on("touchend touchcancel",function(){p(this).css("background","#fff")})}function a(){var e=(u.val()+"").toLowerCase(),t={},o=0,n="";""!==e&&(p.each(c,function(o,n){p.isArray(n)&&p.each(n,function(n,i){i.name.toLowerCase().indexOf(e)>-1&&(t[o]=t[o]||[],t[o].push(i))})}),p.each(t,function(e,t){var i=['<div class="brand-list bar-',o,'">'];o++,i.push('<div class="title-bar"><h2>'),i.push(e),i.push("</h2></div>"),p.each(t,function(e,t){i.push('<p><a href="'+t.url+'">'+t.name),t.isNew&&i.push('<i class="icon-new">NEW</i>'),t.isHot&&i.push('<i class="icon-hot">HOT</i>'),i.push("</a></p>")}),i.push("</div>"),n+=i.join("")})),p(".search-result").html(n),i()}var s,r,l,d,c,u,h,p=e("jquery"),f=e("hammer"),m=e("swiper"),g=e("lazyload"),v=p(".brand-list"),w=p(".search-icon"),y=p(".newbrand-search").outerHeight(),b=p(".yoho-header").outerHeight(),C=parseInt(y)+parseInt(b)-1;l=new m(".brands-swiper",{grabCursor:!0,slidesPerView:"auto",wrapperClass:"brands-list",slideElement:"li"}),s=new m(".swiper-container",{lazyLoading:!0,loop:!0,autoplay:3e3,pagination:".swiper-pagination .pagination-inner"}),g(p("img.lazy")),p(".yoho-header").css({"z-index":2,position:"fixed",top:0}),p(".banner-top").length>0&&p(".hot-brands").css("padding-top","0"),r=p('<div class="title-bar fixed-title-bar"><h2></h2></div>'),r.css({position:"fixed",top:C}).hide(),d=C+p(".hot-brands").outerHeight()+p(".banner-top").outerHeight(),v.last().append(r),p(window).scroll(function(){window.requestAnimationFrame(n)}),i(),p(".brand-search-page").length&&(c=p.parseJSON(p("#brands-data").html()),u=p("#keyword"),u.on("input",function(){u.val().length?(w.css("color","#000"),p(this).closest(".search-box").css("width","11.25rem"),p(".search-action").show()):(w.css("color","#b2b2b2"),p(this).closest(".search-box").css("width","12.5rem"),p(".search-action").hide()),a()}).focus(),h=new f(p(".clear-text")[0]),h.on("tap",function(e){e.preventDefault(),p(".search-result").html(""),p("#keyword").val("").trigger("input"),e.srcEvent.stopPropagation()}),p("form.search-box").on("submit",function(){return!1}))}),define("js/guang/entry",["jquery","lazyload","swiper","hammer","mlellipsis","iscroll-probe","index"],function(e,t,o){e("js/guang/plus-star/list"),e("js/guang/plus-star/detail"),e("js/guang/home"),e("js/guang/list"),e("js/guang/detail")}),define("js/guang/plus-star/list",["jquery","lazyload","swiper","index"],function(e,t,o){var n,i=e("jquery"),a=e("lazyload"),s=e("swiper"),r=i("#nav-tab > li"),l=i("#ps-content > .content");a(i("img.lazy")),n=new s(".swiper-container",{lazyLoading:!0,pagination:".swiper-pagination"}),i("#nav-tab").bind("contextmenu",function(e){return!1}),i("#nav-tab").on("touchend touchcancel",function(e){var t=i(e.target).closest("li");t.hasClass("focus")||(r.toggleClass("focus"),l.toggleClass("hide"),i(document).trigger("scroll"))}),i("#nav-tab").on("touchstart",function(e){var t=e.target||e.srcElement;t.className="bytouch "+t.className}).on("touchend touchcancel",function(){r.removeClass("bytouch")})}),define("js/guang/plus-star/detail",["jquery","hammer","mlellipsis","lazyload"],function(e,t,o){var n,i,a,s,r=e("jquery"),l=e("hammer"),d=e("mlellipsis"),c=e("lazyload"),u=r("#intro"),h=r("#intro-more-txt"),p=r("#related-infos-container"),f=e("js/guang/info"),m=e("js/plugin/tip"),g=r("#brand-info").data("id"),v=r("#jump-to-app").val();e("js/plugin/wx-share"),d.init(),c(r("img.lazy")),u[0].mlellipsis(3),setTimeout(function(){n=u.text(),i=u.attr("title")}),f.initInfosEvt(p),a=new l(document.getElementById("more-intro")),a.on("tap",function(e){var t=r(e.target).closest("#more-intro");t.toggleClass("spread"),t.hasClass("spread")?(u.text(i),h.text("收起")):(u.text(n),h.text("more"),r(window).scrollTop(0,400)),e.preventDefault()}),s=new l(document.getElementById("brand-like")),s.on("tap",function(e){var t="ok",o=r(e.target);"1"!==v&&(e.preventDefault(),o.hasClass("like")&&(t="cancel"),r.ajax({type:"POST",url:"/guang/opt/favoriteBrand",data:{id:g,opt:t},success:function(e){200===e.code?o.toggleClass("like"):400===e.code||412===e.code?location.href=e.data:m.show(e.message)},error:function(){m.show("网络断开连接了~")}}))})}),define("js/guang/info",["jquery","hammer","mlellipsis","lazyload"],function(e,t,o){function n(e){d(e.find("img.lazy")),e.each(function(){var e=s(this),t=e.find(".info-title"),o=e.find(".info-text");t[0].mlellipsis(2),o[0].mlellipsis(2)})}function i(e){var t;"undefined"!=typeof e&&(t=new r(e[0]),t.on("tap",function(e){var t,o,n=s(e.target),i="ok";return t=n.closest(".like-btn"),t.length>0?(e.preventDefault(),t.hasClass("like")&&(i="cancel"),o=n.closest(".guang-info"),void s.ajax({type:"POST",url:"/guang/opt/praiseArticle",data:{id:o.data("id"),opt:i},success:function(e){var o=e.code;200===o&&(t.next(".like-count").text(e.data),t.toggleClass("like"))},error:function(){c.show("网络断开连接了~")}})):(t=n.closest(".collect-btn"),void(t.length>0&&(e.preventDefault(),t.hasClass("collected")&&(i="cancel"),o=n.closest(".guang-info"),s.ajax({type:"POST",url:"/guang/opt/collectArticle",data:{id:o.data("id"),opt:i},success:function(e){e.code&&200===e.code&&t.toggleClass("collected")},error:function(){c.show("网络断开连接了~")}}))))}),n(e.find(".guang-info")))}function a(e,t,o){var i;m||t.end||(1===t.page&&u.showLoadingMask(),i=e.find(".guang-info").length,m=!0,s.ajax({type:"GET",url:o?o:"/guang/index/page",data:t,success:function(o){var a;return" "===o?(t.end=!0,m=!1,p.addClass("hide"),void f.removeClass("hide")):(e.append(o),a=i>0?e.find(".guang-info:gt("+(i-1)+")"):e.find(".guang-info"),n(a),1===t.page&&(u.hideLoadingMask(),p.removeClass("hide"),window.rePosFooter()),t.page++,void(m=!1))},error:function(){c.show("网络断开连接了~"),m=!1}}))}var s=e("jquery"),r=e("hammer"),l=e("mlellipsis"),d=e("lazyload"),c=e("js/plugin/tip"),u=e("js/plugin/loading"),h=s("#load-more-info"),p=s(""),f=s(""),m=!1;l.init(),h.length>0&&(p=h.children(".loading"),f=h.children(".no-more")),t.initInfosEvt=i,t.setLazyLoadAndMellipsis=n,t.loadMore=a}),define("js/plugin/tip",["jquery"],function(e,t,o){function n(e,t){var o,n;"undefined"!=typeof e&&(o=e.toString(),n=t&&t>0?t:2e3,i.text(o).show(),a=setTimeout(function(){"block"===i.css("display")&&i.hide()},n))}var i,a,s=e("jquery");!function(){var e='<div id="yoho-tip" class="yoho-tip"></div>';s(".yoho-page").append(e),i=s("#yoho-tip"),i.on("touchend",function(){i.hide(),clearTimeout(a)})}(),t.show=n}),define("js/plugin/loading",["jquery"],function(e,t,o){function n(e){var t='<div class="loading-mask hide"><div class="loading"><div></div><div></div><div></div></div></div>';d=!0,void 0===e&&(e=l),e.append(t),s=e.children(".loading-mask")}function i(){d||(n(),d=!0),s.removeClass("hide")}function a(){s.addClass("hide")}var s,r=e("jquery"),l=r(".yoho-page"),d=!1;t.init=n,t.showLoadingMask=i,t.hideLoadingMask=a}),define("js/plugin/wx-share",["jquery"],function(e,t,o){var n=e("jquery");o.exports=function(){var e="http://www.yohoshow.com/api/wechat/getSignPackage";n.getJSON(e+"?pageurl="+encodeURIComponent(location.href.split("#")[0])+"&callback=?",function(e){var t,o,n,i;void 0!==e&&""!==e&&(t=e.appId.toString(),o=e.timestamp,n=e.nonceStr.toString(),i=e.signature.toString(),wx.config({debug:!1,appId:t,timestamp:o,nonceStr:n,signature:i,jsApiList:["checkJsApi","onMenuShareTimeline","onMenuShareAppMessage","onMenuShareQQ","onMenuShareWeibo","hideMenuItems","showMenuItems","hideAllNonBaseMenuItem","showAllNonBaseMenuItem","translateVoice","startRecord","stopRecord","onRecordEnd","playVoice","pauseVoice","stopVoice","uploadVoice","downloadVoice","chooseImage","previewImage","uploadImage","downloadImage","getNetworkType","openLocation","getLocation","hideOptionMenu","showOptionMenu","closeWindow","scanQRCode","chooseWXPay","openProductSpecificView","addCard","chooseCard","openCard"]}))}),wx.ready(function(){var e=n("#shareTitle").val(),t=n("#shareImg").val(),o=n("#shareDesc").val(),i=n("#shareLink").val(),a={title:e,desc:o,imgUrl:t,link:i};wx.onMenuShareAppMessage(a),wx.onMenuShareTimeline(a),wx.onMenuShareQQ(a),wx.onMenuShareWeibo(a)})}}),define("js/guang/home",["jquery","swiper","hammer","mlellipsis","lazyload","index"],function(e,t,o){function n(){var e=f.not(".hide");a(window).scrollTop()+h>=a(document).height()-.25*e.height()&&l(e,w[v])}var i,a=e("jquery"),s=e("swiper"),r=e("js/guang/info"),l=r.loadMore,d=a("#load-more-info"),c=a(""),u=a(""),h=a(window).height(),p=a("#info-list"),f=p.children(".info-list"),m=a("#guang-nav"),g=m.children(".focus"),v=g.data("type"),w={};d.length>0&&(c=d.children(".loading"),u=d.children(".no-more")),i=new s(".swiper-container",{lazyLoading:!0,pagination:".swiper-pagination",autoplay:3e3}),r.initInfosEvt(p),function(){var e=a("#gender").val();m.children(".guang-nav-item").each(function(){var t=a(this).data("type"),o=a(this).hasClass("focus");w[t]={page:o?2:1,gender:e,type:t,end:!1}})}(),m.bind("contextmenu",function(e){return!1}),m.on("touchend touchcancel",function(e){var t,o,n=a(e.target).closest(".guang-nav-item");n.hasClass("focus")||(o=n.index(),n.addClass("focus"),g.removeClass("focus"),t=f.eq(o),g=n,v=n.data("type"),1===w[v].page?(c.addClass("hide"),u.addClass("hide"),l(t,w[v])):w[v].end?(c.addClass("hide"),u.removeClass("hide")):(c.removeClass("hide"),u.addClass("hide")),f.not(".hide").addClass("hide"),t.removeClass("hide"),1===w[v].page&&window.rePosFooter())}),a(document).scroll(function(){window.requestAnimationFrame(n)}),m.on("touchstart",function(e){var t=e.target||e.srcElement;t.className="bytouch "+t.className}).on("touchend touchcancel",function(){m.find("li").removeClass("bytouch")})}),define("js/guang/list",["jquery","hammer","mlellipsis","lazyload"],function(e,t,o){function n(){i(window).scrollTop()+r>=i(document).height()-.25*p.height()&&s(p,h)}var i=e("jquery"),a=e("js/guang/info"),s=a.loadMore,r=i(window).height(),l=i("#author-infos"),d=i("#tag"),c=i("#gender"),u=i("#isApp"),h={page:2,end:!1},p=i("#info-list");a.initInfosEvt(p),l.length>0&&i.extend(h,{authorId:l.data("id"),isApp:u.val()}),d.length>0&&i.extend(h,{tag:d.val(),gender:c.val(),isApp:u.val()}),i(window).scroll(function(){window.requestAnimationFrame(n)})}),define("js/guang/detail",["jquery","mlellipsis","lazyload","iscroll-probe"],function(e,t,o){function n(e){var t=e.offset().left,o=-C+t+y/2+"px";r.css({backgroundPosition:o+" bottom"}),v&&b.css({backgroundPosition:o+" bottom"})}function i(e){var t,o,i,a=h(e.currentTarget),p=a.index();a.hasClass("focus")||(l.filter(".focus").removeClass("focus"),v&&(t=a.closest(".fixed-thumb-container").length>0?r:b,o=t.find(".thumb").eq(p),b.find(".thumb.focus").removeClass("focus"),o.addClass("focus")),a.addClass("focus"),n(a),d.not(".hide").addClass("hide"),i=d.eq(p),i.removeClass("hide"),f(i.find(".lazy")),v?u&&u.scrollToElement(c,400):h("body").animate({scrollTop:s.offset().top},400),u&&u.refresh())}function a(){var e,t,o,n,i,a=h("#scroller"),l=h(".yoho-header"),d=0;return l.length>0&&(d=l.outerHeight()),u=new m("#wrapper",{probeType:3,mouseWheel:!0,click:!0}),document.addEventListener("touchmove",function(e){e.preventDefault()},!1),w?(e=h(window).height()-d,i=b[0],t=r.outerHeight(),o=s.outerHeight(),n=s.offset().top-d,void u.on("scroll",function(){var s=-this.y,r=i.className;n-e+t>=s?-1===r.indexOf("fixed-bottom")&&b.addClass("fixed-bottom").removeClass("hide"):n>=s?-1===r.indexOf("hide")&&b.addClass("hide").removeClass("fixed-bottom fixed-top"):n+o-t>=s?-1===r.indexOf("fixed-top")&&b.addClass("fixed-top").removeClass("hide absolute").css("top",""):n+o>=s?(-1===r.indexOf("absolute")&&b.addClass("absolute").removeClass("fixed-top hide"),i.style.top=n+d+o-t-s+"px"):s>n+o&&-1===r.indexOf("hide")&&b.addClass("hide").removeClass("absolute"),a.trigger("scroll")})):void u.on("scroll",function(){a.trigger("scroll")})}var s,r,l,d,c,u,h=e("jquery"),p=e("mlellipsis"),f=e("lazyload"),m=e("iscroll-probe"),g=h(".author .intro"),v=!1,w=h(".collocation-block").length>0?!0:!1,y=0,b=h(""),c=document.querySelector("#wrapper .collocation-block"),C=h(window).width();e("js/plugin/wx-share")(),window.onload=function(){u&&u.refresh()},t.i=function(e){var t=navigator.userAgent.indexOf("iPhone")>0?!0:!1;v=t&&e,p.init(),f(h(".lazy")),h(".info-list .title, .one-good .reco-name").each(function(){this.mlellipsis(2)}),g.offset()&&parseInt(g.offset().left,10)===parseInt(g.css("margin-left"),10)&&g.css("padding-top",0),v&&(h(".yoho-header").length>0?h("#wrapper").addClass("ios has-head"):h("#wrapper").addClass("ios")),w&&(s=h(".collocation-block"),r=s.children(".thumb-container"),l=r.find("li"),d=s.find(".prod"),y=l.width(),v&&(b=h("#wrapper").after(r.clone().addClass("fixed-thumb-container fixed-bottom")).next(".thumb-container"),f(b.find(".lazy"),{event:"sporty"})),n(l.filter(".focus")),r.delegate(".thumb","touchend",i),v&&b.delegate(".thumb","touchend",i)),v&&a()}}),define("js/home/entry",["jquery","hammer","swiper","lazyload","index"],function(e,t,o){e("js/home/home"),e("js/home/maybe-like")}),define("js/home/home",["jquery","hammer","swiper","lazyload","index"],function(e,t,o){function n(){b.hasClass("menu-open")&&(b.removeClass("menu-open"),g(".overlay").hide(),g(".sub-nav").removeClass("show"),j.removeClass("on"),g("body").css({height:"auto",overflow:"auto"}))}function i(){k+=10,q.css({transform:"rotateX("+k+"deg)","-webkit-transform":"rotateX("+k+"deg)","-moz-transform":"rotateX("+k+"deg)"}),k/90%2===1&&(T?(q.addClass("animate"),T=!1):(q.removeClass("animate"),T=!0)),k/90%2===0&&k%360!==0?window.setTimeout(i,3e3):k%360===0?window.setTimeout(i,6e4):c(function(){i()})}var a,s,r,l,d,c,u,h,p,f,m,g=e("jquery"),v=e("hammer"),w=e("swiper"),y=e("lazyload"),b=g(".mobile-wrap"),C=g(".overlay"),j=g(".side-nav"),x=g(".sub-nav"),k=0,q=g(".home-header .logo"),T=!0;e("js/home/maybe-like"),y(g("img.lazy")),m=new v(g(".nav-btn")[0]),m.on("tap",function(e){return e.preventDefault(),b.addClass("menu-open"),C.show().css("opacity",.3),j.addClass("on"),g("body").css({height:g(window).height(),width:g(window).width(),overflow:"hidden"}),e.srcEvent.stopPropagation(),!1}),g(".overlay").on("touchstart",function(e){return n(),!1}),j.on("touchstart","li",function(e){return g(this).find(".sub-nav").size()>0&&(g(".sub-nav").removeClass("show"),g(this).find(".sub-nav").addClass("show")),e.stopPropagation(),e.target.pathname===location.pathname?(n(),!1):void 0}),x.each(function(){g(this).find("li").eq(0).on("touchstart",function(e){return g(".sub-nav").removeClass("show"),e.stopPropagation(),!1})}).on("touchstart",function(e){e.currentTarget!==e.target&&x.find("li").removeClass("current")}),j.children("ul").children("li").on("touchstart",function(){j.children("ul").children("li").css("background","#fff"),g(this).css("background","#eee")}).on("touchend touchcancel",function(){g(this).css("background","#fff")}),g(".banner-swiper").find("li").size()>1&&(a=new w(".banner-swiper",{lazyLoading:!0,lazyLoadingInPrevNext:!0,loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!1,paginationClickable:!0,slideElement:"li",pagination:".banner-top .pagination-inner"})),r=new w(".brands-swiper",{grabCursor:!0,slidesPerView:"auto",wrapperClass:"brands-list",slideElement:"li"}),s=new w(".recommend-swiper",{grabCursor:!0,slidesPerView:"auto",wrapperClass:"recommend-list",slideElement:"li"}),g(".trend-topic-swiper").find("li").size()>1&&(l=new w(".trend-topic-swiper",{loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!1,paginationClickable:!0,slideElement:"li",pagination:".trend-topic-content .pagination-inner"})),g(".category-swiper").each(function(e,t){p="category-swiper"+e,g(this).addClass(p),g("."+p).find(".swiper-slide").size()>1&&(d=new w("."+p,{loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!1,paginationClickable:!0,slideElement:"li",pagination:"."+p+" .pagination-inner"}))}),c=function(){var e=null,t=["webkit","moz","ms"];for(h=0;h<t.length;h++)u=t[h]+"RequestAnimationFrame",window[u]&&(f=!0,e=u);return f?function(t){window[e](t)}:function(e){window.setTimeout(e,67)}}(),setTimeout(i,3e3),g(".home-header .iconfont").on("touchstart",function(){g(this).addClass("highlight")}).on("touchend touchcancel",function(){g(this).removeClass("highlight")}),window.reMarginFooter(".footer-tab"),t.set=function(e){window.setCookie("_Channel",e,{expires:365,domain:".m.yohobuy.com"})}}),define("js/home/maybe-like",["jquery","hammer","lazyload"],function(e,t,o){function n(){v||(v=!0,p.showLoadingMask(),c.ajax({type:"GET",url:r,data:{page:w+1},success:function(e){return" "===e?(v=!1,p.hideLoadingMask(),void(y&&(r="1,3"===y?"/boys/bottomBanner":"/girls/bottomBanner",c.ajax({type:"GET",url:r,success:function(e){e&&e.img&&(c("#load-more-img").show(),c("#load-more-img a").attr("href",e.url),c("#load-more-img a > img").attr("src",e.img))},error:function(){}})))):(s=g.find(".good-info").length,g.append(e),f(0===s?g.find(".good-info").find("img.lazy"):g.find(".good-info:gt("+(s-1)+")").find("img.lazy")),v=!1,p.hideLoadingMask(),void w++)},error:function(){h.show("网络断开连接了~"),v=!1,p.hideLoadingMask()}}))}function i(){c(window).scrollTop()+m>=c(document).height()-200&&n()}var a,s,r,l,d,c=e("jquery"),u=e("hammer"),h=e("js/plugin/tip"),p=e("js/plugin/loading"),f=e("lazyload"),m=c(window).height(),g=c("#goods-list"),v=!1,w=0,y=null,b=c(".mobile-wrap").hasClass("kids-wrap")?!0:!1,C=c(".mobile-wrap").hasClass("lifestyle-wrap")?!0:!1,j=c("#maybe-like-nav");b?r="/product/recom/maylikekids":C?r="/product/recom/maylikelife":(y=c(".mobile-wrap").hasClass("boys-wrap")?"1,3":"2,3",r="/product/recom/maylike?gender="+y),l=j.children(".focus"),C&&(a=new u(j[0]),a.on("tap",function(e){var t,o=c(e.target).closest("li"),n=c(".goods-list");e.preventDefault(),o.hasClass("focus")||(d=o.index(),o.addClass("focus"),l.removeClass("focus"),n.not(".hide").addClass("hide"),t=n.eq(d),t.removeClass("hide"),l=o,c(document).trigger("scroll"),e.srcEvent.stopPropagation())})),p.init(c(".maybe-like")),c(".maybe-like p").on("touchstart",function(e){n()}),c(window).scroll(function(){window.requestAnimationFrame(i)})}),define("js/index/entry",["jquery","hammer"],function(e,t,o){e("js/index/search"),e("js/index/footer"),e("js/index/channel")}),define("js/index/search",["jquery","hammer"],function(e,t,o){var n,i,a=e("jquery"),s=e("js/plugin/security"),r=e("hammer"),l=a("#search-input input"),d=a("#search-input .clear-input"),c=a(".search-icon"),u=a("#search-form"),h=a(".history"),p=a(".history-search"),f=a("#clear-history"),m=e("js/index/write-search"),g=m.getRanToken();n=new r(f[0]),n.on("tap",function(){localStorage.removeItem("historys"),h.html(""),p.hide(),f.hide(),window.rePosFooter()}),l.on("input",function(){""===l.val()?(c.css("color","#b2b2b2"),d.addClass("hide")):(c.css("color","#666"),d.removeClass("hide"))}),i=new r(d[0]),i.on("tap",function(){l.val("").trigger("input")}),a("#search").on("touchend",function(){return s.hasDangerInput()?!1:(a(this).closest("form").submit(),!1)}),function(){var e,t,o,n="";if(localStorage&&(t=localStorage.getItem("historys"),t&&t.length>0)){for(t=t.split(g),o=t.length;o>0;o--)e=t[o-1],""!==e&&(n+='<li><a href="/?query='+e+'">'+e+"</li>");h.html(n),f.removeClass("hide"),p.removeClass("hide"),window.rePosFooter()}}(),m.bindWirteLocal(u)}),define("js/plugin/security",["jquery"],function(e,t,o){function n(e){var t,o,n,s=i("input[type!=hidden], textarea"),r=/['"<>&\|]|--/g,l=s.length,d=void 0===e||"boolean"!=typeof e?!0:e;for(o=0;l>o;o++)if(t=s.eq(o).val(),r.test(t))return d?s.eq(o).val(t.replace(r," ")):(n=t.match(r).join(" "),a.show("不可以输入 "+n+" 哦!")),!d&&!0;return!1}var i=e("jquery"),a=e("js/plugin/tip");t.hasDangerInput=n}),define("js/index/write-search",[],function(e,t,o){function n(){return a}function i(e){e.on("submit",function(){var e,t=this.query.value;if(localStorage){if(e=localStorage.getItem("historys"),e=e?e:"",e.indexOf(a+t+a)>-1)return;""===e&&(t=a+t),e+=t+a,localStorage.setItem("historys",e)}})}var a=" ??++ ";t.getRanToken=n,t.bindWirteLocal=i}),define("js/index/footer",["jquery","hammer"],function(e,t,o){function n(){var e="http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445",t=new Date;setTimeout(function(){new Date-t<2e3&&(window.location=e)},500)}var i,a=e("jquery"),s=e("hammer");e("js/common"),a("#float-layer-close").on("touchend",function(e){return a("#float-layer-app").hide(),window.setCookie("_float-layer-app","id490655927",{domain:".yohobuy.com"}),window.setCookie("_float-layer-app-close",1,{domain:".yohobuy.com",expires:1}),!1}),a("#float-layer-btn")&&a("#float-layer-btn")[0]&&(i=new s(a("#float-layer-btn")[0]),i.on("tap",function(e){n("bottom"),e.srcEvent.stopPropagation()}),"function"!=typeof window.cookie||window.cookie("_float-layer-app")?a("#float-layer-app").hide():a("#float-layer-app").show())}),define("js/index/channel",["jquery"],function(e,t,o){var n=e("jquery"),i=e("js/plugin/security"),a=n(".search-box"),s=n(".box"),r=n(".index-search"),l=n(".index-logo"),d=n(".index-channel a"),c=a.children('input[type="text"]'),u=s.children(".no-search"),h=a.children(".search-icon");e("js/common"),c.on("focus",function(){s.addClass("action"),l.addClass("action")}).on("input",function(){""===c.val()?h.addClass("empty"):h.removeClass("empty")}),u.on("touchend",function(){return s.removeClass("action"),l.removeClass("action"),c.blur(),!1}),a.children(".clear-text").on("touchstart",function(){c.val("").focus().trigger("input")}),a.children(".search-icon").on("touchstart",function(){return i.hasDangerInput()?!1:void r.submit()}),a.keyup(function(e){if(13===e.keyCode){if(i.hasDangerInput())return!1;r.submit()}}),n(".index-channel img").on("load error",function(){window.rePosFooter&&window.rePosFooter()}),d.on("touchstart",function(){d.css({background:"#000",color:"#fff",borderColor:"#fff"}),n(this).css({background:"rgba(255, 255, 255, 0.5)",color:"#000",borderColor:"#000"})}).on("touchend touchcancel",function(){n(this).css({background:"#000",color:"#fff",borderColor:"#fff"})})}),define("js/passport/entry",["jquery"],function(e,t,o){e("js/passport/register/register"),e("js/passport/register/code"),e("js/passport/register/password"),e("js/passport/login/login"),e("js/passport/login/international"),e("js/passport/back/mobile"),e("js/passport/back/code"),e("js/passport/back/email"),e("js/passport/back/email-success"),e("js/passport/back/new-password")}),define("js/passport/register/register",["jquery"],function(e,t,o){var n=e("jquery"),i=n("#phone-num"),a=n("#country-select"),s=n("#area-code"),r=n("#btn-next"),l=e("js/passport/api"),d=e("js/plugin/tip"),c=n.trim,u=d.show;l.selectCssHack(n("#country-select")),l.bindClearEvt(),i.bind("input",function(){""===c(i.val())?r.addClass("disable"):r.removeClass("disable")}),a.change(function(){s.text(a.val())}),r.on("touchstart",function(){var e=c(i.val()),t=a.val();r.hasClass("disable")||(l.phoneRegx[t].test(e)?n.ajax({url:"/passport/reg/verifymobile",type:"POST",data:{areaCode:t.replace("+",""),phoneNum:e},success:function(e){200===e.code?location.href=e.data:u(e.message)}}):u("手机号格式不正确,请重新输入"))})}),define("js/passport/api",["jquery"],function(e,t,o){function n(e){var t,o=r(".has-eye");e&&"open"===e.status?o.append('<div class="eye"></div>'):o.append('<div class="eye close"></div>'),t=o.children(".eye"),t.on("touchstart",function(e){var t=r(this),o=t.siblings(".pwd");e.preventDefault(),t.toggleClass("close"),t.hasClass("close")?o.attr("type","password"):o.attr("type","text"),o.focus()})}function i(){var e,t=r(".has-clear");t.append('<div class="clear-input"></div>'),e=t.children(".clear-input"),e.on("touchstart",function(t){var o=e.siblings(".input");o.val("").trigger("input").focus(),t.preventDefault()}),t.children(".input").bind("input",function(){var e=r(this),t=e.siblings(".clear-input"),o=l(e.val());""===o?t.hide():t.show()})}function a(e){return e.length>=6&&e.length<=20?!0:!1}function s(e){function t(){var t=e.find("option:selected").text().length;switch(t){case 2:e.outerWidth(90);break;case 3:e.outerWidth(110);break;default:e.outerWidth(130)}}var o=navigator.userAgent;o.match(/uc/i)&&o.match(/android/i)?e.change(function(){t()}):e.removeClass("in-android-uc")}var r=e("jquery"),l=r.trim,d=/^([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|-]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/,c={"+86":/^1[35847]{1}[0-9]{9}$/,"+852":/^[965]{1}[0-9]{7}$/,"+853":/^[0-9]{8}$/,"+886":/^[0-9]{10}$/,"+65":/^[98]{1}[0-9]{7}$/,"+60":/^1[1234679]{1}[0-9]{8}$/,"+1":/^[0-9]{10}$/,"+82":/^01[0-9]{9}$/,"+44":/^7[789][0-9]{8}$/,"+81":/^0[9|8|7][0-9]{9}$/,"+61":/^[0-9]{11}$/};o.exports={emailRegx:d,phoneRegx:c,bindEyesEvt:n,bindClearEvt:i,pwdValidate:a,selectCssHack:s}}),define("js/passport/register/code",["jquery"],function(e,t,o){e("js/passport/code")(!0)}),define("js/passport/code",["jquery"],function(e,t,o){var n=e("jquery");o.exports=function(t,o){function i(){n.ajax({url:"/passport/bind/bindMobile",type:"post",data:{areaCode:f.replace("+",""),phoneNum:p,openId:h,sourceType:u,nickname:c,password:""},success:function(e){200===e.code?(g.show("登录成功"),setTimeout(function(){location.href=e.data.refer},2e3)):g.show(e.message)},error:function(e){g.show("登录失败,请重试!")}})}function a(){var e,t=59;e=setInterval(function(){0===t?(l.text("重发验证码").removeClass("disable"),clearInterval(e)):l.text("重发验证码 ("+t--+"秒)")},1e3)}var s=n("#captcha"),r=n("#btn-next"),l=n("#captcha-tip"),d=parseInt(n("#isReg").val()),c=n("#nickname").val(),u=n("#sourceType").val(),h=n("#openId").val(),p=n("#phone-num").val(),f=n("#area-code").val().replace("+",""),m=e("js/passport/api"),g=e("js/plugin/tip"),v=n.trim,w=g.show,y=t?"reg":"back";m.bindClearEvt(),s.bind("input",function(){""!==v(s.val())?r.removeClass("disable"):r.addClass("disable")}),l.on("touchstart",function(){l.hasClass("disable")||n.ajax({type:"POST",url:o?"/passport/bind/sendBindMsg":"/passport/"+y+"/sendcode",data:{phoneNum:p,areaCode:f},success:function(e){200===e.code?(l.text("重发验证码 (60秒)").addClass("disable"),a()):w(e.message)}})}),r.on("touchstart",function(){r.hasClass("disable")||n.ajax({type:"POST",url:o?"/passport/bind/checkBindMsg":"/passport/"+y+"/verifycode",
data:{phoneNum:p,areaCode:f,code:v(s.val()),token:n("#token").val()},success:function(e){200===e.code?o?d?i():location.href="/passport/bind/password?phoneNum="+p+"&areaCode="+f+"&openId="+h+"&sourceType="+u+"&nickname="+c:location.href=e.data:w(e.message)}})}),a()}}),define("js/passport/register/password",["jquery"],function(e,t,o){var n=e("jquery"),i=n("#pwd"),a=n("#btn-sure"),s=e("js/passport/api"),r=e("js/plugin/tip"),l=n.trim,d=r.show;s.bindEyesEvt({status:"open"}),i.bind("input",function(){""===l(i.val())?a.addClass("disable"):a.removeClass("disable")}),a.on("touchstart",function(){var e=l(i.val());a.hasClass("disable")||(s.pwdValidate(e)===!1?d("密码6-20位,请重新输入"):n.ajax({type:"POST",url:"/passport/reg/setpassword",data:{password:e,phoneNum:n("#phone-num").val(),areaCode:n("#area-code").val(),token:n("#token").val()},success:function(e){var t;200===e.code?(t=e.data,d("注册成功"),n.ajax({url:t.session,dataType:"jsonp"}),setTimeout(function(){location.href=t.href},1e3)):d(e.message)}}))})}),define("js/passport/login/login",["jquery"],function(e,t,o){function n(){h&&p?d.removeClass("disable"):d.addClass("disable")}function i(){c.show(),u.show()}function a(){c.hide(),u.hide()}var s=e("jquery"),r=s("#account"),l=s("#pwd"),d=s("#btn-login"),c=s("#retrive-pwd-mask"),u=s("#retrive-pwd-ways"),h=!1,p=!1,f=e("js/passport/api"),m=e("js/plugin/tip"),g=s.trim,v=m.show;f.bindEyesEvt(),f.bindClearEvt(),r.bind("input",function(){h=""!==g(r.val())?!0:!1,n()}),l.bind("input",function(){p=""===g(l.val())?!1:!0,n()}),d.on("touchstart",function(){var e=g(r.val()),t=g(l.val());d.hasClass("disable")||(d.text("正在登录...").addClass("disable"),(/^[0-9]+$/.test(e)||f.emailRegx.test(e))&&f.pwdValidate(t)?s.ajax({type:"POST",url:"/passport/login/auth",data:{account:e,password:t},success:function(e){var t,o;200===e.code?(t=e.data,s.ajax({url:t.session,dataType:"jsonp",success:function(){clearTimeout(o),setTimeout(function(){location.href=t.href},1e3)}}),o=setTimeout(function(){location.href=t.href},3e3),v("登录成功")):v(e.message)},error:function(){v("网络断开连接啦~")},complete:function(){d.text("登录").removeClass("disable")}}):v("账号或密码有错误,请重新输入"))}),s("#forget-pwd").on("touchstart",function(){i()}),c.on("touchstart",function(){a()}),s("#cancel-retrive").on("touchstart",function(e){e.preventDefault(),a()}),r.trigger("input"),l.trigger("input")}),define("js/passport/login/international",["jquery"],function(e,t,o){function n(){c&&u?d.removeClass("disable"):d.addClass("disable")}var i=e("jquery"),a=i("#phone-num"),s=i("#country-select"),r=i("#area-code"),l=i("#pwd"),d=i("#btn-login"),c=!1,u=!1,h=e("js/passport/api"),p=e("js/plugin/tip"),f=i.trim,m=p.show;h.selectCssHack(s),h.bindEyesEvt(),h.bindClearEvt(),a.bind("input",function(){c=""===f(a.val())?!1:!0,n()}),l.bind("input",function(){var e=f(l.val());u=""===e?!1:!0,n()}),s.change(function(){r.text(s.val())}),d.on("touchstart",function(){var e=f(a.val()),t=s.val(),o=f(l.val());d.hasClass("disable")||(d.text("正在登录...").addClass("disable"),h.phoneRegx[t].test(e)&&h.pwdValidate(o)?i.ajax({type:"POST",url:"/passport/login/auth",data:{areaCode:t.replace("+",""),account:e,password:o},success:function(e){var t,o;200===e.code?(t=e.data,m("登录成功"),i.ajax({url:t.session,dataType:"jsonp",success:function(){clearTimeout(o),setTimeout(function(){location.href=t.href},1e3)}}),o=setTimeout(function(){location.href=t.href},3e3),m("登录成功")):m(e.message)},error:function(){m("网络断开连接啦~")},complete:function(){d.text("登录").removeClass("disable")}}):m("账号或密码有错误,请重新输入"))}),a.trigger("input"),l.trigger("input")}),define("js/passport/back/mobile",["jquery"],function(e,t,o){var n=e("jquery"),i=n("#phone-num"),a=n("#country-select"),s=n("#area-code"),r=n("#btn-next"),l=e("js/passport/api"),d=e("js/plugin/tip"),c=n.trim,u=d.show;l.selectCssHack(n("#country-select")),l.bindClearEvt(),i.bind("input",function(){""===c(i.val())?r.addClass("disable"):r.removeClass("disable")}),a.change(function(){s.text(a.val())}),r.on("touchstart",function(){var e=c(i.val()),t=a.val();r.hasClass("disable")||(l.phoneRegx[t].test(e)?n.ajax({url:"/passport/back/sendcode",type:"POST",data:{areaCode:t.replace("+",""),phoneNum:e},success:function(e){200===e.code?location.href=e.data:u(e.message)}}):u("手机号格式不正确,请重新输入"))})}),define("js/passport/back/code",["jquery"],function(e,t,o){e("js/passport/code")(!1)}),define("js/passport/back/email",["jquery"],function(e,t,o){var n=e("jquery"),i=n("#email"),a=n("#btn-sure"),s=e("js/passport/api"),r=e("js/plugin/tip"),l=n.trim,d=r.show;s.bindClearEvt(),i.bind("input",function(){""===l(i.val())?a.addClass("disable"):a.removeClass("disable")}),a.on("touchstart",function(){var e=l(i.val());a.hasClass("disable")||(s.emailRegx.test(e)?n.ajax({url:"/passport/back/sendemail",type:"POST",data:{email:e},success:function(e){200===e.code?location.href=e.data:d(e.message)}}):d("邮箱格式不正确,请重新输入"))})}),define("js/passport/back/email-success",["jquery"],function(e,t,o){var n=e("jquery"),i=n("#resend"),a=e("js/plugin/tip"),s=a.show;i.on("touchstart",function(e){e.preventDefault(),n.ajax({url:i.data("url"),type:"GET",success:function(e){s(200===e.code?e.message:e.message)}})})}),define("js/passport/back/new-password",["jquery"],function(e,t,o){var n=e("jquery"),i=n("#pwd"),a=n("#btn-ok"),s=e("js/passport/api"),r=e("js/plugin/tip"),l=n.trim,d=r.show,c=n("#phone-num");s.bindEyesEvt({status:"open"}),i.bind("input",function(){""===l(i.val())?a.addClass("disable"):a.removeClass("disable")}),a.on("touchstart",function(){var e,t,o=l(i.val()),r=!0;a.hasClass("disable")||(e={password:o},0===c.length&&(r=!1),r?(n.extend(e,{phoneNum:c.val(),areaCode:n("#areaCode").val(),token:n("#token").val()}),t="/passport/back/passwordByMobile"):(n.extend(e,{code:n("#email-code").val()}),t="/passport/back/passwordByEmail"),s.pwdValidate(o)?n.ajax({type:"POST",url:t,data:e,success:function(e){200===e.code?(d("密码修改成功"),setTimeout(function(){location.href=e.data},1e3)):d(e.message)}}):d("密码6-20位,请重新输入"))})}),define("js/product/entry",["jquery","swiper","lazyload","hammer","index"],function(e,t,o){e("js/product/newsale/newarrival"),e("js/product/newsale/discount"),e("js/product/list"),e("js/product/detail/detail"),e("js/product/detail/consultform"),e("js/product/newsale/hot-rank")}),define("js/product/newsale/newarrival",["jquery","swiper","lazyload","hammer","index"],function(e,t,o){function n(e){var t,o,n,i,a,u,f={};if(!d){if(e){for(o in T)T.hasOwnProperty(o)&&(T[o].reload=!0);switch(q.children(".active").removeClass("active"),E.addClass("active"),e.type){case"gender":t={gender:e.id};break;case"brand":t={brand:e.id};break;case"sort":t={sort:e.id};break;case"color":t={color:e.id};break;case"size":t={size:e.id};break;case"price":t={price:e.id};break;case"discount":t={discount:e.id};break;case"limit":t={limit:e.id};break;case"channel":t={channel:e.id};break;case"p_d":t={p_d:e.id}}c.extend(b,t)}if(E.hasClass("today")?(i="today",a=1):E.hasClass("week")?(i="week",a=2):E.hasClass("sale")&&(i="sale",a=3),n=T[i],u=n.page+1,n.reload)u=1;else if(n.end)return;c.extend(f,b,{dayLimit:a,page:u}),d=!0,m.showLoadingMask(),c.ajax({type:"GET",url:"/product/newsale/selectNewSale",data:f,success:function(e){var t,o;switch(i){case"today":t=s;break;case"week":t=r;break;case"sale":t=l}" "===e?(n.end=!0,n.reload&&t.html(y)):n.reload?(t.html(e),h(t.find(".lazy"))):(o=t.find(".good-info").length,t.append(e),h(t.find(".good-info:gt("+(o-1)+") .lazy"))),n.reload=!1,n.page=u,d=!1,m.hideLoadingMask(),window.rePosFooter()},error:function(){p.show("网络断开连接了~"),d=!1,m.hideLoadingMask()}})}}function i(){c(window).scrollTop()+w>c(document).height()-.25*g.height()-50&&void 0!==E&&n()}var a,s,r,l,d,c=e("jquery"),u=e("swiper"),h=e("lazyload"),p=e("js/plugin/tip"),f=e("js/plugin/filter"),m=e("js/plugin/loading"),g=c("#goods-container"),v=g.children(),s=c(v.get(0)),r=c(v.get(1)).addClass("hide"),l=c(v.get(2)).addClass("hide"),w=c(window).height(),y='<p class="no-result">未找到相关搜索结果</p>',b=e("js/product/query-param"),C=c.extend({},b),j=new Date,x=j.getMonth()+1,k=j.getDate(),q=c("#list-nav"),T={today:{reload:!0,page:0,end:!1},week:{reload:!0,page:0,end:!1},sale:{reload:!0,page:0,end:!1}},E=q.find(".active");e("js/product/suspend-cart"),c("#today a").text(x+"月"+k+"号"),c(".swiper-container .swiper-slide").length>1&&(a=new u(".swiper-container",{lazyLoading:!0,lazyLoadingInPrevNext:!0,loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!0,paginationClickable:!0,pagination:".banner-top .pagination-inner"})),c.ajax({type:"GET",url:"/product/newsale/filter",data:b,success:function(e){g.append(e),f.initFilter({fCbFn:n,hCbFn:function(){E.addClass("active"),E.siblings(".filter").removeClass("active")}})}}),h(c(".lazy")),q.bind("contextmenu",function(e){return!1}),q.on("touchend touchcancel",function(e){var t,o,i,a=c(e.target).closest("li");if(e.preventDefault(),a.hasClass("filter"))a.hasClass("active")?(f.hideFilter(),E.addClass("active"),a.removeClass("active")):(E=a.siblings(".active"),E.removeClass("active"),a.addClass("active"),f.showFilter());else{if(a.hasClass("today")?o="today":a.hasClass("week")?o="week":a.hasClass("sale")&&(o="sale"),t=T[o],!a.hasClass("active")){if(i=a.siblings(".active"),E=a,i.hasClass("filter"))f.hideFilter();else{switch(g.children(".container:not(.hide)").addClass("hide"),o){case"today":s.removeClass("hide");break;case"week":r.removeClass("hide");break;case"sale":l.removeClass("hide")}f.resetFilter(),b=c.extend({},C)}i.removeClass("active"),a.addClass("active")}t.reload&&n()}e.stopPropagation()}),c(window).scroll(function(){window.requestAnimationFrame(i)}),n(),q.on("touchstart","li",function(e){c(this).addClass("bytouch")}).on("touchend touchcancel",function(){q.find("li").removeClass("bytouch")})}),define("js/plugin/filter",["jquery","hammer"],function(e,t,o){function n(){h.addClass("hide")}function i(){h.removeClass("hide")}function a(){var e=g(".filter-body .classify");e.on("touchstart",".shower",function(){e.removeClass("highlight"),g(this).addClass("highlight")}).on("touchend touchcancel",".shower",function(){g(this).removeClass("highlight")})}function s(){var e=g(".filter-body .sub-item");e.on("touchstart",function(){e.removeClass("highlight"),g(this).addClass("highlight")}).on("touchend touchcancel",function(){g(this).removeClass("highlight")})}function r(e){e.hasClass("active")||(e.siblings(".active").removeClass("active"),e.addClass("active"))}function l(e){var t,o,n=e.closest(".sub-classify"),i=n.siblings(".shower");return e.hasClass("chosed")?n:(n.children(".chosed").removeClass("chosed"),e.addClass("chosed"),t=g.trim(e.html()),o=g.trim(i.html()),i.html(o.substring(0,o.indexOf("</span>")+7)+t.substring(0,t.indexOf("<i"))),0===e.index()?i.addClass("default"):i.removeClass("default"),n)}function d(e){var t,o=e.data("id");t=l(e),p&&p({type:t.data("type"),id:o}),n()}function c(e){var t;p=e.fCbFn,f=e.hCbFn,m=e.missStatus,a(),s(),h=g(".filter-mask"),t=new v(h[0]),t.on("tap",function(e){var t,o=g(e.target);e.preventDefault(),o.closest(".filter-body").length>0?(t=o.closest(".sub-item"),t.length>0?(t=o.closest("li"),d(t)):(t=o.closest(".classify-item"),e.srcEvent.stopPropagation(),r(t))):(n(),f&&f())})}function u(){"undefined"!=typeof h&&(g(".sub-classify").each(function(){l(g(this).children(":first-child"))}),r(g(".classify > :first-child")))}var h,p,f,m,g=e("jquery"),v=e("hammer");t.initFilter=c,t.showFilter=i,t.hideFilter=n,t.resetFilter=u}),define("js/product/query-param",["jquery"],function(e,t,o){var n=e("jquery"),i={};n(".query-param").each(function(){var e=n(this);i[e.data("attr")]=e.val()}),o.exports=i}),define("js/product/suspend-cart",["jquery"],function(e,t,o){var n=e("jquery"),i=n("#suspend-cart");n.ajax({type:"GET",url:"/cart/index/count",success:function(e){200===e.code&&i.find(".cart-count").html(e.data.cart_goods_count).removeClass("hide")}})}),define("js/product/newsale/discount",["jquery","swiper","lazyload","hammer","index"],function(e,t,o){function n(e){var t,o,n,i,a,l={};if(!s){if(e){for(o in j)j.hasOwnProperty(o)&&(j[o].reload=!0);switch(C.children(".active").removeClass("active"),x.addClass("active"),e.type){case"gender":t={gender:e.id};break;case"brand":t={brand:e.id};break;case"sort":t={sort:e.id};break;case"color":t={color:e.id};break;case"size":t={size:e.id};break;case"price":t={price:e.id};break;case"discount":t={discount:e.id}}r.extend(b,t)}if(x.hasClass("new")?i="newest":x.hasClass("price")?i="price":x.hasClass("discount")&&(i="discount"),n=j[i],a=n.page+1,n.reload)a=1;else if(n.end)return;r.extend(l,b,{type:i,order:n.order,page:a}),s=!0,h.showLoadingMask(),r.ajax({type:"GET",url:"/product/newsale/selectNewSale",data:l,success:function(e){var t,o;switch(i){case"newest":t=m;break;case"price":t=g;break;case"discount":t=v}" "===e?(n.end=!0,n.reload&&t.html(y)):n.reload?(t.html(e),d(t.find(".lazy"))):(o=t.find(".good-info").length,t.append(e),d(t.find(".good-info:gt("+(o-1)+") .lazy"))),n.reload=!1,n.page=a,s=!1,h.hideLoadingMask(),window.rePosFooter()},error:function(){c.show("网络断开连接了~"),s=!1,h.hideLoadingMask()}})}}function i(){r(window).scrollTop()+w>r(document).height()-.25*p.height()-50&&void 0!==x&&n()}var a,s,r=e("jquery"),l=e("swiper"),d=e("lazyload"),c=e("js/plugin/tip"),u=e("js/plugin/filter"),h=e("js/plugin/loading"),p=r("#goods-container"),f=p.children(),m=r(f.get(0)),g=r(f.get(1)),v=r(f.get(2)),w=r(window).height(),y='<p class="no-result">未找到相关搜索结果</p>',b=e("js/product/query-param"),C=r("#list-nav"),j={newest:{order:1,reload:!0,page:0,end:!1},price:{order:0,reload:!0,page:0,end:!1},discount:{order:0,reload:!0,page:0,end:!1}},x=C.find(".active");e("js/product/suspend-cart"),r(".swiper-container .swiper-slide").length>1&&(a=new l(".swiper-container",{lazyLoading:!0,lazyLoadingInPrevNext:!0,loop:!0,autoplay:3e3,autoplayDisableOnInteraction:!0,paginationClickable:!0,pagination:".banner-top .pagination-inner"})),r.ajax({type:"GET",url:"/product/newsale/filter",data:b,success:function(e){p.append(e),u.initFilter({fCbFn:n,hCbFn:function(){x.addClass("active"),x.siblings(".filter").removeClass("active")},missStatus:!0})}}),d(r(".lazy")),C.bind("contextmenu",function(e){return!1}),C.on("touchend touchcancel",function(e){var t,o,i,a=r(e.target).closest("li");if(e.preventDefault(),"undefined"!=typeof a&&0!==a.length){if(a.hasClass("filter"))a.hasClass("active")?(u.hideFilter(),x.addClass("active"),a.removeClass("active")):(x=a.siblings(".active"),x.removeClass("active"),a.addClass("active"),u.showFilter());else{if(a.hasClass("new")?o="newest":a.hasClass("price")?o="price":a.hasClass("discount")&&(o="discount"),t=j[o],a.hasClass("active")){if(a.hasClass("new"))return;(a.hasClass("price")||a.hasClass("discount"))&&(a.find(".icon > .iconfont").toggleClass("cur"),x=a,t.reload=!0,t.order=0===t.order?1:0)}else{if(i=a.siblings(".active"),x=a,i.hasClass("filter"))u.hideFilter();else switch(p.children(".container:not(.hide)").addClass("hide"),o){case"newest":m.removeClass("hide");break;case"price":g.removeClass("hide");break;case"discount":v.removeClass("hide")}i.removeClass("active"),a.addClass("active")}t.reload&&n()}e.stopPropagation()}}),r(window).scroll(function(){window.requestAnimationFrame(i)}),n(),C.on("touchstart","li",function(e){r(this).addClass("bytouch")}).on("touchend touchcancel",function(){C.find("li").removeClass("bytouch")})}),define("js/product/list",["jquery","hammer","lazyload"],function(e,t,o){function n(e){var t,o,n,i,s,r={};if(!a){if(e){for(o in I)I.hasOwnProperty(o)&&(I[o].reload=!0);switch(E.children(".active").removeClass("active"),z.addClass("active"),e.type){case"gender":t={gender:e.id};break;case"brand":t={brand:e.id};break;case"sort":t={sort:e.id};break;case"color":t={color:e.id};break;case"size":t={size:e.id};break;case"price":t={price:e.id};break;case"discount":t={discount:e.id}}d.extend(T,t)}if(z.hasClass("new")?i="newest":z.hasClass("price")?i="price":z.hasClass("discount")&&(i="discount"),n=I[i],s=n.page+1,n.reload)s=1;else if(n.end)return;d.extend(r,T,{type:i,order:n.order,page:s}),a=!0,v.showLoadingMask(),d.ajax({type:"GET",url:"/index/search/search",data:r,success:function(e){var t,o,r='<p class="no-result">未找到相关搜索结果</p>';switch(i){case"newest":o=y;break;case"price":o=b;break;case"discount":o=C}if(" "===e?(n.end=!0,n.reload&&o.html(r)):n.reload?(o.html(e),u(o.find(".lazy"))):(t=o.find(".good-info").length,o.append(e),u(o.find(".good-info:gt("+(t-1)+") .lazy"))),n.reload=!1,n.page=s,a=!1,v.hideLoadingMask(),window.rePosFooter(),window._yas)switch(i){case"newest":window._yas(1*new Date,"1.0.13.6.3","yohobuy_m",window._ozuid,"",".new-goods .good-info .good-detail-img .good-thumb");break;case"price":window._yas(1*new Date,"1.0.13.6.3","yohobuy_m",window._ozuid,"",".new-goods .good-info .good-detail-img .good-thumb");break;case"discount":window._yas(1*new Date,"1.0.13.6.3","yohobuy_m",window._ozuid,"",".new-goods .good-info .good-detail-img .good-thumb")}}})}}function i(){d(window).scrollTop()+j>d(document).height()-.25*w.height()&&n()}var a,s,r,l,d=e("jquery"),c=e("hammer"),u=e("lazyload"),h=d("#brand-header"),p=d("#intro-box"),f=e("js/plugin/filter"),m=e("js/index/write-search"),g=e("js/plugin/tip"),v=e("js/plugin/loading"),w=d("#goods-container"),y=w.children(".new-goods"),b=w.children(".price-goods"),C=w.children(".discount-goods"),j=d(window).height(),x=d("#search-input input"),k=d(".search-icon"),q=d("#search-input .clear-input"),T=e("js/product/query-param"),E=d("#list-nav"),I={newest:{order:1,reload:!0,page:0,end:!1},price:{order:0,reload:!0,page:0,end:!1},discount:{order:0,reload:!0,page:0,end:!1}},z=E.find(".active");x.on("input",function(){""===x.val()?(k.css("color","#b2b2b2"),q.addClass("hide")):(k.css("color","#666"),q.removeClass("hide"))}),q.on("touchend",function(){x.val("").trigger("input")}),d("#search").on("touchend",function(){return d(this).closest("form").submit(),!1}),e("js/product/suspend-cart"),d.ajax({type:"GET",url:"/search/filter",data:T,success:function(e){w.append(e),f.initFilter({fCbFn:n,hCbFn:function(){z.addClass("active"),z.siblings(".filter").removeClass("active")}})}}),u(d(".lazy")),m.bindWirteLocal(d("#search-form")),E.bind("contextmenu",function(e){return!1}),E.on("touchend touchcancel",function(e){var t,o,i,a=d(e.target).closest("li");if(a.hasClass("filter"))a.hasClass("active")?(f.hideFilter(),z.addClass("active"),a.removeClass("active")):(z=a.siblings(".active"),z.removeClass("active"),a.addClass("active"),f.showFilter());else{if(a.hasClass("new")?o="newest":a.hasClass("price")?o="price":a.hasClass("discount")&&(o="discount"),t=I[o],a.hasClass("active")){if(a.hasClass("new"))return;(a.hasClass("price")||a.hasClass("discount"))&&(a.find(".icon > .iconfont").toggleClass("cur"),z=a,t.reload=!0,t.order=0===t.order?1:0)}else{if(i=a.siblings(".active"),z=a,i.hasClass("filter"))f.hideFilter();else switch(w.children(".container:not(.hide)").addClass("hide"),o){case"newest":y.removeClass("hide");break;case"price":b.removeClass("hide");break;case"discount":C.removeClass("hide")}i.removeClass("active"),a.addClass("active")}t.reload&&n()}}),d(window).scroll(function(){window.requestAnimationFrame(i)}),h.length>0&&(s=new c(h.children(".btn-intro")[0]),s.on("tap",function(){p.removeClass("hide"),d("body").addClass("overflow-hidden")}),r=new c(document.getElementById("intro-box")),r.on("tap",function(e){var t=d(e.target);e.srcEvent.preventDefault(),(0===t.closest("#brand-intro").length||t.hasClass("close-intro"))&&(p.addClass("hide"),d("body").removeClass("overflow-hidden"))}),l=new c(h.children(".btn-col")[0]),l.on("tap",function(e){var t,o=d(e.target).closest(".btn-col"),n=h.data("id");t=o.hasClass("coled")?"cancel":"ok",d.ajax({type:"POST",url:"/product/opt/favoriteBrand",data:{id:n,opt:t},success:function(e){200===e.code?(o.toggleClass("coled"),"ok"===t?g.show("添加收藏成功"):g.show("取消收藏成功")):400===e.code?location.href=e.data:g.show(e.message)},error:function(){g.show("网络断开连接了~")}})})),n(),E.on("touchstart","li",function(){E.find("li").removeClass("bytouch"),d(this).addClass("bytouch")}).on("touchend touchcancel","li",function(){E.find("li").removeClass("bytouch")})}),define("js/product/detail/detail",["jquery","swiper","hammer","lazyload","index"],function(e,t,o){function n(){var e=a(".cart-bar"),t=setInterval(function(){e?(window.reMarginFooter(".cart-bar"),clearInterval(t)):e=a(".cart-bar")},200)}var i,a=e("jquery"),s=e("swiper"),r=e("hammer"),l=e("lazyload"),d=a(".goodsDiscount .discount-folder"),c=a(".goodsDiscount .first-item span"),u=document.getElementById("goodsDiscount"),h=u&&new r(u),p=a(u).find(".first-item"),f=a(".cart-bar");n(),l(a("img.lazy")),i=new s(".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===d.children().length&&(d.css("display","none"),c.html("")),h&&d.children().length>0&&h.on("tap",function(e){d.is(":hidden")?(p.removeClass("short-text"),c.removeClass("icon-down").addClass("icon-up").html("&#xe608;"),d.slideDown()):(p.addClass("short-text"),c.removeClass("icon-up").addClass("icon-down").html("&#xe609;"),d.slideUp())}),e("js/product/detail/desc"),e("js/product/detail/comments-consults"),e("js/product/recommend-for-you-product-desc"),a.ajax({type:"GET",url:"/cart/index/count",success:function(e){200===e.code&&f.find(".num-tag").html(e.data.cart_goods_count).removeClass("hide")}}),a(".good-detail-page").length>0&&a("#yoho-footer").css("border-top","1px solid #e0e0e0"),e("js/product/detail/like")}),define("js/product/detail/desc",["jquery","lazyload","swiper","index"],function(e,t,o){function n(e){var t,o;e.length>0&&(t=e[0].getBoundingClientRect().right,o=e.find(".swiper-slide:last-child")[0].getBoundingClientRect().right,0>o-t?e.next(".tips").css("display","none"):e.next(".tips").css("display","block"))}function i(e,t){var o=null;c(e).each(function(n,i){o=c(e).slice(n,n+t),o.length===t&&n%t===0&&c(o).wrapAll(c('<div class="js-wraper"></div>'))})}function a(){v||w||(v=!0,p.showLoadingMask(),c.ajax({type:"GET",url:m,success:function(e){r=c("#productDesc"),r.append(e),window.rePosFooter(),u(r.find("img.lazy")),l=new h("#size-swiper-container",{slidesPerView:"auto"}),d=new h("#reference-swiper-container",{slidesPerView:"auto"}),n(c("#size-swiper-container")),n(c("#reference-swiper-container")),i(".detail .column",2),v=!1,w=!0,p.hideLoadingMask()},error:function(){f.show("网络断开连接了~"),v=!1,p.hideLoadingMask()}}))}function s(){(!w||c(window).scrollTop()+g>=c(document).height()-200)&&a()}var r,l,d,c=e("jquery"),u=e("lazyload"),h=e("swiper"),p=e("js/plugin/loading"),f=e("js/plugin/tip"),m=c("#introUrl").val(),g=c(window).height(),v=!1,w=!1;c(window).scroll(function(){window.requestAnimationFrame(s)})}),define("js/product/detail/comments-consults",["jquery","hammer"],function(e,t,o){var n,i,a=e("jquery"),s=e("js/plugin/tip"),r=e("hammer"),l=document.getElementById("nav-tab"),d=l&&new r(l),c=document.getElementById("goto-consult"),u=c&&new r(c);!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"))}(),d&&d.on("tap",function(e){var t=a(e.target).closest("li"),o=t.index();t.hasClass("comment-nav")&&0===n?s.show("暂无商品评价"):t.hasClass("focus")||(a("#nav-tab li").each(function(){a(this).removeClass("focus")}),a("#feedback-content .content").each(function(){a(this).addClass("hide")}),t.addClass("focus"),a("#feedback-content .content:eq("+o+")").removeClass("hide"))}),u&&u.on("tap",function(){location.href=a(c).data("href")}),a(".goods-consults-page").length>0&&a("#yoho-header").css("position","fixed").css("top","0")}),define("js/product/recommend-for-you-product-desc",["swiper","jquery","index"],function(e,t,o){function n(){h||u||(h=!0,d&&r.get(d).then(function(e){e.length<5?l.css("display","none"):(l.html(e).show(),r("#swiper-recommend").length&&(a=new s("#swiper-recommend",{slidesPerView:"auto",grabCursor:!0,slideElement:"a",lazyLoading:!0,watchSlidesVisibility:!0}))),h=!1,u=!0}).fail(function(){l.hide()}))}function i(){(!u||r(window).scrollTop()+c>=r(document).height()-50)&&n()}var a,s=e("swiper"),r=e("jquery"),l=r(".recommend-for-you"),d=r("#preferenceUrl").val(),c=r(window).height(),u=!1,h=!1;r(window).scroll(function(){window.requestAnimationFrame(i)})}),define("js/product/detail/like",["jquery","hammer"],function(e,t,o){var n=e("jquery"),i=e("hammer"),a=e("js/plugin/tip"),s=e("js/shopping-cart/chose-panel"),r=document.getElementById("likeBtn"),l=r&&new i(r),d=document.getElementById("addtoCart"),c=d&&new i(d),u=n("#productId").val();l&&l.on("tap",function(e){var t,o,i=n(e.target);i.hasClass("liked")?(t="cancel",o=0):(t="ok",o=1),n.ajax({type:"POST",url:"/product/opt/favoriteProduct",data:{id:u,opt:t},success:function(e){200===e.code?(i.toggleClass("liked"),"cancel"===t?a.show("取消收藏成功"):"ok"===t&&a.show("收藏成功")):400===e.code?location.href=e.data:a.show(e.message)},error:function(){a.show("网络断开连接了~")}}),window._yas&&window._yas.sendCustomInfo({pd:u,fa:o},!0)}),c&&c.on("tap",function(e){s.show(),window._yas&&window._yas.sendCustomInfo({pd:u,by:1},!0)})}),define("js/shopping-cart/chose-panel",["jquery"],function(e,t,o){function n(){r(".chose-panel").show(),r("body").css("overflow","hidden"),a=r("#good-num")}function i(){r(".chose-panel").hide(),r("body").css("overflow","auto")}var a,s,r=e("jquery");r(".yoho-page").on("touchstart",".chose-panel",function(e){var t=r(e.target);t.closest(".main").length>0||i()}).on("touchstart","#chose-btn-sure",function(){}).on("touchstart",".block",function(e){var t,o,n,i=r(this),a=r(e.target).closest(".chose-items"),l=i.closest(".block-list").siblings(":first"),d=i.data("numstr").split("/");if(i.siblings(".chosed").removeClass("chosed"),i.toggleClass("chosed"),o=i.index(),s=r(".block-list>ul>li.chosed"),i.closest(".block-list").hasClass("color-list")&&r(".chose-panel").find(".thumb").addClass("hide").eq(o).removeClass("hide"),0===s.length)i.closest("ul>li").each(function(){r(this).removeClass("zero-stock"),0===r(this).data("num")-0&&r(this).addClass("zero-stock")}),l.find("ul>li").each(function(){r(this).removeClass("zero-stock"),0===r(this).data("num")-0&&r(this).addClass("zero-stock")});else if(1===s.length&&i.hasClass("chosed"))for(t=s.data("numstr").split("/"),l.find(".block").removeClass("zero-stock"),n=0;n<t.length;n++)0===t[n]-0&&l.find(".block").eq(n).addClass("zero-stock");else if(1!==s.length||i.hasClass("chosed")){if(2===s.length){for(l.find(".block").removeClass("zero-stock"),n=0;n<d.length;n++)0===d[n]-0&&l.find(".block").eq(n).addClass("zero-stock");t=l.find(".chosed").data("numstr").split("/"),a.find(".num .left-num").html("剩余"+t[o]+"件"),2===s.closest(".zero-stock").length&&(r("#chose-btn-sure").css("background-color","#c0c0c0"),r("#chose-btn-sure").html("已售罄"))}}else l.find("ul>li").each(function(){r(this).removeClass("zero-stock"),0===r(this).data("num")-0&&r(this).addClass("zero-stock")}),a.find(".num .left-num").html("")}).on("touchstart",".btn-minus",function(){var e=+a.val(),t=r(".block-list>ul>li.chosed");t.length<2||0!==e&&a.val(e-1)}).on("touchstart",".btn-plus",function(){var e=+a.val();r(".block-list>ul>li.chosed").length<2||a.val(e+1)}),t.show=n}),define("js/product/detail/consultform",["jquery"],function(e,t,o){var n,i=e("jquery"),a=e("js/plugin/tip"),s=e("js/plugin/loading"),r=i(".consult-form"),l=i("#submit"),d=i("#content"),c=i("#product_id").val();l.on("touchend",function(){return d.blur(),r.submit(),!1}).on("touchstart",function(){i(this).addClass("highlight")}).on("touchend touchcancel",function(){i(this).removeClass("highlight")}),d.on("focus",function(){"请输入咨询内容"===d.val()&&d.val("")}).on("blur",function(){""===d.val()&&d.val("请输入咨询内容")}),r.on("submit",function(){var e;return n?!1:(e=d.val(),e&&"请输入咨询内容"!==e?(n=!0,s.showLoadingMask(),i.ajax({method:"POST",url:"/product/detail/consultsubmit",data:{product_id:c,content:e}}).then(function(e){"object"!==i.type(e)&&(e={}),200!==e.code?(a.show(e.message||"网络出了点问题~"),n=!1,s.hideLoadingMask()):(a.show("提交成功~"),setTimeout(function(){window.history.go(-1)},3e3))}).fail(function(){a.show("网络出了点问题~"),n=!1}),!1):(a.show("咨询内容不能为空"),!1))})}),define("js/product/newsale/hot-rank",["jquery","swiper","lazyload","index"],function(e,t,o){function n(e,t,o,n){h.showLoadingMask(),d.ajax({type:"GET",url:"/product/newsale/selectHotrank?"+t,dataType:"html",data:{page:e,tab_id:o,notab:n},success:function(t){" "===t?d(".rank-main").length<1&&d(".goods-nav").length<1?d("#hotRank").html(v):1===e&&(l=d(".goods-nav").prop("outerHTML"),d("#hotRank").html(l+v)):(d(".no-result").remove(),1===e&&d(".rank-main").remove(),d("#hotRank").append(t)),u(d("img.lazy")),d(".rank-main ul li:gt(9)").find(".item-content i").removeClass("top"),a=d(window).height(),0!==d(".rank-main").length?(d("#yoho-footer").css("position","static"),s=d(".rank-main").find("ul").offset().top):d("#yoho-footer").css("position","fixed"),r=new c(".s-goods-nav",{grabCursor:!0,slidesPerView:"auto",slideElement:"li"}),h.hideLoadingMask()}})}function i(){2!==p&&(d(window).scrollTop()+a<s+d("#hotRank").height()-100||(p=2,f=1,n(p,m,g,f)))}var a,s,r,l,d=e("jquery"),c=e("swiper"),u=e("lazyload"),h=e("js/plugin/loading"),p=1,f=0,m="",g="",v='<p class="no-result">未找到相关搜索结果</p>';e("js/product/suspend-cart"),d(window).scroll(function(){window.requestAnimationFrame(i)}),n(p,m,g,f),d("#hotRank").on("touchend touchcancel",function(e){var t=t||window.event,o=t.target||t.srcElement;"span"===o.nodeName.toLowerCase()&&(d(".s-goods-nav .nav-item").removeClass("active"),o.parentNode.className="active "+o.parentNode.className,g=o.getAttribute("data-id")?o.getAttribute("data-id"):"",m=o.getAttribute("data-sort")?o.getAttribute("data-sort"):"",p=1,f=1,n(p,m,g,f))}),d("#hotRank").bind("contextmenu",function(e){return!1}),d("#hotRank").on("touchstart",function(e){var t=t||window.event,o=t.target||t.srcElement;"span"===o.nodeName.toLowerCase()&&(o.parentNode.className="bgActive "+o.parentNode.className)}).on("touchend touchcancel",function(){d(".s-goods-nav .nav-item").removeClass("bgActive")})}),define("js/me/entry",["jquery","hammer","lazyload","handlebars","source-map","swiper","mlellipsis","index"],function(e,t,o){e("js/me/order"),e("js/me/order-detail"),e("js/me/fav"),e("js/me/suggest"),e("js/me/index"),e("js/me/coupons"),e("js/me/online-service"),e("js/me/address"),e("js/me/suggest"),e("js/me/browse-record"),e("js/me/address-act"),e("js/me/logistic"),e("js/me/pay"),e("js/me/personal-details"),e("js/me/currency")}),define("js/me/order",["jquery","hammer","lazyload","handlebars","source-map"],function(e,t,o){function n(e){var t={type:p,page:f.page+1},o=e&&!e.noLoadingMask;m||(m=!0,o&&g.showLoadingMask(),s.ajax({type:"GET",url:"/home/getOrders",data:t,success:function(e){var n;" "!==e?(f.page=t.page,1===t.page?(u.html(e),l(u.find(".lazy"),{try_again_css:"order-failure"})):(n=u.children(".order").length,u.append(e),l(u.children(".order:gt("+(n-1)+")").find(".lazy"),{try_again_css:"order-failure"})),window.rePosFooter()):f.end=!0,m=!1,o&&g.hideLoadingMask()}}))}function i(){f.end===!1&&s(window).scrollTop()+h>s(document).height()-.25*c.height()&&n({noLoadingMask:!0})}var a,s=e("jquery"),r=e("hammer"),l=e("lazyload"),d=s("#order-nav > li"),c=s("#order-container"),u=c.children(".orders:not(.hide)"),h=s(window).height(),p=d.filter(".active").data("type"),f={page:0,end:!1},m=!1,g=e("js/plugin/loading"),v=e("js/me/dialog");l({try_again_css:"order-failure"}),function(){var e=d.length;4!==e&&d.width(100/e+"%")}(),g.init(s("body")),a=new r(document.getElementById("order-container")),a.on("tap",function(e){var t,o,n,i=s(e.target);i.closest(".locHref").length>0||(t=i.closest(".order"),o=t.data("id"),i.closest(".del").length>0?v.showDialog({
dialogText:"确定删除订单吗?",hasFooter:{leftBtnText:"取消",rightBtnText:"确定"}},function(){s.ajax({type:"GET",url:"/home/delOrder",data:{id:o},success:function(e){200===e.code&&(v.showDialog({dialogText:"删除订单成功",autoHide:!0,fast:!0}),history.go(0))},error:function(){v.showDialog({dialogText:"删除订单失败",autoHide:!0,fast:!0})}})}):i.closest(".cancel").length>0?v.showDialog({dialogText:"确定取消订单吗?",hasFooter:{leftBtnText:"取消",rightBtnText:"确定"}},function(){s.ajax({type:"GET",url:"/home/cancelOrder",data:{id:o},success:function(e){200===e.code&&(v.showDialog({dialogText:"取消订单成功",autoHide:!0,fast:!0}),history.go(0))},error:function(){v.showDialog({dialogText:"取消订单失败",autoHide:!0,fast:!0})}})}):i.closest(".order-goods").length>0&&(n=t.data("href"),location.href=n))}),s(window).scroll(function(){window.requestAnimationFrame(i)}),n()}),define("js/me/dialog",["jquery","handlebars","source-map","hammer"],function(e,t,o){var n,i,a,s=e("jquery"),r=e("handlebars"),l=e("hammer");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">{{.}}</span>{{/ leftBtnText}}{{# rightBtnText}}<span class="dialog-right-btn">{{.}}</span>{{/ rightBtnText}}</div>{{/ hasFooter}}</div></div>',a=r.compile(i),t.showDialog=function(e,t){var o,i,r,d=a(e);s(".dialog-wrapper").remove(),s("body").append(s(d)),o=s(".dialog-box"),n=s(".dialog-wrapper"),r=new l(document.getElementById("dialog-wrapper")),e.fast?n.css({display:"block"}):n.fadeIn(),o.css({top:"50%",marginTop:-(o.height()/2)}),e.autoHide&&(i=1e3,e.autoHide>1&&(i=e.autoHide),setTimeout(function(){n.fadeOut()},i)),r.on("tap",function(e){s(e.target).hasClass("dialog-left-btn")?n.fadeOut():s(e.target).hasClass("dialog-right-btn")&&t()})}}),define("js/me/order-detail",["jquery","lazyload","hammer","handlebars","source-map"],function(e,t,o){var n,i=e("jquery"),a=e("lazyload"),s=e("hammer"),r=e("js/me/dialog"),l=e("js/plugin/tip"),d=i("#order-detail").data("id");a({try_again_css:"order-failure"}),n=new s(document.getElementsByClassName("opt")[0]),n.on("tap",function(e){var t=i(e.target);t.hasClass("btn-del")?r.showDialog({dialogText:"确定删除订单吗?",hasFooter:{leftBtnText:"取消",rightBtnText:"确定"}},function(){i.ajax({type:"GET",url:"/home/delOrder",data:{id:d}}).then(function(e){i("#dialog-wrapper").hide(),e||l.show("网络错误"),200===e.code?l.show("删除成功"):l.show(e.message||"网络错误"),window.location.href="/home/orders"}).fail(function(){l.show("网络错误")})}):t.hasClass("btn-cancel")&&r.showDialog({dialogText:"确定取消订单吗?",hasFooter:{leftBtnText:"取消",rightBtnText:"确定"}},function(){i.ajax({type:"GET",url:"/home/cancelOrder",data:{id:d}}).then(function(e){i("#dialog-wrapper").hide(),e||l.show("网络错误"),200===e.code?l.show("取消成功"):l.show(e.message||"网络错误"),window.location.reload()}).fail(function(){l.show("网络错误")})})})}),define("js/me/fav",["jquery","hammer","swiper","handlebars","source-map","index"],function(e,t,o){function n(e){p.filter(".active").removeClass("active"),p.eq(e).addClass("active"),f.filter(".show").removeClass("show"),f.eq(e).addClass("show")}function i(e){var t,o,n=/container-(\d+)['"]{1}/gi,i=/\d+/,a=e.match(n),s=a.length;for(t=0;s>t;t++)o=a[t].match(i)[0],m[o]=new u("#swiper-container-"+o,{slidesPerView:"auto",grabCursor:!0,slideElement:"li",wrapperClass:"swiper-wrapper-"+o,lazyLoading:!0,watchSlidesVisibility:!0})}function a(e,t,o){"favBrand"===t?q=!0:k=!0,d.ajax({method:"post",url:"/home/"+t,data:{page:o},success:function(o){"favBrand"===t?v.addClass("hide"):g.addClass("hide")," "===o?(e.closest(".fav-type").find(".fav-content-loading").addClass("hide"),e.closest(".fav-type").find(".fav-null-box").removeClass("hide")):"end"===o?e.closest(".fav-type").find(".fav-load-background").removeClass("fav-load-background").html("没有更多了"):o.length>10&&(e.append(o),e.closest(".fav-type").find(".fav-content-loading").remove(),"favBrand"===t?(i(o),q=!1):k=!1),window.rePosFooter()}})}function s(){d(window).scrollTop()+w>=d(document).height()-.25*C.height()-y&&(T?(v.filter(".hide").removeClass("hide"),q||(x++,a(C,"favBrand",x))):(g.filter(".hide").removeClass("hide"),k||(j++,a(b,"favProduct",j))))}var r,l,d=e("jquery"),c=e("hammer"),u=e("swiper"),h=e("js/me/dialog"),p=d("#fav-tab > li"),f=d(".fav-content > .fav-type"),m={},g=d(".fav-load-more"),v=d(".fav-brand-load-more"),w=d(window).height(),y=d("#yoho-footer").height(),b=d(".fav-product-list"),C=d(".fav-brand-swiper-wrapper"),j=1,x=1,k=!0,q=!0,T=!1;d("#fav-tab").hasClass("brand-tab")?(n(1),a(C,"favBrand",1),T=!0,window.rePosFooter()):(n(0),a(b,"favProduct",1),T=!1,window.rePosFooter()),r=new c(document.getElementById("fav-tab")),r.on("tap",function(e){var t,o=d(e.target).closest("li");0===o.length||o.hasClass("active")||(t=o.index(),0===t?(T=!1,0===b.find("li").length&&b.closest(".fav-type").find(".fav-null-box").hasClass("hide")&&a(b,"favProduct",1)):(T=!0,0===C.find("div").length&&C.closest(".fav-type").find(".fav-null-box").hasClass("hide")&&a(C,"favBrand",1)),n(t),window.rePosFooter())}),l=new c(document.getElementById("fav-content")),l.on("tap",function(e){var t="";d(e.target).hasClass("del-fav")&&h.showDialog({dialogText:"您确定要取消收藏吗?",hasFooter:{leftBtnText:"取消",rightBtnText:"确定"}},function(){t=d(e.target).closest("li").attr("data-id"),d.ajax({method:"post",url:"/home/favoriteDel",data:{id:t}}).then(function(t){200===t.code?(h.showDialog({autoHide:!0,fast:!0,dialogText:"已经取消收藏"}),d(e.target).closest("li").remove()):400===t.code?h.showDialog({autoHide:!0,fast:!0,dialogText:t.message}):h.showDialog({autoHide:!0,fast:!0,dialogText:"取消收藏失败"})}).fail(function(){h.showDialog({autoHide:!0,dialogText:"网络错误~"})})})}),d(window).scroll(s),d(document).on("touchend",".swiper-header",function(){var e=d(this).find(".fav-more").attr("href");window.location.href=e})}),define("js/me/suggest",["jquery","hammer","lazyload","handlebars","source-map"],function(e,t,o){var n,i,a,s,r=e("jquery"),l=e("hammer"),d=e("lazyload"),c=e("handlebars"),u=e("js/me/dialog"),h=r(".upload-img-list"),p=r(".suggest-item .like-btn"),f=r(".suggest-item .dislike-btn"),m=r(".img-add"),g="",v=0;e("js/me/jquery.upload"),a='{{# imgList}}<li>{{# imgUrl}}<img src="{{.}}" /><span class="upload-img-remove"></span>{{/ imgUrl}}</li>{{/ imgList}}',s=c.compile(a),r("#upload-img").upload({auto:!0,fileType:"image/*",uploadScript:"/home/suggestimgUpload",fileObjName:"fileData",fileSizeLimit:300,height:"100%",width:"100%",multi:!1,onAddQueueItem:function(e){h.html(s({imgList:!0}))},onUploadComplete:function(e,t){h.html(""),g=JSON.parse(t).imgList[0].imgRelUrl,h.html(s(JSON.parse(t))),m.hide(),v++}}),d(),n=new l(document.getElementById("yoho-header")),n.on("tap",function(e){var t=r("#suggest-textarea").val(),o=/\S+/;if(r(e.target).hasClass("nav-btn")){if(!o.test(t))return void u.showDialog({autoHide:!0,dialogText:"意见不能为空"});r.ajax({method:"post",url:"/home/savesuggest",data:{content:t,image:g}}).then(function(e){200===e.code?(u.showDialog({autoHide:!0,dialogText:"提交成功"}),setTimeout(function(){location.pathname="home/suggest"},2e3)):u.showDialog({autoHide:!0,dialogText:"提交失败~"})}).fail(function(){u.showDialog({autoHide:!0,dialogText:"网络错误~"})})}}),null!==document.getElementById("img-form")&&(i=new l(document.getElementById("img-form")),i.on("tap",function(e){r(e.target).hasClass("upload-img-remove")&&(h.html(""),g="",v--,setTimeout(function(){m.show()},50))})),p.bind("click",function(){var e=r(this).closest(".suggest-item").attr("data-id"),t=r(this);r.ajax({method:"post",url:"/home/upAndDown",data:{suggest_id:e,reliable:1}}).then(function(e){200===e.code&&(t.closest(".suggest-type").removeClass("show"),t.closest(".suggest-item").find(".suggest-good").addClass("show"))}).fail(function(e){u.showDialog({autoHide:!0,dialogText:"网络错误~"})})}),f.bind("click",function(){var e=r(this).closest(".suggest-item").attr("data-id"),t=r(this);r.ajax({method:"post",url:"/home/upAndDown",data:{suggest_id:e,reliable:2}}).then(function(e){200===e.code&&(t.closest(".suggest-type").removeClass("show"),t.closest(".suggest-item").find(".suggest-bad").addClass("show"))}).fail(function(e){u.showDialog({autoHide:!0,dialogText:"网络错误~"})})})}),define("js/me/jquery.upload",["jquery"],function(e,t,o){var n=e("jquery");!function(e){var t={init:function(o){return this.each(function(){var n=e(this);n.data("uploadifive",{inputs:{},inputCount:0,fileID:0,queue:{count:0,selected:0,replaced:0,errors:0,queued:0,cancelled:0},uploads:{current:0,attempts:0,successful:0,errors:0,count:0}});var a=n.data("uploadifive"),s=a.settings=e.extend({auto:!0,buttonClass:!1,buttonText:"Select Files",checkScript:!1,dnd:!0,dropTarget:!1,fileObjName:"Filedata",fileSizeLimit:0,fileType:!1,formData:{},height:30,itemTemplate:!1,method:"post",multi:!0,overrideEvents:[],queueID:!1,queueSizeLimit:0,removeCompleted:!1,simUploadLimit:0,truncateLength:0,uploadLimit:0,uploadScript:"uploadifive.php",width:100},o);if(isNaN(s.fileSizeLimit)){var r=1.024*parseInt(s.fileSizeLimit);s.fileSizeLimit.indexOf("KB")>-1?s.fileSizeLimit=1e3*r:s.fileSizeLimit.indexOf("MB")>-1?s.fileSizeLimit=1e6*r:s.fileSizeLimit.indexOf("GB")>-1&&(s.fileSizeLimit=1e9*r)}else s.fileSizeLimit=1024*s.fileSizeLimit;if(a.inputTemplate=e('<input type="file">').css({"font-size":s.height+"px",opacity:0,position:"absolute",right:"-3px",top:"-3px","z-index":999}),a.createInput=function(){var o=a.inputTemplate.clone(),i=o.name="input"+a.inputCount++;s.multi&&o.attr("multiple",!0),s.fileType&&o.attr("accept",s.fileType),o.bind("change",function(){a.queue.selected=0,a.queue.replaced=0,a.queue.errors=0,a.queue.queued=0;var o=this.files.length;if(a.queue.selected=o,a.queue.count+o>s.queueSizeLimit&&0!==s.queueSizeLimit)e.inArray("onError",s.overrideEvents)<0&&alert("The maximum number of queue items has been reached ("+s.queueSizeLimit+"). Please select fewer files."),"function"==typeof s.onError&&s.onError.call(n,"QUEUE_LIMIT_EXCEEDED");else{for(var r=0;o>r;r++)file=this.files[r],a.addQueueItem(file);a.inputs[i]=this,a.createInput()}s.auto&&t.upload.call(n),"function"==typeof s.onSelect&&s.onSelect.call(n,a.queue)}),a.currentInput&&a.currentInput.hide(),a.button.append(o),a.currentInput=o},a.destroyInput=function(t){e(a.inputs[t]).remove(),delete a.inputs[t],a.inputCount--},a.drop=function(o){a.queue.selected=0,a.queue.replaced=0,a.queue.errors=0,a.queue.queued=0;var i=o.dataTransfer,r=i.name="input"+a.inputCount++,l=i.files.length;if(a.queue.selected=l,a.queue.count+l>s.queueSizeLimit&&0!==s.queueSizeLimit)e.inArray("onError",s.overrideEvents)<0&&alert("The maximum number of queue items has been reached ("+s.queueSizeLimit+"). Please select fewer files."),"function"==typeof s.onError&&s.onError.call(n,"QUEUE_LIMIT_EXCEEDED");else{for(var d=0;l>d;d++)file=i.files[d],a.addQueueItem(file);a.inputs[r]=i}s.auto&&t.upload.call(n),"function"==typeof s.onDrop&&s.onDrop.call(n,i.files,i.files.length),o.preventDefault(),o.stopPropagation()},a.fileExistsInQueue=function(e){for(var t in a.inputs){input=a.inputs[t],limit=input.files.length;for(var o=0;o<limit;o++)if(existingFile=input.files[o],existingFile.name==e.name&&!existingFile.complete)return!0}return!1},a.removeExistingFile=function(e){for(var o in a.inputs){input=a.inputs[o],limit=input.files.length;for(var i=0;i<limit;i++)existingFile=input.files[i],existingFile.name!=e.name||existingFile.complete||(a.queue.replaced++,t.cancel.call(n,existingFile,!0))}},0==s.itemTemplate?a.queueItem=e('<div class="uploadifive-queue-item"> <a class="close" href="#">X</a> <div><span class="filename"></span><span class="fileinfo"></span></div> <div class="progress"> <div class="progress-bar"></div> </div> </div>'):a.queueItem=e(s.itemTemplate),a.addQueueItem=function(o){if(e.inArray("onAddQueueItem",s.overrideEvents)<0){a.removeExistingFile(o),o.queueItem=a.queueItem.clone(),o.queueItem.attr("id",s.id+"-file-"+a.fileID++),o.queueItem.find(".close").bind("click",function(){return t.cancel.call(n,o),!1});var i=o.name;i.length>s.truncateLength&&0!=s.truncateLength&&(i=i.substring(0,s.truncateLength)+"..."),o.queueItem.find(".filename").html(i),o.queueItem.data("file",o),a.queueEl.append(o.queueItem)}"function"==typeof s.onAddQueueItem&&s.onAddQueueItem.call(n,o),o.size>s.fileSizeLimit&&0!=s.fileSizeLimit?a.error("FILE_SIZE_LIMIT_EXCEEDED",o):(a.queue.queued++,a.queue.count++)},a.removeQueueItem=function(t,o,n){n||(n=0);var i=o?0:500;t.queueItem&&(" - Completed"!=t.queueItem.find(".fileinfo").html()&&t.queueItem.find(".fileinfo").html(" - Cancelled"),t.queueItem.find(".progress-bar").width(0),t.queueItem.delay(n).fadeOut(i,function(){e(this).remove()}),delete t.queueItem,a.queue.count--)},a.filesToUpload=function(){var e=0;for(var t in a.inputs){input=a.inputs[t],limit=input.files.length;for(var o=0;o<limit;o++)file=input.files[o],file.skip||file.complete||e++}return e},a.checkExists=function(o){if(e.inArray("onCheck",s.overrideEvents)<0){e.ajaxSetup({async:!1});var i=e.extend(s.formData,{filename:o.name});if(e.post(s.checkScript,i,function(e){o.exists=parseInt(e)}),o.exists&&!confirm("A file named "+o.name+" already exists in the upload folder.\nWould you like to replace it?"))return t.cancel.call(n,o),!0}return"function"==typeof s.onCheck&&s.onCheck.call(n,o,o.exists),!1},a.uploadFile=function(t,o){if(!t.skip&&!t.complete&&!t.uploading)if(t.uploading=!0,a.uploads.current++,a.uploads.attempted++,xhr=t.xhr=new XMLHttpRequest,"function"==typeof FormData||"object"==typeof FormData){var r=new FormData;r.append(s.fileObjName,t);for(i in s.formData)r.append(i,s.formData[i]);xhr.open(s.method,s.uploadScript,!0),xhr.upload.addEventListener("progress",function(e){e.lengthComputable&&a.progress(e,t)},!1),xhr.addEventListener("load",function(e){4==this.readyState&&(t.uploading=!1,200==this.status?"Invalid file type."!==t.xhr.responseText?a.uploadComplete(e,t,o):a.error(t.xhr.responseText,t,o):404==this.status?a.error("404_FILE_NOT_FOUND",t,o):403==this.status?a.error("403_FORBIDDEN",t,o):a.error("Unknown Error",t,o))}),xhr.send(r)}else{var l=new FileReader;l.onload=function(i){var r="-------------------------"+(new Date).getTime(),l="--",d="\r\n",c="";c+=l+r+d,c+='Content-Disposition: form-data; name="'+s.fileObjName+'"',t.name&&(c+='; filename="'+t.name+'"'),c+=d,c+="Content-Type: application/octet-stream"+d+d,c+=i.target.result+d;for(key in s.formData)c+=l+r+d,c+='Content-Disposition: form-data; name="'+key+'"'+d+d,c+=s.formData[key]+d;c+=l+r+l+d,xhr.upload.addEventListener("progress",function(e){a.progress(e,t)},!1),xhr.addEventListener("load",function(e){t.uploading=!1;var n=this.status;404==n?a.error("404_FILE_NOT_FOUND",t,o):"Invalid file type."!=t.xhr.responseText?a.uploadComplete(e,t,o):a.error(t.xhr.responseText,t,o)},!1);var u=s.uploadScript;if("get"==s.method){var h=e(s.formData).param();u+=h}xhr.open(s.method,s.uploadScript,!0),xhr.setRequestHeader("Content-Type","multipart/form-data; boundary="+r),"function"==typeof s.onUploadFile&&s.onUploadFile.call(n,t),xhr.sendAsBinary(c)},l.readAsBinaryString(t)}},a.progress=function(t,o){if(e.inArray("onProgress",s.overrideEvents)<0){if(t.lengthComputable)var i=Math.round(t.loaded/t.total*100);o.queueItem.find(".fileinfo").html(" - "+i+"%"),o.queueItem.find(".progress-bar").css("width",i+"%")}"function"==typeof s.onProgress&&s.onProgress.call(n,o,t)},a.error=function(o,i,r){if(e.inArray("onError",s.overrideEvents)<0){switch(o){case"404_FILE_NOT_FOUND":errorMsg="404 Error";break;case"403_FORBIDDEN":errorMsg="403 Forbidden";break;case"FORBIDDEN_FILE_TYPE":errorMsg="Forbidden File Type";break;case"FILE_SIZE_LIMIT_EXCEEDED":errorMsg="File Too Large";break;default:errorMsg="Unknown Error"}i.queueItem.addClass("error").find(".fileinfo").html(" - "+errorMsg),i.queueItem.find(".progress").remove()}"function"==typeof s.onError&&s.onError.call(n,o,i),i.skip=!0,"404_FILE_NOT_FOUND"==o?a.uploads.errors++:a.queue.errors++,r&&t.upload.call(n,null,!0)},a.uploadComplete=function(o,i,r){e.inArray("onUploadComplete",s.overrideEvents)<0&&(i.queueItem.find(".progress-bar").css("width","100%"),i.queueItem.find(".fileinfo").html(" - Completed"),i.queueItem.find(".progress").slideUp(250),i.queueItem.addClass("complete")),"function"==typeof s.onUploadComplete&&s.onUploadComplete.call(n,i,i.xhr.responseText),s.removeCompleted&&setTimeout(function(){t.cancel.call(n,i)},3e3),i.complete=!0,a.uploads.successful++,a.uploads.count++,a.uploads.current--,delete i.xhr,r&&t.upload.call(n,null,!0)},a.queueComplete=function(){"function"==typeof s.onQueueComplete&&s.onQueueComplete.call(n,a.uploads)},!(window.File&&window.FileList&&window.Blob&&(window.FileReader||window.FormData)))return"function"==typeof s.onFallback&&s.onFallback.call(n),!1;if(s.id="uploadifive-"+n.attr("id"),a.button=e('<div id="'+s.id+'" class="uploadifive-button">'+s.buttonText+"</div>"),s.buttonClass&&a.button.addClass(s.buttonClass),a.button.css({height:s.height,"line-height":s.height+"px",overflow:"hidden",position:"relative","text-align":"center",width:s.width}),n.before(a.button).appendTo(a.button).hide(),a.createInput.call(n),s.queueID?a.queueEl=e("#"+s.queueID):(s.queueID=s.id+"-queue",a.queueEl=e('<div id="'+s.queueID+'" class="uploadifive-queue" />'),a.button.after(a.queueEl)),s.dnd){var l=s.dropTarget?e(s.dropTarget):a.queueEl.get(0);l.addEventListener("dragleave",function(e){e.preventDefault(),e.stopPropagation()},!1),l.addEventListener("dragenter",function(e){e.preventDefault(),e.stopPropagation()},!1),l.addEventListener("dragover",function(e){e.preventDefault(),e.stopPropagation()},!1),l.addEventListener("drop",a.drop,!1)}XMLHttpRequest.prototype.sendAsBinary||(XMLHttpRequest.prototype.sendAsBinary=function(e){function t(e){return 255&e.charCodeAt(0)}var o=Array.prototype.map.call(e,t),n=new Uint8Array(o);this.send(n.buffer)}),"function"==typeof s.onInit&&s.onInit.call(n)})},debug:function(){return this.each(function(){console.log(e(this).data("uploadifive"))})},clearQueue:function(){this.each(function(){var o=e(this),n=o.data("uploadifive"),a=n.settings;for(var s in n.inputs)for(input=n.inputs[s],limit=input.files.length,i=0;i<limit;i++)file=input.files[i],t.cancel.call(o,file);"function"==typeof a.onClearQueue&&a.onClearQueue.call(o,e("#"+n.settings.queueID))})},cancel:function(o,n){this.each(function(){var i=e(this),a=i.data("uploadifive"),s=a.settings;"string"==typeof o&&(isNaN(o)||(fileID="uploadifive-"+e(this).attr("id")+"-file-"+o),o=e("#"+fileID).data("file")),o.skip=!0,a.filesCancelled++,o.uploading&&(a.uploads.current--,o.uploading=!1,o.xhr.abort(),delete o.xhr,t.upload.call(i)),e.inArray("onCancel",s.overrideEvents)<0&&a.removeQueueItem(o,n),"function"==typeof s.onCancel&&s.onCancel.call(i,o)})},upload:function(t,o){this.each(function(){var n=e(this),i=n.data("uploadifive"),a=i.settings;if(t)i.uploadFile.call(n,t);else if(i.uploads.count+i.uploads.current<a.uploadLimit||0==a.uploadLimit){if(!o){i.uploads.attempted=0,i.uploads.successsful=0,i.uploads.errors=0;var s=i.filesToUpload();"function"==typeof a.onUpload&&a.onUpload.call(n,s)}e("#"+a.queueID).find(".uploadifive-queue-item").not(".error, .complete").each(function(){return _file=e(this).data("file"),i.uploads.current>=a.simUploadLimit&&0!==a.simUploadLimit||i.uploads.current>=a.uploadLimit&&0!==a.uploadLimit||i.uploads.count>=a.uploadLimit&&0!==a.uploadLimit?!1:void(a.checkScript?(_file.checking=!0,skipFile=i.checkExists(_file),_file.checking=!1,skipFile||i.uploadFile(_file,!0)):i.uploadFile(_file,!0))}),0==e("#"+a.queueID).find(".uploadifive-queue-item").not(".error, .complete").size()&&i.queueComplete()}else 0==i.uploads.current&&(e.inArray("onError",a.overrideEvents)<0&&i.filesToUpload()>0&&0!=a.uploadLimit&&alert("The maximum upload limit has been reached."),"function"==typeof a.onError&&a.onError.call(n,"UPLOAD_LIMIT_EXCEEDED",i.filesToUpload()))})},destroy:function(){this.each(function(){var o=e(this),n=o.data("uploadifive"),i=n.settings;t.clearQueue.call(o),i.queueID||e("#"+i.queueID).remove(),o.siblings("input").remove(),o.show().insertBefore(n.button),n.button.remove(),"function"==typeof i.onDestroy&&i.onDestroy.call(o)})}};e.fn.upload=function(o){return t[o]?t[o].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof o&&o?void e.error("The method "+o+" does not exist in $.uploadify"):t.init.apply(this,arguments)}}(n)}),define("js/me/index",["jquery","swiper","index"],function(e,t,o){var n,i=e("jquery"),a=i(".user-avatar"),s=i(".list-item"),r=new Image;e("js/product/recommend-for-you"),e("js/product/suspend-cart"),n=a.data("avatar"),r.src=n,r.onload=function(){a.css("background-image","url("+n+")")},i(".yoho-page").on("touchstart",".list-item, .type-item, .order-title",function(){s.removeClass("highlight"),i(this).addClass("highlight")}).on("touchend touchcancel",".list-item, .type-item, .order-title",function(){i(this).removeClass("highlight")})}),define("js/product/recommend-for-you",["swiper","jquery","index"],function(e,t,o){var n,i=e("swiper"),a=e("jquery"),s=a(".recommend-for-you");a.get("/home/preference").then(function(e){s.html(e).show(),a("#swiper-recommend").length&&(n=new i("#swiper-recommend",{slidesPerView:"auto",grabCursor:!0,slideElement:"a",lazyLoading:!0,watchSlidesVisibility:!0}))}).fail(function(){s.hide()})}),define("js/me/coupons",["jquery","hammer","mlellipsis"],function(e,t,o){function n(e,t){l.showLoadingMask(),a.ajax({type:"POST",url:"/home/couponData",dataType:"html",data:{status:e,page:t},success:function(e){a("#employ").append(e),window.rePosFooter(),l.hideLoadingMask()}})}var i,a=e("jquery"),s=e("hammer"),r=e("mlellipsis"),l=e("js/plugin/loading"),d=0,c=1;r.init(),a(".yoho-footer").css("border-top","1px solid #e0e0e0"),a(".employ span").each(function(e){i=new s(a(".employ span")[e]),i.on("tap",function(t){a(".employ span").removeClass("active").eq(e).addClass("active"),a("#employ").html(" "),d=e,c=1,n(d,c),window.rePosFooter()})}),a(window).scroll(function(){return a(window).scrollTop()+a(window).height()>a("body").height()-1?(c++,void n(d,c)):void 0}),n(d,c)}),define("js/me/online-service",["jquery"],function(e,t,o){var n=e("jquery"),i=n(".question-tab .tab-item");i.on("touchend",function(){var e=n(this).data("tab");e='[data-tab-name="'+e+'"]',i.removeClass("current"),n(this).addClass("current"),n(".question-list").removeClass("current"),n(e).addClass("current")}),n(".yoho-page").on("touchstart",".connect-item, .question-item",function(){n(this).siblings().removeClass("highlight"),n(this).addClass("highlight")}).on("touchend touchcancel",".connect-item, .question-item",function(){n(this).removeClass("highlight")})}),define("js/me/address",["jquery"],function(e,t,o){var n,i=e("jquery"),a=e("js/plugin/tip"),s=e("js/plugin/loading"),r=i(".action"),l=i(".add-address"),d=i("#yoho-footer"),c=i(".confim-mask"),u=i(".page-wrap"),h=i(".address-item");u.first().css("min-height",function(){return i(window).height()-i("#yoho-header").height()-d.height()}),window.rePosFooter(),c.on("touchend",".cancel",function(e){return n=null,c.fadeOut(),!1}).on("touchend",".confim",function(){return s.showLoadingMask(),c.fadeOut(),i.ajax({method:"POST",url:"/home/delAddress",data:{id:n}}).then(function(e){"object"!==i.type(e)&&(e={}),200!==e.code?(a.show(e.message||"网络出了点问题~"),s.hideLoadingMask()):window.location.reload()}).fail(function(){a.show("网络出了点问题~"),s.hideLoadingMask()}).always(function(){n=null}),!1}),h.length<5&&l.attr("href",l.data("href")),l.on("touchend",function(){return h.length>=5?(a.show("您最多添加5个收货地址"),!1):void 0}),r.on("touchend",".del",function(){return n=i(this).data("id"),c.fadeIn(),!1})}),define("js/me/browse-record",["jquery","lazyload","handlebars","source-map","hammer"],function(e,t,o){function n(e){var t=l.children(".browse-record-good").length;f||(1===h&&d.removeClass("hide"),f=!0,i.ajax({type:"GET",url:"/home/recordContent",data:{page:h+1},success:function(o){" "===o?(p=!0,c.addClass("hide"),u.removeClass("hide")):(0===t?(l.html(o),a()):(l.append(o),a(l.find(".browse-record-good:gt("+(t-1)+") .lazy"))),window.rePosFooter(),h++,e&&e())},complete:function(){f=!1}}))}var i=e("jquery"),a=e("lazyload"),s=e("js/plugin/loading"),r=e("js/me/dialog"),l=i(".records"),d=i(".load-more"),c=d.children(".more"),u=d.children(".no-more"),h=0,p=!1,f=!1,m=i(window).height();s.init(),s.showLoadingMask(),n(s.hideLoadingMask),i(window).scroll(function(){p||m+i(window).scrollTop()>i(document).height()-.25*l.height()&&n()}),l.on("touchstart",".del-icon",function(){var e=i(this).closest(".browse-record-good"),t=e.data("skn");r.showDialog({dialogText:"确定删除此条浏览记录吗?",hasFooter:{leftBtnText:"取消",rightBtnText:"确定"}},function(){i.ajax({type:"GET",url:"/home/delRecord",data:{skn:t},success:function(e){200===e.code&&(r.showDialog({dialogText:"删除浏览记录成功",autoHide:2e3,fast:!0}),setTimeout(function(){window.history.go(0)},1200))}})})})}),define("js/me/address-act",["jquery","hammer"],function(e,t,o){var n,i=e("jquery"),a=e("hammer"),s=e("js/plugin/tip"),r=e("js/plugin/security"),l=e("js/plugin/loading"),d=i(".edit-address"),c=i(".submit"),u=i(".my-edit-address-page"),h=i(".my-address-list-page"),p=i(".nav-back"),f=i(".nav-title"),m=i("input, textarea"),g=f.html(),v=i(".area"),w="edit",y=[],b=i.queryString();i(u,h).css("min-height",function(){return i(window).height()-i("#yoho-header").height()}),p.attr("href","javascript:void(0);"),p.on("touchend",function(e){"list"===w?(h.hide(),u.show(),e.preventDefault(),w="edit",f.html(g),h.hide(),h.find("ul").hide().find("li").removeClass("highlight"),h.children("ul").show().children("li").show(),y=[]):window.history.go(-1)}),d.on("submit",function(){return n?!1:r.hasDangerInput(!1)?!1:i(this).find('[name="consignee"]').val()?i(this).find('[name="mobile"]').val()?i(this).find('[name="area_code"]').val()&&i(this).find('[name="area"]').val()?i(this).find('[name="address"]').val()?(n=!0,l.showLoadingMask(),i.ajax({method:"POST",url:"/home/saveAddress",data:i(this).serialize()}).then(function(e){"object"!==i.type(e)&&(e={}),200!==e.code?(s.show(e.message||"网络出了点问题~"),n=!1,l.hideLoadingMask()):"shopping"===b.refer?window.location.href="/shoppingCart/selectAddress":window.location.href="/home/address"}).fail(function(){s.show("网络出了点问题~"),n=!1}),!1):(s.show("地址不能为空"),!1):(s.show("省市区不能为空"),!1):(s.show("手机号不能为空"),!1):(s.show("收件人不能为空"),!1)}),c.on("touchend",function(){return r.hasDangerInput(!1)?!1:(m.blur(),d.submit(),!1)}).on("touchstart",function(){i(this).addClass("highlight")}).on("touchend touchcancel",function(){i(this).removeClass("highlight")}),i.get("/home/locationList").then(function(e){h.html(e),v.on("touchend",function(){u.hide(),h.show(),w="list",f.html("地区选择")}),h.find(".address").each(function(e,t){var o=new a(t);o.on("tap",function(e){var t=i(e.target);"li"!==e.target.tagName.toLowerCase()&&(t=t.parent("li")),y.push(t.children(".caption").text()),t.siblings().hide(),t.children("ul").show().children("li").show(),e.srcEvent.preventDefault(),e.srcEvent.stopPropagation()})}),h.find(".address-last").each(function(e,t){var o=new a(t);o.on("tap",function(e){var t=i(e.target);y.push(t.children(".caption").text()),i('[name="area"]').val(y.join(" ")),i('[name="area_code"]').val(t.data("id")),u.show(),w="edit",f.html(g),h.hide(),h.find("ul").hide().find("li").removeClass("highlight"),h.children("ul").show().children("li").show(),y=[],e.srcEvent.preventDefault(),e.srcEvent.stopPropagation()})}),h.on("touchstart","li",function(){i(this).addClass("highlight")}).on("touchend touchcancel","li",function(){i(this).removeClass("highlight")})}).fail(function(){s.show("获取省市区列表失败")})}),define("js/me/logistic",["jquery"],function(e,t,o){function n(){l+r>s?window.rePosFooter():a.css("border-top","1px solid #f1f1f1")}var i=e("jquery"),a=i("#yoho-footer"),s=window.outerHeight,r=document.body.offsetHeight,l=a.height();i(document).ready(n)}),define("js/me/pay",["jquery","hammer"],function(e,t,o){function n(){document.addEventListener("WeixinJSBridgeReady",function(){window.WeixinJSBridge&&window.WeixinJSBridge.call("hideOptionMenu")})}function i(e,t){window.WeixinJSBridge&&window.WeixinJSBridge.invoke("getBrandWCPayRequest",t,function(t){window.location.href="/home/orders/detail?order_code="+e})}function a(e){var t;void 0===typeof WeixinJSBridge?document.addEventListener?document.addEventListener("WeixinJSBridgeReady",i,!1):document.attachEvent&&(document.attachEvent("WeixinJSBridgeReady",i),document.attachEvent("onWeixinJSBridgeReady",i)):p.ajax({type:"GET",url:"/shopping/pay/wechatwapapi?order_code="+e,dataType:"json",success:function(o){200===o.code?(t=o.data.jsApiParameters,i(e,t)):m.show("微信支付调取失败")},error:function(){m.show("请刷新本页面,完成微信支付")}})}function s(){var e=window.navigator.userAgent.toLowerCase();return e.indexOf("micromessenger")>0?!0:!1}function r(){var e=p(".app");e.each(function(e,t){return"weixin"===p(t).parent().attr("id")?(p(t).parent().css("display","none"),!1):void 0})}function l(){s()||r()}function d(e,t){p(e).css("background-position-y",t)}function c(){var e=p(".box"),t=null,o=null;e.each(function(e,n){t=p(n).find(".icon").find("div"),t.length>0&&(o=p(n).attr("id"),"alipay"!==o&&d(t,b[o]))})}function u(){var e=p(".payapp-list");e.css("visibility","visible")}function h(){l(),f.hideLoadingMask(),u(),c()}var p=e("jquery"),f=e("js/plugin/loading"),m=e("js/plugin/tip"),g=e("hammer"),v=document.getElementById("ordercode").value,w=document.getElementById("weixin"),y=w&&new g(w),b={baidu:"-2.7rem",weixin:"-1.2rem",QQ:"-5.4rem",bank:"-4rem"};window.wx&&wx.hideOptionMenu(),void 0===typeof WeixinJSBridge?(document.addEventListener?document.addEventListener("WeixinJSBridgeReady",n,!1):document.attachEvent&&(document.attachEvent("WeixinJSBridgeReady",n),document.attachEvent("onWeixinJSBridgeReady",n)),n()):n(),y&&y.on("tap",function(){a(v)}),f.showLoadingMask(),p(document).ready(h)}),define("js/me/personal-details",["jquery"],function(e,t,o){var n,i=e("jquery"),a=i(".user-avatar"),s=new Image;n=a.data("avatar"),s.src=n,s.onload=function(){a.css("background-image","url("+n+")")}}),define("js/me/currency",["jquery"],function(e,t,o){function n(e){i.ajax({type:"POST",url:"/home/ajaxCurrencyDetail",dataType:"html",data:{page:e},success:function(e){i(".coin-detail").append(e),window.rePosFooter()}})}var i=e("jquery"),a=1;i(window).scroll(function(){return i(window).scrollTop()+i(window).height()>i("body").height()-1?(a++,void n(a)):void 0}),n(a)});
\ No newline at end of file
... ...
This diff could not be displayed because it is too large.
... ... @@ -88,7 +88,7 @@
}
.cost {
margin-bottom: 100rem / $pxConvertRem; /*排除被固定底部遮挡的影响*/
// margin-bottom: 100rem / $pxConvertRem; /*排除被固定底部遮挡的影响*/
li {
font-size: 28rem / $pxConvertRem;
... ... @@ -104,10 +104,11 @@
}
.opt {
position: fixed;
bottom: 0;
left: 0;
right: 0;
// 测试反馈 底部不需要固定
// position: fixed;
// bottom: 0;
// left: 0;
// right: 0;
text-align: right;
border-top: 1px solid #e0e0e0;
}
... ... @@ -130,4 +131,4 @@
background: #d0021b;
margin-left: 10rem / $pxConvertRem;
}
}
\ No newline at end of file
}
... ...
... ... @@ -29,7 +29,7 @@
<a class="logistics sub" href="{{logisticsUrl}}">
<span class="iconfont">&#xe630;</span>
<p class="beside-icon sub-content">
<span class="sub-title">物流信息</span>
<span class="sub-title">物流信息</span>
<span>物流公司:{{logisticsCompany}}</span>
<span>快递单号:{{logisticsNum}}</span>
</p>
... ... @@ -88,7 +88,7 @@
{{/if}}
{{/if}}
{{#if unreceived}}
{{#if logisticsUrl}}
<a href="{{logisticsUrl}}">
<span class="btn btn-check-logistics">查看物流</span>
</a>
... ... @@ -97,4 +97,4 @@
</div>
{{/ orderDetail}}
</div>
{{> layout/footer}}
\ No newline at end of file
{{> layout/footer}}
... ...
{{> layout/header}}
<div class="gift-advance-page yoho-page">
{{# shoppingCart}}
{{#if gift}}
{{# gift}}
{{> shopping-cart/gift-advance-good}}
{{/ gift}}
{{^}}
{{# advance}}
<div class="advance-block">
<p class="title">{{title}}</p>
{{# goods}}
{{> shopping-cart/gift-advance-good}}
{{/ goods}}
</div>
{{/ advance}}
{{/if}}
{{/ shoppingCart}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
{{> layout/header}}
<div id="mainCart" class="shopping-cart-page yoho-page">
{{# shoppingCart}}
{{#if cartNav}}
<ul class="cart-nav clearfix">
<li class="active">
<span>
普通商品({{commonGoodsCount}})
</span>
</li>
<li>
<span>
预售商品({{presellGoodsCount}})
</span>
</li>
</ul>
{{/if}}
{{#if showLoginInfo}}
<p class="login-info">
<span class="iconfont">&#xe628;</span>
请您先
<a class="btn btn-login">登录</a>
可以同步电脑和手机中的商品
</p>
{{/if}}
{{# commonCart}}
<div class="cart-content common">
{{> shopping-cart/cart-content}}
</div>
{{/ commonCart}}
{{# preSellCart}}
<div class="cart-content presell hide">
<p class="presell-info">
<span class="iconfont">&#xe61a;</span>
<span class="txt">预售商品全场包邮,到货后立即发货</span>
<span class="txt">预售商品不参加活动,不可使用优惠券</span>
</p>
{{> shopping-cart/cart-content}}
</div>
{{/ preSellCart}}
{{/ shoppingCart}}
</div>
<div id="advanceBuy" class="shopping-cart-page yoho-page hide">
{{# shoppingCart}}
{{# commonCart}}
{{# advanceBuy}}
<span>
{{promotionTitle}}
</span>
{{# goods}}
{{> shopping-cart/gift-advance-good}}
{{/ goods}}
{{/ advanceBuy}}
{{/ commonCart}}
{{/ shoppingCart}}
</div>
<div class="shopping-cart-zero yoho-page hide">
<div class="cart-zero">
<i class="iconfont">&#xe62c</i>
<p>您的购物车暂无商品</p>
<a href="">随便逛逛</a>
</div>
{{> product/recommend-for-you}}
</div>
{{> shopping-cart/chose-panel}}
{{> layout/footer}}
\ No newline at end of file
... ...
{{> layout/header}}
<div class="order-ensure-page yoho-page">
{{# orderEnsure}}
<a class="address-wrap block" data-id="{{addressId}}" href="/shoppingCart/selectAddress">
<p class="infos">
收货地址
<span class="per-info">{{name}} {{phoneNum}}</span>
<span class="address">{{area}} {{address}}</span>
</p>
<span class="iconfont">&#xe614;</span>
</a>
<section class="dispatch block">
<div class="sub-block">
<h3 class="title">配送方式</h3>
<ul class="dispatch-mode clearfix">
{{#each dispatchMode}}
<li {{#if isSelected}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li>
{{/each}}
</ul>
</div>
<div class="sub-block">
<h3 class="title">送货时间</h3>
<ul class="dispatch-time clearfix">
{{#each dispatchTime}}
<li {{#if isSelected}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li>
{{/each}}
</ul>
</div>
</section>
<section class="block">
<h3 class="title">商品</h3>
<div class="goods">
{{#each goods}}
{{> me/order/good}}
{{/each}}
</div>
</section>
<section class="block">
<ul class="sale-invoice">
{{# coupon}}
<li class="coupon">
<a href="/shoppingCart/selectCoupon">
<span class="title">优惠券</span>
{{#if count}}
<span class="coupon-count">
{{count}}张可用
</span>
{{/if}}
{{#if value}}
<span class="used coupon-use">
{{value}}
<i class="iconfont">&#xe614;</i>
</span>
{{^}}
<span class="not-used coupon-use">
未使用
<i class="iconfont">&#xe614;</i>
</span>
{{/if}}
</a>
</li>
{{/coupon}}
<li class="coin" data-yoho-coin="{{yohoCoin}}">
<span class="title">YOHO币</span>
<span class="desc">可抵用¥{{yohoCoin}}</span>
<span class="coin-check">
<em>- ¥ {{yohoCoin}}</em>
<i class="iconfont checkbox icon-cb-checked"></i>
</span>
</li>
{{#if invoice}}
<li class="invoice {{#if needInvoice}}focus{{/if}}">
<span class="title">发票</span>
<span class="iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"></span>
<form id="invoice">
<input type="text" name="invoice-title" value="{{invoiceText}}" placeholder="发票抬头">
<label>
发票类型
<select class="invoice-type" name="invoice-type">
{{# invoice}}
<option value="{{id}}" {{#if isSelected}}selected{{/if}}>{{name}}</option>
{{/ invoice}}
</select>
</label>
</form>
</li>
{{/if}}
</ul>
<form id="msg" action="" method="post">
<input type="text" name="msg" value="{{msg}}" placeholder="留言">
</form>
</section>
<section class="price-cal block">
<ul class="total">
<li>
<span>总价</span>
&nbsp;&nbsp;¥{{sumPrice}}
</li>
<li>
<span>活动价</span>
- ¥{{salePrice}}
</li>
<li>
<span>运费</span>
+ {{freight}}
</li>
{{#couponPrice}}
<li>
<span>优惠券</span>
- ¥{{.}}
</li>
{{/couponPrice}}
<li>
<span>YOHO币</span>
- ¥{{yohoCoin}}
</li>
<li class="cost">
应付金额: <em>¥{{price}}</em>
</li>
</ul>
</section>
<ul class="pay-mode">
{{# paymentWay}}
<li class="{{#if default}}default{{/if}}" data-pay-type="{{paymentType}}" data-pay-id="{{id}}">
<span class="iconfont">
{{#if default}}
&#xe62f;
{{else}}
&#xe62e;
{{/if}}
</span>
{{name}}
</li>
{{/ paymentWay}}
</ul>
{{/ orderEnsure}}
</div>
<script id="tmpl-price" type="text/tmpl">
<ul class="total">
<li>
<span>总价</span>
&nbsp;&nbsp;¥\{{sumPrice}}
</li>
<li>
<span>活动价</span>
- ¥\{{salePrice}}
</li>
<li>
<span>运费</span>
+ \{{freight}}
</li>
\{{#couponPrice}}
<li>
<span>优惠券</span>
- ¥\{{.}}
</li>
\{{/couponPrice}}
<li>
<span>YOHO币</span>
- ¥\{{yohoCoin}}
</li>
<li class="cost">
应付金额: <em>¥\{{price}}</em>
</li>
</ul>
</script>
{{> layout/footer}}
... ...
{{> layout/header}}
<div class="my-address-page select-address-page yoho-page">
<div class="page-wrap">
{{# address}}
<a class="address-item" data-address-id="{{address_id}}" href="/shoppingCart/orderEnsure">
<span class="name">{{consignee}}</span>
<span class="tel">{{mobile}}</span>
<p class="address-info">{{area}} {{address}}</p>
<div class="action iconfont">
<span class="edit" data-href="/home/addressAct?id={{address_id}}&refer=shopping">&#xe61e;</span>
<span class="del" data-id="{{address_id}}">&#xe621;</span>
</div>
</a>
{{/ address}}
<a class="add-address" data-href="/home/addressAct?refer=shopping">
添加新地址
</a>
<div class="confim-mask hide">
<div class="confim-box">
<div class="content">
您确定要删除地址?
</div>
<div class="action">
<span class="cancel">
取消
</span>
<span class="confim">
确认
</span>
</div>
</div>
</div>
</div>
</div>
{{> layout/footer}}
... ...
{{> layout/header}}
<div class="yoho-page select-coupon-page my-coupon-page">
<form id="new-coupon" method="POST" action="">
<input type="text" name="couponCode" value="" placeholder="输入优惠券码">
<button type="submit" class="submit">确定</button>
</form>
<div id="coupon-list" class="coupon-list"></div>
<div class="not-avaliable-coupon-line hide">不可使用的优惠券</div>
<div id="coupon-list-not" class="coupon-list"></div>
</div>
<script id="tmpl-coupon" type="text/tmpl">
\{{#coupons}}
\{{^ notAvailable}}
<a class="employ-main" data-coupon-code="\{{ couponCode}}" data-coupon-value="\{{ couponValue}}" href="/shoppingCart/orderEnsure">
<span>\{{ couponValue}}</span>
<p class="coupon-name">\{{ couponDetailInfomation}}</p>
<p>有效期:\{{ couponValidity}}</p>
</a>
\{{/ notAvailable}}
\{{/coupons}}
</script>
<script id="tmpl-coupon-not-avaliable" type="text/tmpl">
\{{# notAvailableCoupons}}
<div class="employ-main not-avaliable">
<span>\{{ couponValue}}</span>
<p class="coupon-name">\{{ couponDetailInfomation}}</p>
<p>有效期:\{{ couponValidity}}</p>
</div>
\{{/ notAvailableCoupons}}
</script>
<script id="tmpl-no-coupon" type="text/tmpl">
<div class="coupon-list">
<div class="null">
<i></i>
<p>您还没有优惠券!</p>
</div>
</div>
</script>
{{> layout/footer}}
... ...
... ... @@ -86,7 +86,6 @@
×{{count}}
</span>
</div>
</div>
<!--<div class="opt-panel hide">
<div class="put-in-favorite">
<span class="iconfont">&#xe622;</span>
... ...
... ... @@ -52,7 +52,7 @@ class CouponController extends HuodongAction
$urlGirls = Helpers::url('/cuxiao/coupon/girlsbrand');
$urlKids = Helpers::url('/cuxiao/coupon/kidsbrand');
$urlLifestyle = Helpers::url('/cuxiao/coupon/lifestylebrand');
$urlShare = Yohobuy::SERVICE_URL . '/operations/api/v5/webshare/getShare';
$urlShare = '\/operations\/api\/v5\/webshare\/getShare';
$urlEncode = strtr($urlBoys, array('/' => '\\/'));
$this->_view->display('boysbrand', array(
... ... @@ -67,10 +67,10 @@ class CouponController extends HuodongAction
'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/11/26/09/0226ad7f8bcf5467a789e17b761c7557e0.jpg',
'shareDesc' => '2015感恩季!品牌专属优惠券限时送!先领券,再购物,让你乐享整个冬季!',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"364","share":"' . $urlShare . '","shareparam":{"share_id":"406"},"islogin":"N","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"366","share":"' . $urlShare . '","shareparam":{"share_id":"408"},"islogin":"N","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"368","share":"' . $urlShare . '","shareparam":{"share_id":"410"},"islogin":"N","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"370","share":"' . $urlShare . '","shareparam":{"share_id":"412"},"islogin":"N","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"364","share":"' . $urlShare . '","shareparam":{"share_id":"406"},"islogin":"Y","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"366","share":"' . $urlShare . '","shareparam":{"share_id":"408"},"islogin":"Y","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"368","share":"' . $urlShare . '","shareparam":{"share_id":"410"},"islogin":"Y","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"370","share":"' . $urlShare . '","shareparam":{"share_id":"412"},"islogin":"Y","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'url_350' => 'http://list.m.yohobuy.com/?gender=1,3&brand=350&openby:yohobuy={"action":"go.list","params":{"gender":"1,3","brand":"350","title":"MACROPUS"}}',
'url_160' => 'http://list.m.yohobuy.com/?gender=1,3&brand=60&openby:yohobuy={"action":"go.list","params":{"gender":"1,3","brand":"60","title":"izzue"}}',
... ...
... ... @@ -846,7 +846,7 @@ class HomeController extends AbstractAction
if (empty($orderDetail)) {
$this->error();
}
$this->setTitle('订单详情');
$this->setNavHeader('订单详情');
... ...
... ... @@ -8,8 +8,22 @@ use Plugin\Helpers;
/**
* 购物车
*/
class ShoppingCartController extends AbstractAction
class ShoppingcartController extends AbstractAction
{
/**
* 通过当前用户审判是否跳到登录
*
* @param boolean $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
* @return void
*/
protected function auditJumpLogin($useSession = true)
{
$uid = $this->getUid($useSession);
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN))));
}
}
/*
* 购物车首页
*/
... ... @@ -58,10 +72,11 @@ class ShoppingCartController extends AbstractAction
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = $this->getSession('shoppingKey');
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
$skuList = $this->post('skuList', null);
$result = CartModel::selectGoods($uid, $skuList, $shoppingKey);
}
if (empty($result)) {
... ... @@ -122,11 +137,9 @@ class ShoppingCartController extends AbstractAction
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$data = array(
'shoppingCartPage' => true,
'shoppingCart' => CartModel::getCartData($uid, $shoppingKey, true)
);
$cartType = $this->get('cartType', 'ordinary');
$data = array('shoppingCartPage' => true);
$data += CartModel::getCartData($uid, $shoppingKey, $cartType, true);
// 渲染模板
$this->_view->display('gift-advance-good', $data);
... ... @@ -142,12 +155,9 @@ class ShoppingCartController extends AbstractAction
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$data = array(
'shoppingCartPage' => true,
'shoppingCart' => CartModel::getCartData($uid, $shoppingKey, false, true)
);
print_r($data);
$cartType = $this->get('cartType', 'ordinary');
$data = array('shoppingCartPage' => true);
$data += CartModel::getCartData($uid, $shoppingKey, $cartType, false, true);
// 渲染模板
$this->_view->display('gift-advance-good', $data);
... ... @@ -196,6 +206,30 @@ class ShoppingCartController extends AbstractAction
}
/**
* 修改购物车商品数量
*/
public function modifyNumAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = $this->getSession('shoppingKey');
$uid = $this->getUid(true);
$sku= $this->post('sku', 0);
$increaseNum = $this->post('increaseNum', null);
$decreaseNum = $this->post('decreaseNum', null);
$result = CartModel::modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 修改购物车商品数据
*/
public function modifyAction()
... ... @@ -226,17 +260,28 @@ class ShoppingCartController extends AbstractAction
*/
public function orderEnsureAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('购物车');
$this->setNavHeader('购物车');
$cartType = $this->post('cartType', 'ordinary');
// 购物车商品为空跳转到购物车页面
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$cartGoods = CartModel::getCartData($uid, $shoppingKey);
if (empty($cartGoods) || isset($cartGoods['isEmptyCart'])) {
$this->go(Helpers::url('/shoppingcart'));
}
$cartType = $this->get('cartType', 'ordinary');
$cookieData = $this->getCookie('order-info', null);
$uid = $this->getUid(true);
$data = array(
'orderEnsurePage' => true,
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
);
// var_dump($data);
$this->_view->display('order-ensure', $data);
}
... ... @@ -293,7 +338,6 @@ class ShoppingCartController extends AbstractAction
if ($this->isAjax()) {
$uid = $this->getUid(true);
$page = $this->get('page', 1);
$result = CartModel::getCouponList($uid);
}
... ... @@ -309,6 +353,9 @@ class ShoppingCartController extends AbstractAction
*/
public function selectAddressAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('选择地址');
$this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure'));
... ... @@ -328,9 +375,13 @@ class ShoppingCartController extends AbstractAction
*/
public function selectCouponAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('选择优惠券');
$this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure'));
$this->_view->display('select-coupon', array(
'selectCouponPage' => true,
'pageFooter' => true
... ...
... ... @@ -17,632 +17,705 @@ use Plugin\Images;
class CartModel
{
/**
* 加入购物车
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @return array 加入购物车接口返回的数据
*/
public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid)
{
$result = array('code' => 400, 'message' => '出错啦~~');
$addCart = CartData::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid);
if ($addCart && isset($addCart['code'])) {
$result = $addCart;
}
return $result;
}
/**
* @param integer $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @return array|mixed 处理之后的购物车数据
*/
public static function getCartData($uid, $shoppingKey, $onlyGift = false, $onlyAdvanceBuy = false)
{
$result = array('cartNav' => true);
// 用户是否登录
if (empty($uid)) {
$result['showLoginInfo'] = true;
}
// 调用接口获取购物车的数据
$cartData = CartData::cartData($uid, $shoppingKey);
// 处理普通购物车和预售购物车的数据
if (isset($cartData['data']) && !empty($cartData['data'])) {
$cart = $cartData['data'];
/* 普通购物车 */
if(isset($cart['ordinary_cart_data'])) {
$result['commonGoodsCount'] = $cart['ordinary_cart_data']['shopping_cart_data']['goods_count'];
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
}
/* 预售购物车 */
if(isset($cart['advance_cart_data'])) {
$result['presellGoodsCount'] = $cart['advance_cart_data']['shopping_cart_data']['goods_count'];
$result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy);
}
}
return $result;
}
/**
* 购物车商品选择与取消接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 处理之后的数据的数据
*/
public static function selectGoods($uid, $sku, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$select = CartData::selectGoods($uid, $sku_list, $shoppingKey);
if ($select && isset($select['code'])) {
$result['code'] = $select['code'];
$result['message'] = $select['message'];
}
return $result;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
$result['message'] = $remove['message'];
}
return $result;
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
if (empty($uid)) {
$result['code'] = 300;
$reult['message'] = '请先登录';
$result['data'] = '/signin.html';
return $result;
}
// 处理sku
$sku_list = json_encode(array($sku => 1));
$add = CartData::addToFav($uid, $sku_list);
if ($add && isset($add['code'])) {
$result['code'] = $add['code'];
$result['message'] = $add['message'];
}
return $result;
}
/**
* 处理购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @param int $num 购买数目
* @return array 接口返回的数据
*/
public static function cartProductData($uid, $skn, $num)
{
$result = array('code' => 400, 'message' => '出错啦~');
$product = CartData::cartProductData($uid, $skn);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
$data['num'] = $num;
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
}
return $result;
}
/**
* 处理加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array
*/
public static function giftProductData($skn, $promotionId)
{
$result = array();
$product = CartData::giftProductData($skn, $promotionId);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
}
return $result;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $param 要更改的数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $param, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理要更改的数据
$swapData = json_encode(array($param));
$modify = CartData::modifyCartProduct($uid, $swapData, $shoppingKey);
if ($modify && isset($modify['code'])) {
$result['code'] = $modify['code'];
$result['message'] = $modify['message'];
}
return $result;
}
/**
* 调用购物车结算接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param null|string $cookieData cookie中记录的一些订单有关数据
* @return array 接口返回的数据
*/
public static function cartPay($uid, $cartType, $cookieData)
{
$result = array();
$pay = CartData::cartPay($uid, $cartType);
if ($pay && isset($pay['code']) && $pay['code'] === 200) {
$payReturn = $pay['data'];
$orderInfo = array();
$address = array();
$orderCompute = array();
// cookie保存的数据
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']);
}
// 根据地址id查询地址信息
if (isset($orderInfo['addressId'])) {
$address = UserModel::getAddressDataById($uid, $orderInfo['addressId']);
}
// 收货人有关信息
if (isset($payReturn['delivery_address']) && !empty($payReturn['delivery_address'])) {
$result['addressId'] = isset($address['address_id']) ? $address['address_id'] : $payReturn['delivery_address']['address_id'];
$result['name'] = isset($address['consignee']) ? $address['consignee'] : $payReturn['delivery_address']['consignee'];
$result['phoneNum'] = isset($address['mobile']) ? $address['mobile'] : $payReturn['delivery_address']['mobile'];
/**
* 加入购物车
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @return array 加入购物车接口返回的数据
*/
public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid)
{
$result = array('code' => 400, 'message' => '出错啦~~');
$addCart = CartData::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid);
if ($addCart && isset($addCart['code'])) {
$result = $addCart;
}
return $result;
}
/**
* @param integer $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @param string $cartType 购物车类型
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @return array|mixed 处理之后的购物车数据
*/
public static function getCartData($uid, $shoppingKey, $cartType = 'all', $onlyGift = false, $onlyAdvanceBuy = false)
{
$result = array('cartNav' => true);
// 用户是否登录
if (empty($uid)) {
$result['showLoginInfo'] = true;
}
// 调用接口获取购物车的数据
$cartData = CartData::cartData($uid, $shoppingKey);
// 处理普通购物车和预售购物车的数据
do {
if (!isset($cartData['data']) || empty($cartData['data'])) {
break;
}
$cart = $cartData['data'];
if ($cartType !== 'all') { // 加价购或者赠品数据
$result = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
break;
}
$ordinaryCount = intval($cart['ordinary_cart_data']['shopping_cart_data']['goods_count']);
$advanceCount = intval($cart['advance_cart_data']['shopping_cart_data']['goods_count']);
// 普通购物车和预售购物车都为空
if ($ordinaryCount === 0 && $advanceCount === 0) {
$result['isEmptyCart'] = true;
break;
}
/* 普通购物车 */
$result['commonGoodsCount'] = $ordinaryCount;
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
/* 预售购物车 */
$result['presellGoodsCount'] = $advanceCount;
$result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy);
}while(0);
return $result;
}
/**
* 购物车商品选择与取消接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $skuList 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 处理之后的数据的数据
*/
public static function selectGoods($uid, $skuList, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
if (empty($skuList)) {
break;
}
$select = CartData::selectGoods($uid, $skuList, $shoppingKey);
if ($select && isset($select['code'])) {
$result['code'] = $select['code'];
$result['message'] = $select['message'];
}
}while(0);
return $result;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
$result['message'] = $remove['message'];
}
return $result;
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
if (empty($uid)) {
$result['code'] = 300;
$reult['message'] = '请先登录';
$result['data'] = '/signin.html';
return $result;
}
// 处理sku
$sku_list = json_encode(array($sku => 1));
$add = CartData::addToFav($uid, $sku_list);
if ($add && isset($add['code'])) {
$result['code'] = $add['code'];
$result['message'] = $add['message'];
}
return $result;
}
/**
* 处理购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @param int $num 购买数目
* @return array 接口返回的数据
*/
public static function cartProductData($uid, $skn, $num)
{
$result = array('code' => 400, 'message' => '出错啦~');
$product = CartData::cartProductData($uid, $skn);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
$data['num'] = $num;
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
}
return $result;
}
/**
* 处理加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array
*/
public static function giftProductData($skn, $promotionId)
{
$result = array();
$product = CartData::giftProductData($skn, $promotionId);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
}
return $result;
}
/**
* 修改购物车商品数量
*
* @param int $uid 用户ID
* @param string $sku 商品SKU
* @param int $increaseNum 增加的数目
* @param int $decreaseNum 减少的数目
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
if (empty($sku)) {
braek;
}
$modify = CartData::modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey);
if ($modify && isset($modify['code'])) {
$result['code'] = $modify['code'];
$result['message'] = $modify['message'];
}
}while(0);
return $result;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $param 要更改的数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $param, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
if (empty($param['old_product_sku']) || empty($param['new_product_sku'])) {
break;
}
// 处理要更改的数据
$swapData = json_encode(array($param));
$modify = CartData::modifyCartProduct($uid, $swapData, $shoppingKey);
if ($modify && isset($modify['code'])) {
$result['code'] = $modify['code'];
$result['message'] = $modify['message'];
}
}while(0);
return $result;
}
/**
* 调用购物车结算接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param null|string $cookieData cookie中记录的一些订单有关数据
* @return array 接口返回的数据
*/
public static function cartPay($uid, $cartType, $cookieData)
{
$result = array();
$pay = CartData::cartPay($uid, $cartType);
if ($pay && isset($pay['code']) && $pay['code'] === 200) {
$payReturn = $pay['data'];
$orderInfo = array();
$address = array();
$orderCompute = array();
// cookie保存的数据
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']);
}
// 根据地址id查询地址信息
if (isset($orderInfo['addressId'])) {
$address = UserModel::getAddressDataById($uid, $orderInfo['addressId']);
}
// 收货人有关信息
if (isset($payReturn['delivery_address']) && !empty($payReturn['delivery_address'])) {
$result['addressId'] = isset($address['address_id']) ? $address['address_id'] : $payReturn['delivery_address']['address_id'];
$result['name'] = isset($address['consignee']) ? $address['consignee'] : $payReturn['delivery_address']['consignee'];
$result['phoneNum'] = isset($address['mobile']) ? $address['mobile'] : $payReturn['delivery_address']['mobile'];
$result['area'] = isset($address['area']) ? $address['area'] : $payReturn['delivery_address']['area'];
$result['address'] = isset($address['address']) ? $address['address'] : $payReturn['delivery_address']['address'];
$result['isSupport'] = ($payReturn['delivery_address']['is_support'] === 'Y');
}
// 配送方式
if (isset($payReturn['delivery_way'])) {
$idArr = array();
$defaultKey = 0;
$oneDeliv = array();
foreach ($payReturn['delivery_way'] as $key => $val) {
$oneDeliv = array();
$oneDeliv['id'] = $val['delivery_way_id'];
$oneDeliv['name'] = $val['delivery_way_name'];
($val['default'] === 'Y') && $defaultKey = $key;
$idArr[$key] = $oneDeliv['id'];
$result['dispatchMode'][$key] = $oneDeliv;
}
if (isset($orderInfo['deliveryId'])) {
$flag = array_search($orderInfo['deliveryId'], $idArr);
$flag !== false && $result['dispatchMode'][$flag]['isSelected'] = true;
} else {
$result['dispatchMode'][$defaultKey]['isSelected'] = true;
}
}
// 配送时间
if (isset($payReturn['delivery_time'])) {
$idArr = array();
$defaultKey = 0;
$oneDelivTime = array();
foreach ($payReturn['delivery_time'] as $key => $one) {
$oneDelivTime = array();
$oneDelivTime['id'] = $one['delivery_time_id'];
$oneDelivTime['name'] = $one['delivery_time_string'];
($one['default'] === 'Y') && $defaultKey = $key;
$idArr[$key] = $oneDelivTime['id'];
$result['dispatchTime'][] = $oneDelivTime;
}
if (isset($orderInfo['deliveryTimeId'])) {
$flag = array_search($orderInfo['deliveryTimeId'], $idArr);
$flag !== false && $result['dispatchTime'][$flag]['isSelected'] = true;
} else {
$result['dispatchTime'][$defaultKey]['isSelected'] = true;
}
}
// 订单商品
if (isset($payReturn['goods_list'])) {
$oneGoods = array();
foreach ($payReturn['goods_list'] as $single) {
$oneGoods = array();
$oneGoods['id'] = $single['product_sku']; // TODO 未确定用哪个
$oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 120);
$oneGoods['name'] = $single['product_name'];
$oneGoods['color'] = $single['color_name'];
$oneGoods['size'] = $single['size_name'];
$oneGoods['price'] = Helpers::transPrice($single['sales_price']);
$oneGoods['count'] = $single['buy_number'];
$result['goods'][] = $oneGoods;
}
}
// 支付方式
if (isset($payReturn['payment_way'])) {
$onePay = array();
foreach ($payReturn['payment_way'] as $pay) {
$onePay = array();
$onePay['id'] = $pay['payment_id'];
$onePay['paymentType'] = $pay['payment_type'];
$onePay['name'] = $pay['payment_type_name'];
$onePay['default'] = ($pay['default'] === 'Y');
$result['paymentWay'][] = $onePay;
}
}
// 有货币
$result['yohoCoin'] = (isset($orderCompute['use_yoho_coin']) && !empty($orderCompute['use_yoho_coin'])) ? $orderCompute['use_yoho_coin'] : $payReturn['yoho_coin'];
// 订单数据
if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
$sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount'];
$freight = isset($orderCompute['promotion_formula_list']['promotion_amount']) ? $orderCompute['promotion_formula_list'][1]['promotion_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list'][1]['promotion_amount'];
$couponPrice = isset($orderCompute['coupon_amount']) ? $orderCompute['coupon_amount'] : false;
$salePrice = isset($orderCompute['discount_amount']) ? $orderCompute['discount_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list'][3]['promotion_amount'];
$price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount'];
$result['sumPrice'] = Helpers::transPrice($sumPrice);
$result['salePrice'] = Helpers::transPrice($salePrice);
$result['price'] = Helpers::transPrice($price);
$result['freight'] = $freight;
$result['couponPrice'] = $couponPrice;
}
// 发票有关数据
if (isset($payReturn['invoices']) && !empty($payReturn['invoices'])) {
$one = array();
foreach ($payReturn['invoices']['invoices_type_list'] as $inv) {
$one = array();
$one['id'] = $inv['invoices_type_id'];
$one['name'] = $inv['invoices_type_name'];
$result['isSupport'] = ($payReturn['delivery_address']['is_support'] === 'Y');
}
// 配送方式
if (isset($payReturn['delivery_way'])) {
$idArr = array();
$defaultKey = 0;
$oneDeliv = array();
foreach ($payReturn['delivery_way'] as $key => $val) {
$oneDeliv = array();
$oneDeliv['id'] = $val['delivery_way_id'];
$oneDeliv['name'] = $val['delivery_way_name'];
($val['default'] === 'Y') && $defaultKey = $key;
$idArr[$key] = $oneDeliv['id'];
$result['dispatchMode'][$key] = $oneDeliv;
}
if (isset($orderInfo['deliveryId'])) {
$flag = array_search($orderInfo['deliveryId'], $idArr);
$flag !== false && $result['dispatchMode'][$flag]['isSelected'] = true;
} else {
$result['dispatchMode'][$defaultKey]['isSelected'] = true;
}
}
// 配送时间
if (isset($payReturn['delivery_time'])) {
$idArr = array();
$defaultKey = 0;
$oneDelivTime = array();
foreach ($payReturn['delivery_time'] as $key => $one) {
$oneDelivTime = array();
$oneDelivTime['id'] = $one['delivery_time_id'];
$oneDelivTime['name'] = $one['delivery_time_string'];
($one['default'] === 'Y') && $defaultKey = $key;
$idArr[$key] = $oneDelivTime['id'];
$result['dispatchTime'][] = $oneDelivTime;
}
if (isset($orderInfo['deliveryTimeId'])) {
$flag = array_search($orderInfo['deliveryTimeId'], $idArr);
$flag !== false && $result['dispatchTime'][$flag]['isSelected'] = true;
} else {
$result['dispatchTime'][$defaultKey]['isSelected'] = true;
}
}
// 订单商品
if (isset($payReturn['goods_list'])) {
$oneGoods = array();
foreach ($payReturn['goods_list'] as $single) {
$oneGoods = array();
$oneGoods['id'] = $single['product_sku']; // TODO 未确定用哪个
$oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 120);
$oneGoods['name'] = $single['product_name'];
$oneGoods['color'] = $single['color_name'];
$oneGoods['size'] = $single['size_name'];
$oneGoods['price'] = Helpers::transPrice($single['sales_price']);
$oneGoods['count'] = $single['buy_number'];
$result['goods'][] = $oneGoods;
}
}
// 支付方式
if (isset($payReturn['payment_way'])) {
$onePay = array();
foreach ($payReturn['payment_way'] as $pay) {
$onePay = array();
$onePay['id'] = $pay['payment_id'];
$onePay['paymentType'] = $pay['payment_type'];
$onePay['name'] = $pay['payment_type_name'];
$onePay['default'] = ($pay['default'] === 'Y');
$result['paymentWay'][] = $onePay;
}
}
// 有货币
$result['yohoCoin'] = (isset($orderCompute['use_yoho_coin']) && !empty($orderCompute['use_yoho_coin'])) ? $orderCompute['use_yoho_coin'] : $payReturn['yoho_coin'];
// 订单数据
if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
$sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount'];
$freight = '¥0';
if (isset($orderCompute['promotion_formula_list'][1]['promotion_amount'])) {
$freight = $orderCompute['promotion_formula_list'][1]['promotion_amount'];
} elseif(isset($payReturn['shopping_cart_data']['promotion_formula_list'][1]['promotion_amount'])) {
$freight = $payReturn['shopping_cart_data']['promotion_formula_list'][1]['promotion_amount'];
}
$couponPrice = isset($orderCompute['coupon_amount']) ? $orderCompute['coupon_amount'] : false;
$salePrice = isset($orderCompute['discount_amount']) ? $orderCompute['discount_amount'] : $payReturn['shopping_cart_data']['discount_amount'];
$price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount'];
$result['sumPrice'] = Helpers::transPrice($sumPrice);
$result['salePrice'] = Helpers::transPrice($salePrice);
$result['price'] = Helpers::transPrice($price);
$result['freight'] = $freight;
$result['couponPrice'] = $couponPrice;
}
// 发票有关数据
if (isset($payReturn['invoices']) && !empty($payReturn['invoices'])) {
$one = array();
foreach ($payReturn['invoices']['invoices_type_list'] as $inv) {
$one = array();
$one['id'] = $inv['invoices_type_id'];
$one['name'] = $inv['invoices_type_name'];
isset($orderInfo['invoiceType']) && $one['id'] == $orderInfo['invoiceType'] && $one['isSelected'] = true;
$result['invoice'][] = $one;
}
$result['invoice'][] = $one;
}
// 发票信息需要记录
if (isset($orderInfo['invoice'])) {
$result['needInvoice'] = $orderInfo['invoice'];
$result['invoiceText'] = $orderInfo['invoiceText'];
}
if (isset($orderInfo['invoice'])) {
$result['needInvoice'] = $orderInfo['invoice'];
$result['invoiceText'] = $orderInfo['invoiceText'];
}
}
}
// 留言
isset($orderInfo['msg']) && $result['msg'] = $orderInfo['msg'];
// 优惠券数据
$coupons = array();
!empty($orderCompute['coupon_amount']) && $coupons['value'] = $orderInfo['couponValue'];
$coupons += self::getCouponList($uid, true);
$result['coupon'] = $coupons;
}
return $result;
}
/**
* 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量
* @return array 接口返回的数据
*/
public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin)
{
$result = array();
$compute = CartData::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
if ($compute && isset($compute['code']) && $compute['code'] === 200) {
$result = $compute['data'];
}
return $result;
}
/**
* 购物车结算--输入优惠券代码返回的结果处理
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public static function searchCoupon($uid, $couponCode)
{
$result = array('code' => 400, 'message' => '出错啦~');
$coupon = CartData::searchCoupon($uid, $couponCode);
if ($coupon && isset($coupon['code'])) {
$result = $coupon;
}
return $result;
}
/**
* 处理优惠券列表数据
*
* @param int $uid 用户ID
* @param boolean $onlyTotal 只返回总数
* @return array|mixed 处理之后的优惠券数据
*/
public static function getCouponList($uid, $onlyTotal = false)
{
$result = array();
// 调用接口获取优惠券数据
$coupons = CartData::getCouponList($uid);
// 处理优惠券数据
if (isset($coupons['data'])) {
if ($onlyTotal) {
$result['count'] = count($coupons['data']['couponList']);
} else {
$couponArr = array();
isset($coupons['data']['couponList']) && $couponArr = $coupons['data']['couponList'];
foreach ($couponArr as &$val) {
$notAvailableRes = self::searchCoupon($uid, $val['couponCode']);
// 处理可用的优惠券
if (isset($notAvailableRes['code']) && $notAvailableRes['code'] !== 200) {
$val['notAvailable'] = true;
}
}
!empty($couponArr) && $result = $couponArr;
}
}
return $result;
}
/**
* 购物车结算--提交结算信息
*
* @param int $uid 用户ID
* @param int $addressId 地址ID
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin)
{
$result = array('code' => 400, 'message' => '出错啦');
if (empty($addressId)) {
$result['code'] = 401;
$result['message'] = '配送地址不能为空';
} elseif (empty($deliveryTime)) {
$result['code'] = 402;
$result['message'] = '请选择配送时间';
} elseif (empty($deliveryWay)) {
$result['code'] = 403;
$result['message'] = '请选择配送方式';
} else {
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin);
// 优惠券数据
$coupons = array();
!empty($orderCompute['coupon_amount']) && $coupons['value'] = $orderInfo['couponValue'];
$coupons += self::getCouponList($uid, true);
$result['coupon'] = $coupons;
}
return $result;
}
/**
* 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量
* @return array 接口返回的数据
*/
public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin)
{
$result = array();
$compute = CartData::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
if ($compute && isset($compute['code']) && $compute['code'] === 200) {
$result = $compute['data'];
}
return $result;
}
/**
* 购物车结算--输入优惠券代码返回的结果处理
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public static function searchCoupon($uid, $couponCode)
{
$result = array('code' => 400, 'message' => '出错啦~');
$coupon = CartData::searchCoupon($uid, $couponCode);
if ($coupon && isset($coupon['code'])) {
$result = $coupon;
}
return $result;
}
/**
* 处理优惠券列表数据
*
* @param int $uid 用户ID
* @param boolean $onlyTotal 只返回总数
* @return array|mixed 处理之后的优惠券数据
*/
public static function getCouponList($uid, $onlyTotal = false)
{
$result = array();
// 调用接口获取优惠券数据
$coupons = CartData::getCouponList($uid);
// 处理优惠券数据
if (isset($coupons['data'])) {
if ($onlyTotal) {
$result['count'] = count($coupons['data']['couponList']);
} else {
$couponArr = array();
isset($coupons['data']['couponList']) && $couponArr = $coupons['data']['couponList'];
foreach ($couponArr as &$val) {
$notAvailableRes = self::searchCoupon($uid, $val['couponCode']);
// 处理可用的优惠券
if (isset($notAvailableRes['code']) && $notAvailableRes['code'] !== 200) {
$val['notAvailable'] = true;
}
}
!empty($couponArr) && $result = $couponArr;
}
}
return $result;
}
/**
* 购物车结算--提交结算信息
*
* @param int $uid 用户ID
* @param int $addressId 地址ID
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin)
{
$result = array('code' => 400, 'message' => '出错啦');
if (empty($addressId)) {
$result['code'] = 401;
$result['message'] = '配送地址不能为空';
} elseif (empty($deliveryTime)) {
$result['code'] = 402;
$result['message'] = '请选择配送时间';
} elseif (empty($deliveryWay)) {
$result['code'] = 403;
$result['message'] = '请选择配送方式';
} else {
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin);
if ($orderSubRes && isset($orderSubRes['code'])) {
$result = $orderSubRes;
}
}
return $result;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false)
{
$result = array();
if (!$onlyAdvanceBuy) {
// 赠品
$result['giftCount'] = 0;
$result['freebie'] = Helpers::formatAdvanceGoods($data['gift_list'], $result['giftCount']);
}
if (!$onlyGift) {
// 加价购
$result['advanceBuyCount'] = 0;
$result['advanceBuy'] = Helpers::formatAdvanceGoods($data['price_gift'], $result['advanceBuyCount']);
}
if (!$onlyGift && !$onlyAdvanceBuy) {
// 购买的可用商品列表
$validGoods = Helpers::formatCartGoods($data['goods_list']);
!empty($validGoods) && $result['goods'] = $validGoods;
// 失效商品列表
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list']);
!empty($notValidGoods) && $result['$notValidGoods'] = $notValidGoods;
// 赠品和加价购商品
(count($data['gift_list']) || count($data['price_gift'])) && $result['freebieOrAdvanceBuy'] = true;
// 结算数据
$result['price'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
$result['activityPrice'] = Helpers::transPrice($data['shopping_cart_data']['discount_amount']);
$result['count'] = $data['shopping_cart_data']['goods_count'];
$result['sumPrice'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
}
return $result;
}
$result = $orderSubRes;
}
}
return $result;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false)
{
$result = array();
do {
// 数据为空时返回空的标志
if (empty($data)) {
break;
}
if ($onlyAdvanceBuy) {
// 赠品
$result['freebie'] = Helpers::formatAdvanceGoods($data['gift_list']);
break;
}
if ($onlyGift) {
// 加价购
$result['advanceBuy'] = Helpers::formatAdvanceGoods($data['price_gift']);
break;
}
// 购买的可用商品列表
$validGoods = Helpers::formatCartGoods($data['goods_list']);
if (!empty($validGoods)) {
$result['goods'] = $validGoods;
}
// 失效商品列表
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list']);
if (!empty($notValidGoods)) {
$result['$notValidGoods'] = $notValidGoods;
}
// 赠品和加价购商品
if (count($data['gift_list']) || count($data['price_gift'])) {
$result['freebieOrAdvanceBuy'] = true;
// 赠品
$result['giftCount'] = 0;
$result['freebie'] = Helpers::formatAdvanceGoods($data['gift_list'], $result['giftCount']);
// 加价购
$result['advanceBuyCount'] = 0;
$result['advanceBuy'] = Helpers::formatAdvanceGoods($data['price_gift'], $result['advanceBuyCount']);
}
// 结算数据
$result['price'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
$result['activityPrice'] = Helpers::transPrice($data['shopping_cart_data']['discount_amount']);
$result['count'] = $data['shopping_cart_data']['goods_count'];
$result['sumPrice'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
}while(0);
return $result;
}
}
... ...
... ... @@ -297,7 +297,7 @@ class UserModel
$records = UserData::browseRecord($uid, $udid, $page, $limit);
if (!$records) {
$result['walkwayUrl'] = '/product/new';
$result['walkwayUrl'] = Helpers::url('/product/new');
$result['noRecord'] = true;
return $result;
... ... @@ -308,7 +308,7 @@ class UserModel
// 不能再查到结果了
if ($page == 1 && $records['data']['total'] === 0) {
$result['walkwayUrl'] = '/product/new';
$result['walkwayUrl'] = Helpers::url('/product/new');
$result['noRecord'] = true;
} else {
$data = $records['data']['product_list'];
... ... @@ -781,15 +781,12 @@ class UserModel
$result = array();
$helpListData = UserData::helpListData();
if (isset($helpListData['data']) && !empty($helpListData['data'])) {
$help = $helpListData['data'];
$one = array();
foreach ($help as $val) {
foreach ($helpListData['data'] as $val) {
$one = array();
$one['name'] = $val['caption'];
$one['url'] = Helpers::url('/home/helpdetail/', array('code' => $val['code']));
$one['url'] = Helpers::url('/home/helpdetail', array('code' => $val['code']));
$result['iHelp'][] = $one;
}
... ... @@ -806,7 +803,13 @@ class UserModel
*/
public static function getHelpDetailData($code)
{
return UserData::helpDetailData($code);
$result = array();
if (isset($code)) {
$result = UserData::helpDetailData($code);
}
return $result;
}
}
... ...
... ... @@ -33,10 +33,11 @@ class DetailModel
// 调用服务
$baseInfo = DetailData::baseInfo($productId, $uid);
// 判断商品是否在架
if (empty($baseInfo['status'])) {
return $result;
}
// // 因PC目前是不判断的,先保持一致,以后有需要,可以去掉
// // 判断商品是否在架
// if (empty($baseInfo['status'])) {
// return $result;
// }
// 商品名称
if (isset($baseInfo['productName'])) {
... ... @@ -346,7 +347,7 @@ class DetailModel
$referenceList = array();
// 判断是否显示参考尺码
$showReference = !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['referenceSize']);
$showReference = $boyReference || $girlReference;
if ($showReference) {
$referenceList[0] = array('param' => $referenceName);
}
... ... @@ -361,11 +362,11 @@ class DetailModel
foreach ($sizeInfo['sizeInfoBo']['sizeBoList'] as $value) {
$item = array();
$sizeNameList[] = array('param' => $value['sizeName']);
if (!empty($value['referenceSize']['gender']) && $boyReference && ($value['referenceSize']['gender'] == 1 || $value['referenceSize']['gender'] == 3)) {
$referenceList[] = array('param' => empty($value['referenceSize']['referenceName']) ? ' ' : $value['referenceSize']['referenceName']);
if ($boyReference && ($gender == 1 || $gender == 3) ) {
$referenceList[] = array('param' => empty($value['boyReferSize']['referenceName']) ? ' ' : $value['boyReferSize']['referenceName']);
}
elseif (!empty($value['referenceSize']['gender']) && $girlReference && ($value['referenceSize']['gender'] == 2 || $value['referenceSize']['gender'] == 3)) {
$referenceList[] = array('param' => empty($value['referenceSize']['referenceName']) ? ' ' : $value['referenceSize']['referenceName']);
elseif ($girlReference && ($gender == 2 || $gender == 3) ) {
$referenceList[] = array('param' => empty($value['girlReferSize']['referenceName']) ? ' ' : $value['girlReferSize']['referenceName']);
}
foreach ($value['sortAttributes'] as $attr) {
$sizeBoGroup[$attr['id']][] = array('param' => empty($attr['sizeValue']) ? ' ' : $attr['sizeValue']);
... ...
<?php
use Action\AbstractAction;
use Index\CartModel;
use Index\UserModel;
use Plugin\Helpers;
/**
* 购物车相关的控制器
... ... @@ -8,14 +11,418 @@ use Action\AbstractAction;
* @name IndexController
* @package Cart
* @copyright yoho.inc
* @version 1.0 (2015-10-28 16:34:17)
* @author fei.hong <fei.hong@yoho.cn>
* @version 1.0 (2015-12-16 11:47:20)
* @author gtskk <iamgtskk@gmail.com>
*/
class IndexController extends AbstractAction
{
/**
* 通过当前用户审判是否跳到登录
*
* @param boolean $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
* @return void
*/
protected function auditJumpLogin($useSession = true)
{
$uid = $this->getUid($useSession);
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN))));
}
}
/*
* 购物车首页
*/
public function indexAction()
{
// 跳转到老版
// $this->go(OLD_MAIN . '/cart/index/index');
$this->setTitle('购物车');
$this->setNavHeader('购物车');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$data = array(
'shoppingCartPage' => true,
'shoppingCart' => CartModel::getCartData($uid, $shoppingKey)
);
// 渲染模板
$this->_view->display('index', $data);
}
/*
* 异步获取购物车数据
*/
public function getCartDataAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$result = CartModel::getCartData($uid, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车商品选择与取消
*/
public function selectAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = $this->getSession('shoppingKey');
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 移出购物车
*/
public function delAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = $this->getSession('shoppingKey');
$result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 移入收藏夹
*/
public function colAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$result = CartModel::addToFav($uid, $productId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/*
* 赠品页面
*/
public function giftAction()
{
$this->setTitle('赠品');
$this->setNavHeader('赠品');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$cartType = $this->get('cartType', 'ordinary');
$data = array('shoppingCartPage' => true);
$data += CartModel::getCartData($uid, $shoppingKey, $cartType, true);
// 渲染模板
$this->_view->display('gift-advance-good', $data);
}
/*
* 加价购页面
*/
public function advanceBuyAction()
{
$this->setTitle('加价购');
$this->setNavHeader('加价购');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$cartType = $this->get('cartType', 'ordinary');
$data = array('shoppingCartPage' => true);
$data += CartModel::getCartData($uid, $shoppingKey, $cartType, false, true);
// 渲染模板
$this->_view->display('gift-advance-good', $data);
}
/*
* 获取购物车商品数据
*/
public function goodinfoAction()
{
$result = array();
if ($this->isAjax()) {
$num = $this->get('buy_num', 1);
$skn = $this->get('id', 1);
$uid = $this->getUid(true);
$result = CartModel::cartProductData($uid, $skn, $num); // 测试skn的ID为51172055
$result['num'] = $num;
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/*
* 获取购物车加价购商品数据
*/
public function giftinfoAction()
{
$result = array();
if ($this->isAjax()) {
$skn = $this->get('skn', null);
$promotionId = $this->get('promotionId', null);
$result = CartModel::giftProductData($skn, $promotionId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 修改购物车商品数量
*/
public function modifyNumAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = $this->getSession('shoppingKey');
$uid = $this->getUid(true);
$sku= $this->post('sku', 0);
$increaseNum = $this->post('increaseNum', null);
$decreaseNum = $this->post('decreaseNum', null);
$result = CartModel::modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 修改购物车商品数据
*/
public function modifyAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = $this->getSession('shoppingKey');
$uid = $this->getUid(true);
$params = array();
$params['old_product_sku']= $this->post('old_product_sku', 0);
$params['new_product_sku']= $this->post('new_product_sku', 0);
$params['buy_number']= $this->post('buy_number', 0);
$params['selected']= $this->post('selected', null);
$result = CartModel::modifyCartProduct($uid, $params, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车结算请求
*/
public function orderEnsureAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('购物车');
$this->setNavHeader('购物车');
// 购物车商品为空跳转到购物车页面
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$cartGoods = CartModel::getCartData($uid, $shoppingKey);
if (empty($cartGoods) || isset($cartGoods['isEmptyCart'])) {
$this->go(Helpers::url('/shoppingcart'));
}
$cartType = $this->get('cartType', 'ordinary');
$cookieData = $this->getCookie('order-info', null);
$uid = $this->getUid(true);
$data = array(
'orderEnsurePage' => true,
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
);
$this->_view->display('order-ensure', $data);
}
/**
* 购物车选择改变字段,重新运算订单数据
*/
public function orderComputeAction()
{
$result = array();
if ($this->isAjax()) {
$cartType = $this->post('cartType', 'ordinary');
$deliveryWay = $this->post('deliveryId', 1);
$paymentType = $this->post('paymentTypeId', 1);
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', null);
$uid = $this->getUid(true);
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车输入优惠券码使用优惠券
*/
public function couponSearchAction()
{
$result = array();
if ($this->isAjax()) {
$couponCode = $this->get('couponCode', '');
$uid = $this->getUid(true);
$result = CartModel::searchCoupon($uid, $couponCode);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车结算--获取优惠券列表
*/
public function couponListAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$result = CartModel::getCouponList($uid);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 下单流程 选择地址
*/
public function selectAddressAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('选择地址');
$this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure'));
$uid = $this->getUid(true);
$address = UserModel::getAddressData($uid);
$this->_view->display('select-address', array(
'selectAddressPage' => true,
'pageFooter' => true,
'address' => $address
));
}
/**
* 下单流程 选择优惠券
*/
public function selectCouponAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('选择优惠券');
$this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure'));
$this->_view->display('select-coupon', array(
'selectCouponPage' => true,
'pageFooter' => true
));
}
/**
* 确认结算订单
*/
public function orderSubAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$addressId = $this->post('addressId', null);
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
$deliveryTime = $this->post('deliveryTimeId', 1); // 默认只工作日配送
$deliveryWay = $this->post('deliveryId', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceText', null);
$invoiceId = $this->post('invoiceType', null);
$paymentId = $this->post('paymentTypeId', 15);
$paymentType = $this->post('paymentType', 1); // 默认在线支付
$remark = $this->post('msg', null);
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', 1);
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin);
}
if (empty($result)) {
echo ' ';
} else {
// 提交成功清除Cookie
$this->setCookie('order-info', null);
$this->echoJson($result);
}
}
}
... ...