erp/public/dist/js/200.fbda0d79.js

2 lines
9.7 KiB
JavaScript
Raw Normal View History

2024-11-04 14:46:22 +08:00
"use strict";(self["webpackChunkerp"]=self["webpackChunkerp"]||[]).push([[200],{7240:function(t,e,r){r.r(e),r.d(e,{default:function(){return p}});var n=function(){var t=this,e=t._self._c;return e("div",{staticClass:"backimg"},[e("div",{staticClass:"sign"},[e("span",{staticClass:"title"},[t._v("Hi 欢迎使用")]),t._m(0),e("p",{staticClass:"title-1"},[t._v("登录")]),e("div",{staticClass:"row"},[e("el-input",{attrs:{placeholder:"请输入用户名",size:"large"},model:{value:t.form.name,callback:function(e){t.$set(t.form,"name",e)},expression:"form.name"}})],1),e("div",{staticClass:"row"},[e("el-input",{attrs:{"show-password":"",placeholder:"请输入密码",size:"large"},model:{value:t.form.password,callback:function(e){t.$set(t.form,"password",e)},expression:"form.password"}})],1),e("el-checkbox",{model:{value:t.checked,callback:function(e){t.checked=e},expression:"checked"}},[t._v("记住密码")]),e("br"),e("el-button",{attrs:{type:"primary",loading:t.loading},on:{click:function(e){return t.Login()},keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.Login()}}},[t._v("登 录")])],1)])},o=[function(){var t=this,e=t._self._c;return e("p",{staticClass:"manage"},[e("img",{attrs:{src:r(5108),alt:""}}),e("span",[t._v("ERP管理系统")])])}],i=(r(560),r(9669)),a=r.n(i),s=r(730),u={data(){return{loading:!1,checked:!1,form:{name:"",password:""}}},mounted(){this.getCookie(),window.addEventListener("keydown",this.keyDown)},methods:{Login(){!0===this.checked?this.setCookie(this.form.name,this.form.password,!0,7):this.clearCookie(),""===this.form.name||""===this.form.password?this.$message({message:"账号或密码不能为空",type:"error"}):(this.loading=!0,a().post("/api/auth/login",this.form).then((t=>{let e=t.data;e.error&&(this.$message({message:"账号或密码错误,请重新输入",type:"error"}),this.form.name="",this.form.password="",this.checked=!1,this.loading=!1),e.token&&(localStorage.setItem("userName",this.form.name),this.form={},localStorage.setItem("token",e.token),(0,s.Xt)().then((t=>{console.log(t.data.roles),t.data.roles&&t.data.roles[0]&&(localStorage.setItem("roleName",t.data.roles[0].name),localStorage.setItem("userId",t.data.id),this.$message({message:"成功登录,欢迎来到后台管理系统",type:"success"}),this.$router.push("/GOODS_LIST")),this.loading=!1})).catch((()=>{this.loading=!1})))})))},setCookie(t,e,r,n){const o=new Date;o.setTime(o.getTime()+864e5*n),window.document.cookie="name="+t+";path=/;expires="+o.toGMTString(),window.document.cookie="password="+e+";path=/;expires="+o.toGMTString(),window.document.cookie="state="+r+";path=/;expires="+o.toGMTString()},getCookie(){if(document.cookie.length>0){const t=document.cookie.split("; ");for(let e=0;e<t.length;e++){const r=t[e].split("=");"name"===r[0]?this.form.name=r[1]:"password"===r[0]?this.form.password=r[1]:"state"===r[0]&&(this.checked=Boolean(r[1]))}}},clearCookie:function(){this.setCookie("","",!1,-1)},keyDown(t){13===t.keyCode&&this.Login()}},destroyed(){window.removeEventListener("keydown",this.keyDown,!1)}},c=u,f=r(1001),l=(0,f.Z)(c,n,o,!1,null,"561481f2",null),p=l.exports},730:function(t,e,r){r.d(e,{CI:function(){return a},Uy:function(){return o},VU:function(){return s},Xt:function(){return u},cs:function(){return i}});var n=r(8430);function o(){return(0,n.Z)({url:"/api/roles",method:"get"})}function i(t){return(0,n.Z)({url:"/api/roles",method:"post",data:t})}function a(){return(0,n.Z)({url:"/api/permissions",method:"get"})}function s(t,e){return(0,n.Z)({url:`/api/roles/${t}/permissions`,method:"post",data:e})}function u(){return(0,n.Z)({url:"/api/user/user_roles",method:"get"})}},5108:function(t){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAIAAAADehTSAAAAAXNSR0IArs4c6QAABYhJREFUaN7tmv1PW1UYx/svAKIx8SUx+stM9FfdjIkJi/EHMzUzcbpf1LHNiUaX6UwBF8jI3Aiii04jExoGGmCLYhV5GWXjRbpSBCzv671toS29fbl9oW/33nNan0u7An2jve1Fm3DypGkPbe/nfs/3PM85p0jChdMke6x7rHuse6x5/K5Qsvb/YgUghrQ7Lw+vHW1befYr3WPndQ/V6B6vM5ZdsVf3BBcs+SKW5KhiYMpoPtxCllYRxZUQ5JaIviytpk50cNb13IklwkkxphuGyPurI5Tpw/BU
//# sourceMappingURL=200.fbda0d79.js.map