| | |
| | | |
| | | <script> |
| | | import { isvalidUsername } from "@/utils/validate"; |
| | | |
| | | import { createNamespacedHelpers } from "vuex"; |
| | | const { mapActions } = createNamespacedHelpers("users"); |
| | | export default { |
| | | name: "login", |
| | | data() { |
| | |
| | | }; |
| | | return { |
| | | loginForm: { |
| | | username: "", |
| | | password: "", |
| | | username: "admin", |
| | | password: "macro123", |
| | | }, |
| | | loginRules: { |
| | | username: [ |
| | |
| | | pwdType: false, |
| | | }; |
| | | }, |
| | | created() { |
| | | // this.loginForm.username = getCookie("username"); |
| | | // this.loginForm.password = getCookie("password"); |
| | | // if ( |
| | | // this.loginForm.username === undefined || |
| | | // this.loginForm.username == null || |
| | | // this.loginForm.username === "" |
| | | // ) { |
| | | // this.loginForm.username = "admin"; |
| | | // } |
| | | // if ( |
| | | // this.loginForm.password === undefined || |
| | | // this.loginForm.password == null |
| | | // ) { |
| | | // this.loginForm.password = ""; |
| | | // } |
| | | }, |
| | | created() {}, |
| | | methods: { |
| | | showPwd() { |
| | | if (!this.pwdType) { |
| | |
| | | this.pwdType = false; |
| | | } |
| | | }, |
| | | ...mapActions(["login"]), |
| | | handleLogin() { |
| | | this.$router.push({ path: "/home" }); |
| | | // this.$refs.loginForm.validate((valid) => { |
| | | // if (valid) { |
| | | // console.log(valid); |
| | | // this.loading = true; |
| | | // this.$store |
| | | // .dispatch("Login", this.loginForm) |
| | | // .then(() => { |
| | | // this.loading = false; |
| | | // setCookie("username", this.loginForm.username, 15); |
| | | // setCookie("password", this.loginForm.password, 15); |
| | | // this.$router.push({ path: "/" }); |
| | | // }) |
| | | // .catch(() => { |
| | | // this.loading = false; |
| | | // }); |
| | | // } else { |
| | | // console.log("参数验证不合法!"); |
| | | // return false; |
| | | // } |
| | | // }); |
| | | console.log("in login"); |
| | | const { username, password } = this.loginForm; |
| | | this.$axios |
| | | .post("http://42.193.1.25:8082/sccg/admin/login", { |
| | | password, |
| | | username, |
| | | }) |
| | | .then(function (response) { |
| | | console.log(response); |
| | | }) |
| | | .catch(function (error) { |
| | | console.log(error); |
| | | }); |
| | | }, |
| | | }, |
| | | }; |
| | |
| | | } |
| | | .login-form-layout { |
| | | position: absolute; |
| | | top: 20%; |
| | | right: 5%; |
| | | width: 360px; |
| | | align-self: center; |
| | | } |
| | | .text { |
| | | align-self: flex-start; |
| | | position: absolute; |
| | | top:20%; |
| | | left: 5%; |
| | | // margin-top: 180px; |
| | | // margin-left: 50px; |
| | | display: flex; |
| | | width: 400px; |
| | | justify-content: space-between; |