KISSY.add("mui/mallbar-baby",function(a,t,l,i,e,b,n,r,o){var s=function(a){s.superclass.constructor.call(this,a);this.init()},d="//"+(location.hostname.indexOf(".daily.")>-1?"plaza.baby.daily.tmall.net":"plaza.baby.tmall.com"),m="//"+(location.hostname.indexOf(".daily.")>-1?"bar.daily.tmall.net":"bar.tmall.com"),c=l.one;a.extend(s,t,{init:function(){var a=this.get("mallbar"),t=this,i=l.one,e={brandId:a.get("brandId"),sellerId:a.get("sellerId"),itemId:a.get("itemId"),frontEndCatId:a.get("category"),bizId:a.get("bizId")},b=this.get("Util"),n=b.getSysId(),r=this.get("Store"),o=this.get("rightDetailContCls");window._tb_token_=a.get("token");window.login=a.get("model").get("userinfo").isLogin;if(window.login){r.get({k:"fatigue"+a.get("items")["prof"].getUid(),success:function(l){var i=(new Date).getTime();if(l){if(!(i-i%864e5>l-l%864e5)){t.renderBubble(a,r,e,false)}else{t.renderBubble(a,r,e,true)}}else{t.renderBubble(a,r,e,true)}}})}t.on("rightTabClick",function(){if(e.bizId==="baby"){a.get("items")["prof"].get("pluginObj").fire("rightTabItemClick",{bizId:"baby"})}});t.on("bindRightDetail",function(){if(window.login&&window.join){i(".mallBar-baby-tab-footer-babyInfo").text(window.babyInfo.name+","+window.babyInfo.birthday);i(".mallBar-baby-tab-footer-babyEdit").text("\u7f16\u8f91\u5b9d\u5b9d\u4fe1\u606f");i("."+o).delegate("click",".mallBar-baby-tab-footer-babyEdit",function(l){t.editBubble(a)})}else if(window.login&&!window.join){i(".mallBar-baby-tab-footer-babyEdit").text("\u52a0\u5165\u5b9d\u5b9d\u8ba1\u5212");i("."+o).delegate("click",".mallBar-baby-tab-footer-babyEdit",function(l){t.editBubble(a)})}});t.fire("rightChange",{rightDetail:"
\u5b9d\u5b9d\u8ba1\u5212\u6743\u76ca
"})},joinBabyPlan:function(){var t=this,l=function(){if(!window.babyInfo){return}if(window.babyInfo.gender){a.all(".mallBar-baby-radio").each(function(t){if(t.val()==window.babyInfo.gender){a.one(t).attr("checked","checked")}})}if(window.babyInfo.birthday){a.one("#mallBar-baby-BRITH1").val(window.babyInfo.birthday)}a.one("#mallBar-baby-NAME1").val(window.babyInfo.name||"")};var e=function(a,t){var l=0,i=0;for(var e=0;e127||a.charCodeAt(e)==94){l+=2}else{l++}if(l>t){i=e;break}}return l>t};var b=function(t,l){var i=true,b;if(!t||!/^(\d{4})\-(\d{1,2})\-(\d{1,2})$/.test(t)){i=false}if(!l){i=false}if(e(l,16)){i=false}a.one(".mallBar-baby-tips").css("display",!i?"block":"none");a.one(".mallBar-baby-tips").text(!i?"\u8bf7\u586b\u5199\u6b63\u786e\u7684\u6570\u636e\u54e6,\u4eb2~":"");return i};var o=function(){var a=new n({triggerNode:"#mallBar-baby-BRITH1"});var t=n.DATE.stringify(new Date);a.set("count","1");a.set("date",t);a.set("minDate","");a.set("isSelect",1);a.set("maxDate",n.DATE.siblings(t,"300"));a.set("isDateInfo",false);a.on("dateclick",function(a){});c(".calendar-icon").on("click",function(){c("#mallBar-baby-BRITH1").fire("focus")})};var s=function(){a.one("#joinButton").on("click",function(t){var l=a.trim(a.one("#mallBar-baby-BRITH1").val()),e=a.one(".mallBar-baby-radio").attr("checked")?"1":"2",n=a.trim(a.one("#mallBar-baby-NAME1").val()),r=[],o=window.babyInfo?"edit":"add";if(!b(l,n)){return}new i({dataType:"jsonp",url:d+"/baby/operateBabyPlan.do?version=1",timeout:10,data:{name:n,birthday:l,brandIds:r.join(","),operate:o,gender:e,source:7,joinType:window.babyEnterPosition||"plan",_tb_token_:window._tb_token_||""},success:function(a){if(!a.success){return}window.location.reload(true)}})})};var m=function(){a.one("#exitBabyPlan").on("click",function(a){a.stopPropagation();var t=new r({tip:"\u786e\u5b9a\u8981\u9000\u51fa\u5929\u732b\u5b9d\u5b9d\u8ba1\u5212\u5417\uff1f",showCat:true,callback:function(a){if(a){new i({dataType:"jsonp",timeout:10,url:d+"/baby/operateBabyPlan.do?version=1",data:{operate:"delete",_tb_token_:window._tb_token_||"",babyId:window.babyInfo&&window.babyInfo.id||"0"},success:function(a){if(!a.success){return}window.location.reload(true)}})}}});t.render();t.show()})};var y=function(){o();l();if(window.babyInfo){m()}s()};y()},editBubble:function(a){var t=this,l={title:"\u586b\u5199\u5b9d\u5b9d\u4fe1\u606f",content:t.joinOrEditBabyInfo(window.join),height:136,bubbleType:1,show:true,dismiss:null,first:true,arrClicked:"tmallbrand.99.93",arrShowed:"tmallbrand.99.94",showed:function(){t.joinBabyPlan()},clicked:null};a.bubble(l)},renderBubble:function(t,e,b,n){var r=[96,146,186],o=this,s;var d=function(a){if(!a.data.show){return}else{s={title:"\u5929\u732b\u6bcd\u5a74\u5b9d\u5b9d\u8ba1\u5212\u6743\u76ca",content:o.huodongBubble(a.data.status,a),height:r[a.data.status],bubbleType:1,show:true,dismiss:null,first:true,arrClicked:"tmallbrand.99.95",arrShowed:"tmallbrand.99.96",colsedClicked:function(){e.set({k:"fatigue"+t.get("items")["prof"].getUid(),v:(new Date).getTime(),success:function(a){}})},showed:function(){var e=location.hostname.indexOf(".daily.")>-1?"baby.daily.tmall.net/":"baby.tmall.com/",b="//plaza."+e,n=b+"item/applyExchangeProm.do?actId=5077&itemId=2100516777058",r=b+"item/queryNewMumItems.do";if(a.data.status==0&&window.join){l.all(".mallBar-baby-mark").on("click",function(a){var t=this.getAttribute("data-itemId");a.stopPropagation();a.preventDefault();new i({dataType:"jsonp",url:r,data:{},success:function(a){if(a.success){new i({dataType:"jsonp",url:n,data:{itemId:t,actId:a.data.actId},success:function(a){if(!a.success){alert(a.errorMsg)}else{location.href="http://detail.tmall.com/item.htm?id="+t+""}}})}else{alert(a.errorMsg)}}})})}if(c("#mallBar-baby-join")){c("#mallBar-baby-join").on("click",function(l){l.preventDefault();l.stopPropagation();location.href=a.type?"http://baby.tmall.com/go/market/baby/newmother.php?isShow=1":"http://baby.tmall.com/go/market/baby/9yhg.php?isShow=1";o.editBubble(t)})}if(c(".mallBar-baby-a")){l.all(".mallBar-baby-a").on("click",function(l){l.preventDefault();l.stopPropagation();location.href=a.type?"http://baby.tmall.com/go/market/baby/newmother.php?isShow=1":"http://baby.tmall.com/go/market/baby/9yhg.php?isShow=1";o.editBubble(t)})}},clicked:null};t.bubble(s)}};if(window.login){new i({dataType:"jsonp",url:m+"/baby/getNewMumInfo.htm",data:{brandId:b.brandId,sellerId:b.sellerId,frontEndCatId:b.frontEndCatId,bizId:b.bizId},success:function(l){if(l.success){if(l.data.join&&window.login){window.babyInfo=l.data.openBabyDTO;window.join=l.data.join}else if(!l.data.join&&window.login){window.join=l.data.join}if((location.href.indexOf("newmother.php")>=0||location.href.indexOf("9yhg.php")>=0)&&a.unparam(window.location.search.replace("?",""))["isShow"]==1&&(window.login&&!window.join)){o.editBubble(t)}if(location.href.indexOf("9yhg.php")>=0||location.href.indexOf("newmother.php")>=0){return}if(!n){return}if(l.data.show==false){new i({dataType:"jsonp",url:m+"/baby/get9YuanInfo.htm",data:{sellerId:b.sellerId,frontEndCatId:b.frontEndCatId,bizId:b.bizId},success:function(a){if(a.success){if(a.data.show==false){}else{a.data.status=2;if(a.data.moneyThisMonth>=15e3&&a.data.moneyThisMonth<2e4){a.data.isMatch=false}else if(a.data.moneyThisMonth>=2e4){a.data.isMatch=true}d(a)}}else{return}}})}else{l.type="newmother";if(!l.data.brandDTO){l.data.status=1}else if(l.data.brandDTO.brandItemList.length==1){l.data.status=0}d(l)}}else{return}}})}},getRightDetail:function(){var a=''+'
'+'
'+'
'+'
'+'
\u6362\u8d2d\u6743\u76ca'+"
"+'
'+'

'+'
\u9996\u4ef6\u6743\u76ca'+"
"+"
"+'
";return{html:a,isVisible:false}},joinOrEditBabyInfo:function(a){var t='"}else{t+=''+''+""+""+""}return t},huodongBubble:function(a,t){var l="",i,e,b=t.data.join?"\u7acb\u5373\u67e5\u770b":"\u7acb\u5373\u52a0\u5165",n=t.data.join?"mallBar-baby-see":"mallBar-baby-join",r=t.data.join?"":"mallBar-baby-a";if(a===0){l=''+'
'+'

'+"
"+'
'+'
'+'
\u65d7\u8230\u5e97\u5976\u7c89\u4e13\u4f9b
'+"
\u9996\u6b21\u8d2d\u4e705\u6298\u5305\u90ae
"+"
"+'
"+"
"+"
"}else if(a===1){var o=t.data.join?"\u606d\u559c\u4eb2\uff0c\u83b7\u5f97\u201c\u9996\u8d2d5\u6298\u201d\u6743\u76ca":"\u52a0\u5165\u5b9d\u5b9d\u8ba1\u5212,\u7acb\u4eab\u201c\u9996\u6b21\u8d2d\u4e705\u6298\u201d\u6743\u76ca";l=''+'
'+'
'+o+"
"+"
\u5927\u724c\u5976\u7c895\u6298\u4e13\u4eab
"+"
"+'
"+'
"+"
"}else if(a===2){var s,d=t.data.join?"\u6bcf\u670825\u65e5\u65e9\u4e0a10\u70b9\uff0c9\u5143\u6362\u4e0d\u505c":"\u7acb\u4eab\u201c9\u5143\u6362\u8d2d\u201d\u6743\u76ca";if(t.data.isMatch){s=t.data.join?"\u606d\u559c\u4eb2\uff0c\u83b7\u5f97\u201c9\u5143\u6362\u8d2d\u201d\u6743\u76ca":"\u52a0\u5165\u5b9d\u5b9d\u8ba1\u5212"}else{s=t.data.join?"\u4e07\u4ef6\u5927\u724c\u5c3d\u5728\u201c9\u5143\u6362\u8d2d\u201d":"\u52a0\u5165\u5b9d\u5b9d\u8ba1\u5212"}l='"}return l}});return s},{requires:["base","node","ajax","dom","event","gallery/calendar/1.2/index","mui/overlay/confirm","uri","mui/mallbar-baby/index.css"]});KISSY.add("mui/overlay/confirm",function(t,i){var e={width:360,height:"auto",skin:"defalt",showCat:false,headerContent:"",bodyContent:"",mask:true,zIndex:99999,closeAction:"destroy",align:{points:["cc","cc"]},tip:"",msgType:"question",confirmBtn:"\u786e\u8ba4",cancelBtn:"\u53d6\u6d88"};function n(i){if(t.isString(arguments[0])){var s={};s.tip=arguments[0];i=s;if(t.isFunction(arguments[1]))i.callback=arguments[1];if(t.isObject(arguments[2]))i=t.merge(i,arguments[2])}i=t.merge(e,i);if(i.skin=="gray"||i.skin=="red"||i.skin=="blue"){i.headerContent="\u786e\u8ba4\u64cd\u4f5c"}i.bodyContent='";i.bodyContent=i.bodyContent.replace("{MSGTYPE}",i.msgType);var a={blue:"mui-b-btn-m-primary",defalt:"mui-btn-m-primary"},o=i.skin=="blue"?a[i.skin]:a.defalt;i.footerContent='
";n.superclass.constructor.call(this,i);this.on("afterRenderUI",function(){var t=this,e=this.get("el");var n=e.one(".mui-dialog-cfmOk"),s=e.one(".mui-dialog-cfmCancel");n.on("click",function(){i.callback&&i.callback.call(null,true);if(i.closeAction==="destroy"){t.destroy()}else{t.hide()}});s.on("click",function(){i.callback&&i.callback(false);if(i.closeAction==="destroy"){t.destroy()}else{t.hide()}})})}t.extend(n,i);return n},{requires:["mui/overlay/dialog"]});