import{o as e}from"./chunk-mlkTr37E.js";import{t}from"./_plugin-vue2_normalizer-BHc2Ljhs.js";import{s as n}from"./logger-BTOOQRog.js";import{n as r}from"./vuex.esm-DZpGMn32.js";import{t as i}from"./delay-CW5VuKve.js";var a=e(i()),o=t({name:`LoginIndex`,components:{login:t({name:`LoginIndex`,data(){return{loading:!1,form:{username:``,password:``},returnUrl:``}},computed:{rules(){return{username:[{required:!0,message:this.$t(`VALIDATE_FIELD_REQUIRED`),trigger:`blur`}],password:[{required:!0,message:this.$t(`VALIDATE_FIELD_REQUIRED`),trigger:`blur`},{min:6,message:this.$t(`VALIDATE_PASSWORD_MIN`),trigger:`blur`}]}}},methods:{...r([`SetToken`,`SetUser`,`SetLogin`,`Logout`]),openPageRegister(){this.RouterPath(`/register`)},async loginSubmit(){if(await new Promise(e=>{this.$refs.loginForm.validate(t=>e(t))})){this.loading=!0;try{let e=await this.UserLogin(this.form);if(!(e.success&&e.token))throw this.$Message.error(e.msg||this.$t(`LOGIN_ERROR`)),{msg:`LOGIN_ERROR`,result:e};if(this.$Message.success(this.$t(`LOGIN_SUCCESS`)),await(0,a.default)(500),this.returnUrl)return this.RouterPath(this.returnUrl);this.RouterTo(`root`)}catch(e){n.error({msg:`LOGIN_ERROR`,error:e})}this.loading=!1}},autoLogin(){let{username:e,password:t,ref:n}=this.$route.query;if(!(e&&t))return!1;this.form.username=e,this.form.password=t,n===`shop-manager`&&this.SetUseShopManager(!0),delete this.$route.params.username,delete this.$route.params.password,this.$router.replace({name:this.$route.name,params:this.$route.params,query:{}});let r=this.loginSubmit;return setTimeout(r,200)}},created(){this.returnUrl=this.$route.query.returnUrl,this.form.username=this.getUsername,this.form.password=this.getPassword,this.autoLogin()}},function(){var e=this,t=e._self._c;return t(`div`,{staticClass:`lg-login`},[e.getIsAuthed?t(`Alert`,{staticClass:`lg-login__authed`,attrs:{type:`success`,"show-icon":``}},[e._v(` `+e._s(e.$t(`USER_WAS_LOGGED`))+` `)]):t(`div`,{staticClass:`lg-login__panel`},[e.isUsePopup?e._e():t(`div`,{staticClass:`lg-login__brand`},[t(`img`,{staticClass:`lg-login__logo`,attrs:{src:e.configApp.logoDark,alt:`AutoShopee`}})]),t(`div`,{staticClass:`lg-login__card`},[t(`h2`,{staticClass:`lg-login__title`},[e._v(` `+e._s(e.$t(`LOGIN_USER`))+` `)]),t(`Form`,{ref:`loginForm`,staticClass:`lg-login__form`,attrs:{model:e.form,rules:e.rules}},[t(`FormItem`,{attrs:{prop:`username`}},[t(`Input`,{attrs:{placeholder:e.$t(`USERNAME`),prefix:`ios-person`,size:`large`},nativeOn:{keyup:function(t){return!t.type.indexOf(`key`)&&e._k(t.keyCode,`enter`,13,t.key,`Enter`)?null:e.loginSubmit.apply(null,arguments)}},model:{value:e.form.username,callback:function(t){e.$set(e.form,`username`,t)},expression:`form.username`}})],1),t(`FormItem`,{attrs:{prop:`password`}},[t(`Input`,{attrs:{type:`password`,placeholder:e.$t(`PASSWORD`),prefix:`ios-lock`,size:`large`,password:``},nativeOn:{keyup:function(t){return!t.type.indexOf(`key`)&&e._k(t.keyCode,`enter`,13,t.key,`Enter`)?null:e.loginSubmit.apply(null,arguments)}},model:{value:e.form.password,callback:function(t){e.$set(e.form,`password`,t)},expression:`form.password`}})],1),t(`FormItem`,{staticClass:`mb-0`},[t(`Button`,{staticClass:`lg-login__submit`,attrs:{type:`primary`,long:``,size:`large`,loading:e.loading},on:{click:e.loginSubmit}},[e._v(` `+e._s(e.$t(`BTN_LOGIN`))+` `)])],1)],1),t(`div`,{staticClass:`lg-login__divider`},[t(`span`,{staticClass:`lg-login__divider-text`},[e._v(` `+e._s(e.$t(`REGISTER_OR`))+` `)])]),t(`Button`,{staticClass:`lg-login__alt`,attrs:{long:``,size:`large`},on:{click:e.openPageRegister}},[e._v(` `+e._s(e.$t(`BTN_REGISTER`))+` `)]),t(`p`,{staticClass:`lg-login__note`},[e._v(` `+e._s(e.$t(`LOGIN_PAGE_NOTE`))+` `)])],1)])],1)},[],!1,null,`37401e61`,null,null).exports}},function(){var e=this,t=e._self._c;return t(`div`,[t(`Row`,[t(`Col`,{attrs:{span:e.isUsePopup?12:6,offset:e.isUsePopup?6:9}},[t(`login`)],1)],1)],1)},[],!1,null,null,null,null).exports;export{o as default};