|
|
@@ -66,6 +66,8 @@ import { mapState } from 'vuex'
|
|
|
import Cookies from "js-cookie"
|
|
|
import ThemePicker from "@/components/ThemePicker"
|
|
|
import LangSelector from "@/components/LangSelector"
|
|
|
+import { login } from '@/api/user'
|
|
|
+
|
|
|
export default {
|
|
|
name: 'Login',
|
|
|
components: {
|
|
|
@@ -124,8 +126,26 @@ export default {
|
|
|
password: this.loginForm.password,
|
|
|
captcha: this.loginForm.captcha.toLowerCase()
|
|
|
}
|
|
|
+
|
|
|
+ // this.$store.dispatch('login', userInfo)
|
|
|
+ // .then(() => {
|
|
|
+ // if (this.rememberPassword) { //是否保存密码
|
|
|
+ // Cookies.set('accountInfo', { 'account': this.loginForm.account, 'password': this.loginForm.password, })
|
|
|
+ // } else {
|
|
|
+ // Cookies.remove('accountInfo')
|
|
|
+ // }
|
|
|
+ // Cookies.set('user', userInfo.account) /
|
|
|
+ // sessionStorage.setItem('user', userInfo.account) // 保存用户到本地会话
|
|
|
+ // this.$store.commit('menuRouteLoaded', false) // 要求重新加载导航菜单
|
|
|
+ // this.$router.push('/')
|
|
|
+ // this.loading = false
|
|
|
+ // })
|
|
|
+ // .catch(() => {
|
|
|
+ // this.loading = false
|
|
|
+ // })
|
|
|
+
|
|
|
this.$api.login.login(userInfo).then((res) => {
|
|
|
- if (res.msg != null) {
|
|
|
+ if (res.code != 200) {
|
|
|
this.$message({
|
|
|
message: res.msg,
|
|
|
type: 'error',
|
|
|
@@ -137,7 +157,7 @@ export default {
|
|
|
} else {
|
|
|
Cookies.remove('accountInfo')
|
|
|
}
|
|
|
- Cookies.set('token', res.data.token, { expires: 1, }) // 放置token到Cookie
|
|
|
+ Cookies.set('token', res.data) // 放置token到Cookie
|
|
|
Cookies.set('user', userInfo.account) // 放置token到Cookie
|
|
|
sessionStorage.setItem('user', userInfo.account) // 保存用户到本地会话
|
|
|
this.$store.commit('menuRouteLoaded', false) // 要求重新加载导航菜单
|
|
|
@@ -151,9 +171,38 @@ export default {
|
|
|
duration: 2000
|
|
|
})
|
|
|
});
|
|
|
+
|
|
|
+ // this.$api.login.login(userInfo).then((res) => {
|
|
|
+ // if (res.msg != null) {
|
|
|
+ // this.$message({
|
|
|
+ // message: res.msg,
|
|
|
+ // type: 'error',
|
|
|
+ // duration: 2000
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // if (this.rememberPassword) { //是否保存密码
|
|
|
+ // Cookies.set('accountInfo', { 'account': this.loginForm.account, 'password': this.loginForm.password, })
|
|
|
+ // } else {
|
|
|
+ // Cookies.remove('accountInfo')
|
|
|
+ // }
|
|
|
+ // Cookies.set('token', res.data.token, { expires: 1, }) // 放置token到Cookie
|
|
|
+ // Cookies.set('user', userInfo.account) // 放置token到Cookie
|
|
|
+ // sessionStorage.setItem('user', userInfo.account) // 保存用户到本地会话
|
|
|
+ // this.$store.commit('menuRouteLoaded', false) // 要求重新加载导航菜单
|
|
|
+ // this.$router.push('/') // 登录成功,跳转到主页
|
|
|
+ // }
|
|
|
+ // this.loading = false
|
|
|
+ // }).catch((res) => {
|
|
|
+ // this.$message({
|
|
|
+ // message: res.message,
|
|
|
+ // type: 'error',
|
|
|
+ // duration: 2000
|
|
|
+ // })
|
|
|
+ // });
|
|
|
},
|
|
|
refreshCaptcha() {
|
|
|
this.loginForm.src = this.global.baseUrl + "/captcha.jpg?t=" + new Date().getTime();
|
|
|
+ // this.loginForm.src = process.env.BASE_URL + "/captcha.jpg?t=" + new Date().getTime();
|
|
|
},
|
|
|
reset() {
|
|
|
this.$refs.loginForm.resetFields()
|