diff --git a/pages/login/login.vue b/pages/login/login.vue index 88a3f9e..5c52e1a 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -77,16 +77,23 @@ } try { let res = await handLogin(this.user, RSAencrypt(this.password)) - if (this.saveUser) { - this.$store.dispatch('saveLoginName', this.user) + if (res.code === '200') { + if (this.saveUser) { + this.$store.dispatch('saveLoginName', this.user) + } else { + this.$store.dispatch('delLoginName', '') + } + this.$store.dispatch('saveUserInfo', JSON.stringify(res.data.user)) + this.$store.dispatch('saveToken', res.token) + uni.redirectTo({ + url: '/pages/home/home' + }) } else { - this.$store.dispatch('delLoginName', '') + uni.showToast({ + title: res.msg, + icon: 'none' + }) } - this.$store.dispatch('saveUserInfo', JSON.stringify(res.user.user)) - this.$store.dispatch('saveToken', res.token) - uni.redirectTo({ - url: '/pages/home/home' - }) this.disabled = false } catch (e) { this.disabled = false