import{n as i,v as a}from"./index-9e42b1dc.js";import"./element-37f6a05c.js";const l={name:"SIdentify",props:{identifyCode:{type:String,default:"56h3"},fontSizeMin:{type:Number,default:35},fontSizeMax:{type:Number,default:35},backgroundColorMin:{type:Number,default:180},backgroundColorMax:{type:Number,default:240},colorMin:{type:Number,default:50},colorMax:{type:Number,default:160},lineColorMin:{type:Number,default:100},lineColorMax:{type:Number,default:200},dotColorMin:{type:Number,default:0},dotColorMax:{type:Number,default:255},contentWidth:{type:Number,default:120},contentHeight:{type:Number,default:50}},watch:{identifyCode(){this.drawPic()}},mounted(){this.drawPic()},methods:{randomNum(t,e){return Math.floor(Math.random()*(e-t)+t)},randomColor(t,e){const o=this.randomNum(t,e),n=this.randomNum(t,e),s=this.randomNum(t,e);return"rgb("+o+","+n+","+s+")"},transparent(){return"rgb(255,255,255)"},drawPic(){const e=document.getElementById("s-canvas").getContext("2d");e.textBaseline="bottom",e.fillStyle=this.transparent(),e.fillRect(0,0,this.contentWidth,this.contentHeight);for(let o=0;o{a(n)?s():s(new Error("Please enter the correct user name"))}}],password:[{required:!0,trigger:"blur",validator:(o,n,s)=>{n.length<6?s(new Error("The password can not be less than 6 digits")):s()}}]},loading:!1,passwordType:"password",redirect:void 0,code:"",identifyCode:"",identifyCodes:"123456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}},watch:{$route:{handler(t){this.redirect=t.query&&t.query.redirect},immediate:!0}},created(){this.refreshCode()},methods:{showPwd(){this.passwordType==="password"?this.passwordType="":this.passwordType="password",this.$nextTick(()=>{this.$refs.password.focus()})},handleLogin(){if(this.code.toLowerCase()!=this.identifyCode.toLowerCase()){this.$message({message:"验证码错误",type:"error"});return}this.$refs.loginForm.validate(t=>{if(t)this.loading=!0,this.$store.dispatch("user/login",this.loginForm).then(()=>{this.$router.push({path:this.redirect||"/"}),this.loading=!1}).catch(()=>{this.loading=!1});else return!1})},refreshCode(){this.identifyCode="",this.makeCode(this.identifyCodes,4)},randomNum(t,e){return e=e+1,Math.floor(Math.random()*(e-t)+t)},makeCode(t,e){for(let o=0;o