zhb 11 bulan lalu
induk
melakukan
1b153a660e
2 mengubah file dengan 19 tambahan dan 10 penghapusan
  1. 4 0
      src/api/user.ts
  2. 15 10
      src/views/improve-info.vue

+ 4 - 0
src/api/user.ts

@@ -29,6 +29,10 @@ export const userApi = {
     getUserInfo: () => {
         return $api.post<UserInfo>('/custom/info')
     },
+    // 获取用户信息
+    getUserSingle: () => {
+        return $api.post<UserInfo>('/custom/search/single')
+    },
     //退出登录
     logout: () => {
         return $api.post('/custom/logout', {})

+ 15 - 10
src/views/improve-info.vue

@@ -198,6 +198,7 @@ const infoForm = ref({
     cId: undefined,
 })
 const formData = ref<typeof infoForm.value>({} as any)
+const formDatas = ref<typeof infoForm.value>({} as any)
 const isShow = ref(false)
 
 // 国家选项
@@ -306,6 +307,12 @@ const getInfoForm = () => {
     for (const key of fields) {
         data[key] = customInfo[key] ?? undefined
     }
+    for (const key of fields) {
+        data[key] = formDatas.value[key] ?? undefined
+        console.log(data[key],formDatas.value,112);
+    }
+
+
     data.lastName = convertToPinyin(data.lastName)
     data.firstName = convertToPinyin(data.firstName)
     infoForm.value = { ...data }
@@ -317,24 +324,22 @@ const getUserInfo = async () => {
         return
     }
     try {
-        const res = await userApi.getUserInfo()
+        const res = await userApi.getUserSingle()
 
         if (res.code === 200) {
-            if (res.data.customInfo.uniqueId) {
-                router.push('/')
-            } else {
-                router.push('/improve/info')
-            }
-        } else {
-            showToast(res.msg || '登录失败')
+            console.log(res,1111);
+            formDatas.value = res.data
+            getInfoForm()
+            // userStore.saveUserInfo(res.data)
         }
     } catch (error: any) {
-        showToast(error.message || '登录失败')
+        showToast(error.message || '失败')
     } finally {
     }
 }
 onMounted(() => {
-    getInfoForm()
+    getUserInfo()
+    // getInfoForm()
     isShow.value = false
     getCountryListForSelect()
     getCountry()