mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
登录注册功能
This commit is contained in:
parent
9ae23571be
commit
e0768dace1
2 changed files with 28 additions and 14 deletions
|
|
@ -75,6 +75,16 @@ export default {
|
||||||
})
|
})
|
||||||
.fail((err) => { // 添加错误参数
|
.fail((err) => { // 添加错误参数
|
||||||
|
|
||||||
|
}).send()
|
||||||
|
}, // 登录
|
||||||
|
register(registerForm, callback) {
|
||||||
|
RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/register`).method('POST')
|
||||||
|
.data(registerForm)
|
||||||
|
.success((res) => {
|
||||||
|
RequestService.clearRequestTime()
|
||||||
|
callback(res)
|
||||||
|
})
|
||||||
|
.fail(() => {
|
||||||
}).send()
|
}).send()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,21 +138,25 @@ export default {
|
||||||
showDanger('验证码不能为空')
|
showDanger('验证码不能为空')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Api.user.register({
|
||||||
|
username: this.form.username,
|
||||||
|
password: this.form.password,
|
||||||
|
captcha: this.form.captcha,
|
||||||
|
uuid: this.captchaUuid
|
||||||
|
}).then(response => {
|
||||||
|
if (response.data.code === 200) {
|
||||||
|
showSuccess('注册成功!')
|
||||||
|
goToPage('/login')
|
||||||
|
} else {
|
||||||
|
showDanger(response.data.msg || '注册失败')
|
||||||
|
this.fetchCaptcha()
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
const msg = error.response?.data?.msg || '注册失败'
|
||||||
|
showDanger(msg)
|
||||||
|
this.fetchCaptcha() // 自动刷新验证码
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
|
||||||
await api.post('/user/register', {
|
|
||||||
username: this.form.username,
|
|
||||||
password: this.form.password,
|
|
||||||
captcha: this.form.captcha,
|
|
||||||
uuid: this.captchaUuid
|
|
||||||
})
|
|
||||||
showSuccess('注册成功!')
|
|
||||||
goToPage('/login')
|
|
||||||
} catch (error) {
|
|
||||||
const msg = error.response?.data?.msg || '注册失败'
|
|
||||||
showDanger(msg)
|
|
||||||
this.fetchCaptcha()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
goToLogin() {
|
goToLogin() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue