var $url="/login",$urlCaptcha="/login/captcha",$urlCaptchaCheck="/login/captcha/actions/check",$urlSendSms="/login/actions/sendSms";window.top!=self&&(window.top.location=self.location);var data=utils.init({status:utils.getQueryInt("status"),pageSubmit:!1,pageAlert:null,account:null,password:null,isPersistent:!1,captchaToken:null,captchaValue:null,captchaUrl:null,version:null,adminTitle:null,isSmsEnabled:!1,isSmsLogin:!1,mobile:null,code:null,countdown:0}),methods={apiGet:function(){var t=this;401===this.status&&(this.pageAlert={type:"danger",html:"您的账号登录已过期或失效，请重新登录"}),utils.loading(this,!0),$api.get($url).then(function(i){var a=i.data;a.success?(t.version=a.version,t.adminTitle=a.adminTitle,t.isSmsEnabled=a.isSmsEnabled,t.apiCaptcha()):location.href=a.redirectUrl}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},apiCaptcha:function(){var t=this;utils.loading(this,!0),$api.post($urlCaptcha).then(function(i){var a=i.data;t.captchaToken=a.value,t.captchaValue="",t.pageSubmit=!1,t.captchaUrl=$apiUrl+$urlCaptcha+"?token="+t.captchaToken}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},apiCaptchaCheck:function(){var t=this;utils.loading(this,!0),$api.post($urlCaptchaCheck,{token:this.captchaToken,value:this.captchaValue}).then(function(i){t.apiSubmit()}).catch(function(i){t.apiCaptcha(),utils.loading(t,!1),utils.error(i)})},apiSendSms:function(){var t=this;utils.loading(this,!0),$api.post($urlSendSms,{mobile:this.mobile}).then(function(i){i.data;utils.success("验证码发送成功，10分钟内有效"),t.countdown=60;var a=setInterval(function(){t.countdown-=1,t.countdown<=0&&clearInterval(a)},1e3)}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},apiSubmit:function(){var t=this;utils.loading(this,!0),$api.post($url,{isSmsLogin:this.isSmsLogin,account:this.account,password:md5(this.password),mobile:this.mobile,code:this.code,isPersistent:this.isPersistent}).then(function(i){var a=i.data;localStorage.setItem("sessionId",a.sessionId),localStorage.removeItem(ACCESS_TOKEN_NAME),sessionStorage.removeItem(ACCESS_TOKEN_NAME),t.isPersistent?localStorage.setItem(ACCESS_TOKEN_NAME,a.token):sessionStorage.setItem(ACCESS_TOKEN_NAME,a.token),a.isEnforcePasswordChange?t.redirectPassword():t.redirectIndex()}).catch(function(t){utils.error(t)}).then(function(){t.apiCaptcha(),utils.loading(t,!1)})},redirectPassword:function(){location.href=utils.getSettingsUrl("administratorsPassword")},redirectIndex:function(){location.href=utils.getIndexUrl()},redirectLostPassword:function(){location.href=utils.getRootUrl("lostPassword")},isMobile:function(t){return/^1[3|4|5|7|8][0-9]\d{8}$/.test(t)},btnSendSmsClick:function(){this.countdown>0||(this.mobile?this.isMobile(this.mobile)?(this.pageAlert=null,this.apiSendSms()):this.pageAlert={type:"danger",html:"请输入有效的手机号码"}:this.pageAlert={type:"danger",html:"手机号码不能为空"})},btnCaptchaClick:function(){this.apiCaptcha()},btnSubmitClick:function(t){if(t.preventDefault(),this.pageSubmit=!0,this.pageAlert=null,this.isSmsLogin){if(!this.mobile||!this.code)return;this.apiSubmit()}else{if(!this.account||!this.password||!this.captchaValue)return;this.apiCaptchaCheck()}}},$vue=new Vue({el:"#main",data:data,directives:{focus:{inserted:function(t){t.focus()}}},methods:methods,created:function(){this.apiGet()}});