chillqi %!s(int64=2) %!d(string=hai) anos
pai
achega
33945a8060
Modificáronse 4 ficheiros con 17 adicións e 25 borrados
  1. 9 9
      src/api/user.ts
  2. 4 8
      src/views/user/Dashboard.vue
  3. 2 4
      src/views/user/Login.vue
  4. 2 4
      src/views/user/Register.vue

+ 9 - 9
src/api/user.ts

@@ -1,12 +1,12 @@
 import {axios} from '../utils/request'
 import {USER_MODULE} from './_prefix'
 
-type loginInfo = {
+type LoginInfo = {
     phone: string,
     password: string
 }
 
-type registerInfo = {
+type RegisterInfo = {
     role: string,
     name: string,
     phone: string,
@@ -15,23 +15,23 @@ type registerInfo = {
     createTime: string
 }
 
-type updateInfo = {
+type UpdateInfo = {
     name: string,
     password: string,
     address: string,
 }
 
 // 用户登录
-export const userLogin = (payload: loginInfo) => {
-    return axios.post(`${USER_MODULE}/login`,null, {params: payload})
+export const userLogin = (loginInfo: LoginInfo) => {
+    return axios.post(`${USER_MODULE}/login`,null, {params: loginInfo})
         .then(res => {
             return res
         })
 }
 
 // 用户注册
-export const userRegister = (payload: registerInfo) => {
-    return axios.post(`${USER_MODULE}/register`, payload,
+export const userRegister = (registerInfo: RegisterInfo) => {
+    return axios.post(`${USER_MODULE}/register`, registerInfo,
                     {headers: {'Content-Type': 'application/json'}})
         .then(res => {
             return res
@@ -47,8 +47,8 @@ export const userInfo = () => {
 }
 
 // 更新用户信息
-export const userInfoUpdate = (payload: updateInfo) => {
-    return axios.post(`${USER_MODULE}`, payload, {headers: {'Content-Type': 'application/json'}})
+export const userInfoUpdate = (updateInfo: UpdateInfo) => {
+    return axios.post(`${USER_MODULE}`, updateInfo, {headers: {'Content-Type': 'application/json'}})
         .then(res => {
             return res
         })

+ 4 - 8
src/views/user/Dashboard.vue

@@ -37,13 +37,11 @@ function getUserInfo() {
 }
 
 function updateInfo() {
-  const payload = {
+  userInfoUpdate({
     name: newName.value,
     password: null,
     address: address.value,
-  }
-
-  userInfoUpdate(payload).then(res => {
+  }).then(res => {
     if (res.code === '000') {
       ElMessage({
         customClass: 'customMessage',
@@ -62,13 +60,11 @@ function updateInfo() {
 }
 
 function updatePassword() {
-  const payload = {
+  userInfoUpdate({
     name: null,
     password: password.value,
     address: null
-  }
-
-  userInfoUpdate(payload).then(res => {
+  }).then(res => {
     if (res.code === '000') {
       password.value = ''
       confirmPassword.value = ''

+ 2 - 4
src/views/user/Login.vue

@@ -23,12 +23,10 @@ const loginDisabled = computed(() => {
 
 // 登录按钮触发
 function handleLogin() {
-  const payload = {
+  userLogin({
     phone: tel.value,
     password: password.value
-  }
-
-  userLogin(payload).then(res => {
+  }).then(res => {
     if (res.code === '000') {
       ElMessage({
         message: "登录成功!",

+ 2 - 4
src/views/user/Register.vue

@@ -34,16 +34,14 @@ const registerDisabled = computed(() => {
 
 // 注册按钮触发
 function handleRegister() {
-  const payload = {
+  userRegister({
     role: identity.value,
     name: name.value,
     phone: tel.value,
     password: password.value,
     address: address.value,
     createTime: new Date().getTime()
-  }
-
-  userRegister(payload).then(res => {
+  }).then(res => {
     if (res.code === '000') {
       ElMessage({
         message: "注册成功!请登录账号",