|
|
@@ -7,7 +7,7 @@ import showMessage from '@/server/utils/show-message'
|
|
|
import showErrorMessage from '@/server/utils/show-error-message'
|
|
|
import catchHandler from '@/server/utils/catch-handler'
|
|
|
|
|
|
-export function register({ name, email, emailCode, phone, phoneCode, password }) {
|
|
|
+export function register ({ name, email, emailCode, phone, phoneCode, password }) {
|
|
|
const data = {
|
|
|
name,
|
|
|
email,
|
|
|
@@ -34,7 +34,7 @@ export function register({ name, email, emailCode, phone, phoneCode, password })
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function emailLogin({ email, password }) {
|
|
|
+export function emailLogin ({ email, password }) {
|
|
|
const data = {
|
|
|
username: email,
|
|
|
password
|
|
|
@@ -45,14 +45,17 @@ export function emailLogin({ email, password }) {
|
|
|
.then(res => {
|
|
|
const resourceResponse = res.data
|
|
|
if (resourceResponse.code === httpCode.success) {
|
|
|
+ showMessage({ message: '欢迎回来,' + resourceResponse.data.name })
|
|
|
return resourceResponse.data
|
|
|
} else {
|
|
|
- // TODO
|
|
|
+ showErrorMessage(resourceResponse.msg)
|
|
|
}
|
|
|
+ }).catch(() => {
|
|
|
+ catchHandler()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function logout() {
|
|
|
+export function logout () {
|
|
|
return axios
|
|
|
.post(useUserServer('/logout'))
|
|
|
.then(res => {
|
|
|
@@ -65,7 +68,7 @@ export function logout() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function modifyUser({ name, password }) {
|
|
|
+export function modifyUser ({ name, password }) {
|
|
|
const data = {
|
|
|
name,
|
|
|
password
|
|
|
@@ -80,7 +83,7 @@ export function modifyUser({ name, password }) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function getUserInfo() {
|
|
|
+export function getUserInfo () {
|
|
|
return axios
|
|
|
.get(useUserServer())
|
|
|
.then(res => {
|