| | |
| | | <script> |
| | | import { isvalidUsername } from "@/utils/validate"; |
| | | import { createNamespacedHelpers } from "vuex"; |
| | | import users from "@/api/users"; |
| | | |
| | | const { mapActions } = createNamespacedHelpers("users"); |
| | | export default { |
| | | name: "login", |
| | |
| | | loginForm: { |
| | | username:"", |
| | | password:"", |
| | | // username: "admin", |
| | | // password: "macro123", |
| | | }, |
| | | imgUrl:'', |
| | | loginRules: { |
| | |
| | | }; |
| | | }, |
| | | created() { |
| | | const pic = JSON.parse(localStorage.getItem('pic')); |
| | | const pic = JSON.parse(sessionStorage.getItem('pic')); |
| | | if(pic){ |
| | | this.imgUrl = pic.loginPageIconUrl |
| | | }else{ |
| | | this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/system/portal/logo/search', |
| | | }).then(res => { |
| | | this.imgUrl = res.data.loginPageIconUrl |
| | | }) |
| | | } |
| | | }, |
| | | methods: { |
| | | showPwd() { |
| | | if (!this.pwdType) { |
| | | this.pwdType = true; |
| | | } else { |
| | | this.pwdType = false; |
| | | } |
| | | this.pwdType = !this.pwdType; |
| | | }, |
| | | ...mapActions(["login"]), |
| | | handleLogin() { |
| | |
| | | }) |
| | | .then(function (response) { |
| | | if (response.code === 200) { |
| | | // 设置toke时间 |
| | | // 保存token |
| | | console.log(response); |
| | | localStorage.setItem('token',response.data.token); |
| | | sessionStorage.setItem('token',response.data.token); |
| | | // 保存token |
| | | localStorage.setItem('tokenHead',response.data.tokenHead) |
| | | sessionStorage.setItem('tokenHead',response.data.tokenHead); |
| | | // 保存用户登录名 |
| | | sessionStorage.setItem('name',username); |
| | | // 跳转到首页 |
| | | that.$router.push("/home"); |
| | | }else{ |
| | | that.$refs.loginForm.validate((valid)=>{ |
| | | if(valid){ |
| | | that.$message.error(response.data.message); |
| | | that.$message({ |
| | | type:'warning', |
| | | message:response.message |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | // console.log(response); |
| | | }) |
| | | .catch(function (error) { |
| | | console.log(error); |
| | | }); |
| | | }, |
| | | } |
| | | }, |
| | | }; |
| | | </script> |
| | |
| | | top: 20%; |
| | | right: 5%; |
| | | width: 360px; |
| | | &:deep(.el-input__inner){ |
| | | background-color: #fff !important; |
| | | border: 1px solid #dcdfe6 !important; |
| | | } |
| | | } |
| | | |
| | | .text { |
| | |
| | | .logo>img { |
| | | width: 75px; |
| | | height: 75px; |
| | | border-radius: 4px; |
| | | } |
| | | |
| | | .text-r { |