passport.bind.js 6.71 KB
webpackJsonp([8],{0:function(e,a,o){o(27)},3:function(e,a,o){function t(e){var a,o,t,n=0,i=0;for(t=0;t<e.length;t++)o=e.substr(t,1),i+=/.*[\u4e00-\u9fa5]+.*$/.test(o)?2:1;if(10>=i)a=e;else{for(n=0,a="",t=0;t<e.length;t++)10>n&&(o=e.substr(t,1),"*"!==o&&(n+=/.*[\u4e00-\u9fa5]+.*$/.test(o)?2:1),a+=o);a.length<e.length&&(a+="...")}return a}function n(e){var a,o,n=e.data;-1!==e.result?(o=t(n.profile_name),a='<span>Hi~</span><a href="//www.yohobuy.com/home?t='+n.random+'">'+o+'</a>&nbsp;<a href="//www.yohobuy.com/logout.html">[退出]</a>'):a='<span>Hi~</span>&nbsp;<a href="//www.yohobuy.com/signin.html">[请登录]</a>&nbsp;<a href="//www.yohobuy.com/reg.html">[免费注册]</a>',s(".header-tool li").eq(0).html(a)}function i(){var e={return_type:"jsonp"};s.getJSON("//www.yohobuy.com/common/passport/?callback=?",e,function(e){e&&e.data&&n(e.data)})}var s=o(1),r=s("#api-domain");r.remove(),s(".simple-header").size()>0&&s(".tool-options").on("mouseenter",function(){s(this).find(".tool-select").fadeIn()}).on("mouseleave",function(){s(this).find(".tool-select").fadeOut()}),i()},8:function(e,a){var o={"+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]{1}[0-9]{8}$/,"+81":/^0[9|8|7][0-9]{9}$/,"+61":/^[0-9]{11}$/},t=/^[.\-_a-zA-Z0-9]+@[\-_a-zA-Z0-9]+\.[a-zA-Z0-9]/,n=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;a.phoneRegx=o,a.emailRegx=t,a.pwdValidateRegx=n},27:function(e,a,o){function t(){w(".choosetag").on("change",function(){var e="#f02200";"checked"===w(this).attr("checked")?w(".choosewrapper").css({"background-image":'url("'+T+'")'}):(w(".choosewrapper").css({"background-image":"none"}),e="#CCCCCC"),z.css({"background-color":e})})}function n(){return"checked"===w(".choosetag").attr("checked")}function i(){w(".optionshow").on("click",function(){w(".optionslist").toggleClass("hide")})}function s(){var e="";w(document).on("keyup","#validatenum",function(){e=w(this).val(),4===e.length&&($||($=!0,w.ajax({type:"POST",url:"/passport/autouserinfo/checkBindMsg",data:{code:e,mobile:w("#mobile").val(),area:w("#areacode").val()}}).then(function(e){$=!1,200===e.code?A=!0:alert(e.message)})))}),w("#validatenum").focus(function(){w(this).removeAttr("placeholder")}).blur(function(){w(this).attr("placeholder","验证码")})}function r(){w(".optionitem").on("click",function(){var e=w(this),a=e.attr("areanum"),o=e.text();w("#areaname").text(o),w("#areanum").text(a),w("#areacode").val(a),w(".optionslist").addClass("hide")})}function c(){w(document).on("click","body",function(e){var a=w(e.target);a.hasClass("yohoselectarea")||a.hasClass("areaname")||a.hasClass("righttag")||a.hasClass("optionslist")||a.hasClass("optionitem")||w(".optionslist").addClass("hide")})}function d(){var e="",a="";w(".optionitem").each(function(){e=w(this),a=e.attr("areanum").replace(/\+/g,""),e.attr("areanum",a)})}function l(){var e;w(document).on("click","#alreayregist",function(a){e=w(a.target),(e.hasClass("mask")||e.hasClass("backdrop"))&&(w("#alreayregist").hide(),w(".backdrop").hide())}),w(document).on("click","#bindconfirm",function(a){e=w(a.target),(e.hasClass("mask")||e.hasClass("backdrop"))&&(w("#bindconfirm").hide(),w(".backdrop").hide())})}function u(){w(document).on("click","#yohobindbtn",function(){w(".phonenum").val(""),w("#bindconfirm").hide(),w(".backdrop").hide()}),w(document).on("click","#yohobindbtn2",function(){w(".phonenum").val(""),w("#alreayregist").hide(),w(".backdrop").hide()})}function h(){return x-=1,0>x?(x=60,void w(".validatewrapper").html(C)):(w(".second").text(x),void window.setTimeout(h,1e3))}function m(e){w(".validatewrapper").html(k),window.setTimeout(h,1e3)}function p(){w(document).on("click","#sendmessage",function(){"disabled"!==w("#sendmessage").attr("disabled")&&(m(w("#mobile").val()),w.ajax({type:"POST",url:"/passport/autouserinfo/sendBindMsg",data:{mobile:w("#mobile").val(),area:w("#areacode").val()}}).then(function(e){200!==e.code&&alert(e.message)}))})}function f(){var e="",a="";a=w("#areacode").val(),e=w("#mobile").val(),w.ajax({type:"POST",url:"/passport/autouserinfo/bindMobile",data:{area:a,openId:w("#openId").val(),sourceType:w("#sourceType").val(),mobile:e,code:w("#validatenum").val()}}).then(function(e){200===e.code?e.data&&e.data.refer?window.location.href=e.data.refer:window.location.href="/passport/thirdlogin/bindsuccess":alert(e.message)})}function b(){w(document).on("click","#gotobindphone",function(){A===!0?(w("#inarea").val(w("#areacode").val()),w("#inmobile").val(w("#mobile").val()),f()):alert("请输入正确验证码")})}function g(){var e="",a="",o="",t="",i="",s="";w("#bindfirststep").on("click",function(r){var c;if(r.preventDefault(),o=w(".phonenum").val(),t=w("#areanum").text(),c=y["+"+t],n()){if(""===o||!c||!c.test(o))return j.find("em").text("手机格式错误"),void j.removeClass("hide");e=w("#openId").val()||"29803EC6D4AAC3AAB8ABDB6AE829D579",a=w("#sourceType").val()||"qq",w.ajax({type:"post",url:"/passport/autouserinfo/bindCheck",data:{mobile:o,area:t,openId:e,sourceType:a},dataType:"json",success:function(e){var a=w(window).height();200===e.code?(w("#bindmobileform").attr("action",e.data.next),w("#bindmobileform").submit()):201===e.code?(i=e.data.user.username,s=e.data.user.headImg,w("#registphone").text(o),w("#username").text(i),""===s?w("#userphoto").attr("src","http://img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100"):w("#userphoto").attr("src",s),w("#logindirectly2").attr("href",e.data.user.bindLogin),w(".backdrop").show(),w("#sendmessage").click(),w("#alreayregist .mask").css({"padding-top":a>440?a/2:217}),w("#alreayregist").show()):203===e.code?(w("#bindmobileform").attr("action",e.data.next),w("#bindmobileform").submit()):205===e.code?(i=e.data.user.username,s=e.data.user.headImg,w("#registphonetwo").text(o),w("#username1").text(i),""===s?w("#userphoto1").attr("src","http://img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100"):w("#userphoto1").attr("src",s),w("#logindirectly").attr("href",e.data.user.bindLogin),w(".backdrop").show(),w("#bindconfirm .mask").css({"padding-top":a>440?a/2:217}),w("#bindconfirm").show()):402===e.code?(j.find("em").text("手机格式错误"),j.removeClass("hide")):e&&e.message&&alert(e.message)}})}})}function v(){d(),p(),t(),r(),i(),c(),g(),l(),u(),b(),s()}var w=o(1),y=o(8).phoneRegx,k=w("#nopermissionmessage").html(),C=w(".validatewrapper").html(),x=+w(".second").text(),$=!1,A=!1,T="http://cdn.yoho.cn/yohobuy/assets/img/passport/choosed.png",I=w(".bindwrapper"),j=I.find(".phone-err-tip"),z=I.find(".yohobindbtn");o(3),I.on("keydown",".phonenum",function(e){return 13===e.keyCode?(z.trigger("click"),!1):void 0}),v()}});