浏览代码

fix(password): change password

gemercheung 1 年之前
父节点
当前提交
5e14e8bde3
共有 4 个文件被更改,包括 46 次插入19 次删除
  1. 2 0
      src/request/URL.ts
  2. 18 0
      src/request/users.ts
  3. 12 8
      src/view/layout/nav.vue
  4. 14 11
      src/view/users-password-edit.vue

+ 2 - 0
src/request/URL.ts

@@ -41,6 +41,8 @@ export const getUserInfoById = `/relics/user/info/:id`;
 export const userScenepage = `/relics/user/page`;
 
 export const getMsgAuthCode = `/relics/user/getMsgAuthCode`;
+export const changePassword = `/relics/user/changePassword`
+
 
 ///drawing
 

+ 18 - 0
src/request/users.ts

@@ -52,6 +52,23 @@ export const updateUserStatusFetch = (params: Pick<UserType, 'userId' | 'status'
         method: "post",
         body: JSON.stringify(params),
     });
+
+type changePasswordParam = Pick<UserType, 'confirmPwd' | 'msgAuthCode' | 'password'> & {
+    phoneNum: string
+}
+export const changePassword = (params: changePasswordParam) =>
+    sendFetch<ResResult>(URL.changePassword, {
+        method: "post",
+        body: JSON.stringify({
+            confirmPwd: params.confirmPwd,
+            msgAuthCode: params.msgAuthCode,
+            password: params.password,
+            phoneNum: params.phoneNum
+        }),
+    }, {
+        useResult: true
+    });
+
 export const getMsgAuthCode = (areaNum: string,
     phoneNum: string) =>
     sendFetch<ResResult>(URL.getMsgAuthCode, {
@@ -65,3 +82,4 @@ export const getMsgAuthCode = (areaNum: string,
     });
 
 
+

+ 12 - 8
src/view/layout/nav.vue

@@ -36,17 +36,18 @@
 <script setup lang="ts">
 import { Back } from "@element-plus/icons-vue";
 import { router } from "@/router";
-import { computed } from "vue";
+import { computed, reactive } from "vue";
 import { user, logout } from "@/store/user";
 import { errorHook } from "@/request/state";
 import lySlide from "./slide/index.vue";
 import { usersPasswordEdit } from "@/view/quisk";
 import {
   editUserFetch,
-  UserType
+  UserType,
+  changePassword,
 
 } from "@/request";
-import { reactive } from "vue";
+
 
 const name = computed(() => router.currentRoute.value.meta?.navClass as string);
 const routeName = computed(() => router.currentRoute.value.name as string);
@@ -55,7 +56,7 @@ const logoutHandler = () => {
   router.replace({ name: "login" });
 };
 const passwordHandler = async () => {
-  console.log('passwordHandler', user)
+
   const userObj = reactive<UserType>({
     orgName: '',
     createBy: "",
@@ -72,11 +73,14 @@ const passwordHandler = async () => {
     userName: "",
     roleNames: ""
   })
+  const userinfo = {
+    ...userObj,
+    ...user.value,
+    phoneNum: user.value.userName,
+  }
+  console.log('passwordHandler', userinfo)
   await usersPasswordEdit({
-    user: {
-      ...userObj,
-      ...user
-    }, submit: editUserFetch
+    user: userinfo, submit: changePassword
   });
 };
 errorHook.push((code) => {

+ 14 - 11
src/view/users-password-edit.vue

@@ -6,7 +6,7 @@
     </el-form-item>
     <el-form-item label="验证码" prop="msgAuthCode" required>
       <el-input v-model="data.msgAuthCode" style="width: 190px" :maxlength="500" placeholder="请输入" />
-      <el-button type="danger" style="margin-left: 10px" @click="getMsgCode">获取验证码</el-button>
+      <el-button :disabled="isDisableMsg" type="danger" style="margin-left: 10px" @click="getMsgCode">获取验证码</el-button>
     </el-form-item>
     <el-form-item label="密码" prop="password" required>
       <el-input autocomplete="off" readonly onfocus="this.removeAttribute('readonly');" v-model="data.password"
@@ -135,21 +135,24 @@ onMounted(async () => {
 watchEffect(() => {
   if (props.user) {
     data.value = { ...props.user }
+    console.log('data', data)
   }
 })
 
 const getMsgCode = async () => {
-  const res = await getMsgAuthCode('+86', "13750087092")
-  console.log('res', res)
-  let timer = null
-  if (res.success) {
-    timer && clearTimeout(timer)
-    isDisableMsg.value = true
-    timer = setTimeout(() => {
-      isDisableMsg.value = false
-    }, 60 * 1000)
-  }
 
+  const phoneNum = data.value.userName
+  console.log('getMsgCode',phoneNum)
+  const res = await getMsgAuthCode('+86', phoneNum)
+  // console.log('res', res)
+  // let timer = null
+  // if (res.success) {
+  //   timer && clearTimeout(timer)
+  //   isDisableMsg.value = true
+  //   timer = setTimeout(() => {
+  //     isDisableMsg.value = false
+  //   }, 60 * 1000)
+  // }
 }
 
 // const handleSelect = (orgId: number) => {