1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{141:function(t,e,n){var i=n(4),o=n(30),s=n(313),r=n(311),a=i.Model.extend({POLL_DURATION:5e3,initialize:function(t){this.options=t||{}},getCode:function(t){var e=this,n=this;if(!t.noValidate&&!ST.REGEX.PHONE.test(t.phone))return this.trigger("getCode:error","请输入正确的手机号码");this.trigger("getCode:loading"),delete t.noValidate;var i=function(){e.fetch({url:e.options.url||ST.ACTION.GET_SMS_CODE,data:t,type:"POST",success:function(e,i){n.trigger("getCode:success",i,t)},error:function(t,e){if("10833"===e.code)return n.trigger("getCode:geetest",e.data);n.trigger("getCode:error",e.message||ST.LRes.getPhoneCodeFailed,e)}})};return this.options.beforeSend?this.options.beforeSend.call(this).then(i):i()},abortXhr:function(){clearTimeout(this.pollTimer);var t=this.xhr;t&&t.readyState>0&&t.readyState<4&&t.abort&&t.abort()},pollStatus:function(t,e){e&&(this.startTime=(new Date).getTime(),this.abortXhr());this.xhr=this.fetch({type:"post",timeout:5e4,url:ST.ACTION.ACTIVITY_POLL_VERIFY_STATUS,data:t,success:_.bind((function(t,e){this.trigger("verify:success",e)}),this),error:_.bind((function(e,n){var i=this;"10911"!==n.code&&"10500"!==n.code?this.trigger("verify:error",n):this.pollTimer=setTimeout((function(){i.pollStatus(_.extend(t,{status:n.code}))}),this.POLL_DURATION)}),this)})}});n(102);var c=i.View.extend({COUNT_SECONDS:60,template:r,events:{"click .js-code":"getCode"},defaultOptions:{type:void 0,noValidate:void 0,phone:void 0,phoneInput:void 0,tempToken:void 0,url:void 0,duplex:void 0,size:"xs"},initialize:function(t){t.size=t.size||this.$el.data("size")||this.defaultOptions.size,this.options=_.extend({},this.defaultOptions,t),this.model=new a(this.options),this.listenTo(this.model,"getCode:loading",_.bind(this.disableBtn,this)),this.listenTo(this.model,"getCode:success",_.bind(this.onGetCodeSuccess,this)),this.listenTo(this.model,"getCode:error",_.bind(this.enableBtn,this)),this.listenTo(this.model,"getCode:geetest",_.bind(this.geetest,this)),this.listenTo(this.model,"verify:success",_.bind(this.onVerifySuccess,this)),this.listenTo(this.model,"verify:error",_.bind(this.onVerifyError,this)),this.passEvents("getCode:success getCode:error getCode:loading verify:success verify:error",this.model),this.render()},getCode:function(t){t.preventDefault();var e={type:this.options.type,noValidate:this.options.noValidate},n=App.user?App.user.get("userId"):"";n&&(e.userId=n),void 0!==this.options.phone?e.phone=this.options.phone:this.options.phoneInput&&(e.phone=this.options.phoneInput.val()),this.options.tempToken&&(e.temp_token=this.options.tempToken),this.options.reference_id&&(e.reference_id=this.options.reference_id),e.org_channel=window.getOrgChannel(),this.params=e,this.model.getCode(e)},disableBtn:function(){this.$("button").prop("disabled",!0)},enableBtn:function(){this.$("button").prop("disabled",!1)},onGetCodeSuccess:function(t){if(this.options.duplex&&t.data.token){var e={token:t.data.token,reference_id:ST.helper.getQueryString("uid"),org_channel:window.getOrgChannel()},n=ST.helper.getQueryString("agentdown");n&&(e.agentdown=n),navigator.userAgent.match(/AppleWebKit.*Mobile.*/)&&(e.type="1"),this.model.pollStatus(e,!0)}if(this.options.duplex){this.$("button").html('<icon class="icon icon-verify-loading"></icon>验证中');var i={wrapper:this.$(".icon-verify-loading")[0],aPhotoTime:33,aPhotoTotal:32,playNum:!1,endPhoto:0};s(i)}else this.countBtn()},onVerifySuccess:function(){clearTimeout(this.timer),this.disableBtn(),this.$("button").addClass("verified").html('<icon class="icon icon-verify-success"></icon>验证通过');var t={wrapper:this.$(".icon-verify-success")[0],aPhotoTime:33,aPhotoTotal:29,playNum:1,endPhoto:28};s(t)},onVerifyError:function(){clearTimeout(this.timer),this.disableBtn(),this.$("button").addClass("verified").html('<icon class="icon icon-verify-error"></icon>验证未通过');var t={wrapper:this.$(".icon-verify-error")[0],aPhotoTime:33,aPhotoTotal:29,playNum:1,endPhoto:28};s(t)},countBtn:function(){this.remainSeconds=void 0!==this.remainSeconds?this.remainSeconds:this.COUNT_SECONDS,this.remainSeconds>0?(this.$("button").text("".concat(this.remainSeconds,"s")),this.timer=setTimeout(_.bind((function(){this.remainSeconds-=1,this.countBtn()}),this),1e3)):(delete this.remainSeconds,this.$("button").text("获取验证码"),this.enableBtn())},geetest:function(t){var e=new o({data:t});this.listenTo(e,"geetest:success",_.bind((function(t){this.model.getCode(_.extend(this.params,{noValidate:!0},t))}),this)),this.listenTo(e,"geetest:close",_.bind((function(){this.enableBtn(),this.trigger("getCode:error","本次访问需要进行安全验证")}),this))},onDestroy:function(){this.model.abortXhr()}});t.exports=c},30:function(t,e,n){n(301);var i=n(4),o=n(302),s=n(303);n(13);var r=i.View.extend({template:s,events:{"click .js-close":"close"},initialize:function(t){this.dialog=$.popup(this.options.popup),this.setElement(this.dialog.$popup),this.dialog.on("open",_.bind(this.render,this)),this.model=new o(t),t.data&&window.initGeetest({gt:t.data.gt,challenge:t.data.challenge,offline:!t.data.success,product:"popup",width:"100%"},_.bind(this.onInitCallback,this))},open:function(){return this.dialog.open.apply(this.dialog,arguments)},close:function(){this.trigger("geetest:close"),$("body").trigger("geetest:close"),this.dialog.destroy()},destroy:function(){$("body").trigger("geetest:close"),this.dialog.destroy()},onInitCallback:function(t){var e=this;this.dialog.open(!0),$("body").trigger("geetest:open"),t.appendTo($("#geetest-captcha-wrap")[0]),t.onSuccess((function(){var n=t.getValidate();e.destroy(),e.trigger("geetest:success",n)}))}});t.exports=r},301:function(t,e,n){!function(e,n){"use strict";"object"==typeof t.exports?t.exports=e.document?n(e,!0):function(t){if(!t.document)throw new Error("Geetest requires a window with a document");return n(t)}:n(e)}("undefined"!=typeof window?window:this,(function(t,e){"use strict";if(void 0===t)throw new Error("Geetest requires browser environment");var n=t.document,i=t.Math,o=n.getElementsByTagName("head")[0];function s(t){this._obj=t}function r(t){var e=this;new s(t)._each((function(t,n){e[t]=n}))}s.prototype={_each:function(t){var e=this._obj;for(var n in e)e.hasOwnProperty(n)&&t(n,e[n]);return this}},r.prototype={api_server:"api.geetest.com",protocol:"http://",type_path:"/gettype.php",fallback_config:{slide:{static_servers:["static.geetest.com","dn-staticdown.qbox.me"],type:"slide",slide:"/static/js/geetest.0.0.0.js"},fullpage:{static_servers:["static.geetest.com","dn-staticdown.qbox.me"],type:"fullpage",fullpage:"/static/js/fullpage.0.0.0.js"}},_get_fallback_config:function(){return a(this.type)?this.fallback_config[this.type]:this.new_captcha?this.fallback_config.fullpage:this.fallback_config.slide},_extend:function(t){var e=this;new s(t)._each((function(t,n){e[t]=n}))}};var a=function(t){return"string"==typeof t},c={},d={},l=function(t,e,n,i){e=function(t){return t.replace(/^https?:\/\/|\/$/g,"")}(e);var o=function(t){return 0!==(t=t.replace(/\/+/g,"/")).indexOf("/")&&(t="/"+t),t}(n)+function(t){if(!t)return"";var e="?";return new s(t)._each((function(t,n){(a(n)||function(t){return"number"==typeof t}(n)||function(t){return"boolean"==typeof t}(n))&&(e=e+encodeURIComponent(t)+"="+encodeURIComponent(n)+"&")})),"?"===e&&(e=""),e.replace(/&$/,"")}(i);return e&&(o=t+e+o),o},p=function(t,e,i,s,r){var a=function(c){!function(t,e){var i=n.createElement("script");i.charset="UTF-8",i.async=!0,i.onerror=function(){e(!0)};var s=!1;i.onload=i.onreadystatechange=function(){s||i.readyState&&"loaded"!==i.readyState&&"complete"!==i.readyState||(s=!0,setTimeout((function(){e(!1)}),0))},i.src=t,o.appendChild(i)}(l(t,e[c],i,s),(function(t){t?c>=e.length-1?r(!0):a(c+1):r(!1)}))};a(0)},h=function(e,n,o,s){if("object"==typeof(r=o.getLib)&&null!==r)return o._extend(o.getLib),void s(o);var r;if(o.offline)s(o._get_fallback_config());else{var a="geetest_"+(parseInt(1e4*i.random())+(new Date).valueOf());t[a]=function(e){"success"===e.status?s(e.data):e.status?s(o._get_fallback_config()):s(e),t[a]=void 0;try{delete t[a]}catch(t){}},p(o.protocol,e,n,{gt:o.gt,callback:a},(function(t){t&&s(o._get_fallback_config())}))}},u=function(t,e){var n={networkError:"网络错误"};if("function"!=typeof e.onError)throw new Error(n[t]);e.onError(n[t])};t.Geetest&&(d.slide="loaded");var f=function(e,n){var i=new r(e);e.https?i.protocol="https://":e.protocol||(i.protocol=t.location.protocol+"//"),h([i.api_server||i.apiserver],i.type_path,i,(function(e){var o=e.type,s=function(){i._extend(e),n(new t.Geetest(i))};c[o]=c[o]||[];var r=d[o]||"init";"init"===r?(d[o]="loading",c[o].push(s),p(i.protocol,e.static_servers||e.domains,e[o]||e.path,null,(function(t){if(t)d[o]="fail",u("networkError",i);else{d[o]="loaded";for(var e=c[o],n=0,s=e.length;n<s;n+=1){var r=e[n];"function"==typeof r&&r()}c[o]=[]}}))):"loaded"===r?s():"fail"===r?u("networkError",i):"loading"===r&&c[o].push(s)}))};return t.initGeetest=f,f}))},302:function(t,e,n){var i=n(4).Model.extend({initialize:function(t){this.options=t||{}}});t.exports=i},303:function(module,exports){module.exports=function(obj){var __t,__p="",__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,"")};with(obj||{})__p+='<div class="dialog dialog-default geetest-dialog">\n <div class="dialog-hd">\n <div class="dialog-title">请完成安全认证</div>\n <div class="dialog-control">\n <ul>\n <li><a class="dialog-close js-close" href="javascript:;">关闭</a></li>\n </ul>\n </div>\n </div>\n <div class="dialog-bd">\n <p class="intro">本次访问需要进行安全验证</p>\n <div id="geetest-captcha-wrap">\n\n </div>\n </div>\n</div>\n\n<style>\n .geetest-dialog {\n /*position: fixed;*/\n /*top: 50%;*/\n /*left: 50%;*/\n width: 320px;\n height: 240px;\n /*margin: -120px 0 0 -160px;*/\n background: #fff;\n border-radius: 4px;\n\n }\n\n .geetest-dialog .dialog-bd {\n padding: 0 30px;\n }\n\n .geetest-dialog .dialog-bd .intro {\n font-size: 14px;\n margin-top: 40px;\n margin-bottom: 16px;\n }\n\n .geetest_popup * {\n box-sizing: content-box;\n }\n</style>\n';return __p}},311:function(module,exports){module.exports=function(obj){var __t,__p="",__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,"")};with(obj||{})__p+="",this.options.duplex?__p+='\n\x3c!--<button class="btn btn-default btn-code js-code" data-dssp="获取验证码组件 验证手机"><icon class="icon icon-verify-success"></icon>验证通过</button>--\x3e\n<button\n class="_btn btn-link btn-'+(null==(__t=this.options.size)?"":__t)+' btn-code js-code"\n data-dssp="获取验证码组件 验证手机"\n>\n 验证手机\n</button>\n':__p+='\n<button\n class="_btn btn-link btn-'+(null==(__t=this.options.size)?"":__t)+' btn-code js-code"\n data-dssp="获取验证码组件 获取验证码"\n>\n 获取验证码\n</button>\n',__p+="\n";return __p}}}]); |