| | |
| | | <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: { |
| | |
| | | }, |
| | | methods: { |
| | | showPwd() { |
| | | if (!this.pwdType) { |
| | | this.pwdType = true; |
| | | } else { |
| | | this.pwdType = false; |
| | | } |
| | | this.pwdType = !this.pwdType; |
| | | }, |
| | | ...mapActions(["login"]), |
| | | handleLogin() { |
| | |
| | | if (response.code === 200) { |
| | | // 设置toke时间 |
| | | // 保存token |
| | | console.log(response); |
| | | sessionStorage.setItem('token',response.data.token); |
| | | // 保存token |
| | | sessionStorage.setItem('tokenHead',response.data.tokenHead); |
| | |
| | | } |
| | | }) |
| | | } |
| | | // console.log(response); |
| | | }) |
| | | .catch(function (error) { |
| | | console.log(error); |
| | | }); |
| | | }, |
| | | } |
| | | }, |
| | | }; |
| | | </script> |