浏览代码

个人中心-获取学生信息

Xiao_123 2 月之前
父节点
当前提交
b12ffd7027

+ 3 - 0
components.d.ts

@@ -74,4 +74,7 @@ declare module 'vue' {
     VerifySlide: typeof import('./src/components/Verifition/Verify/VerifySlide.vue')['default']
     WangEditor: typeof import('./src/components/FormUI/wangEditor/index.vue')['default']
   }
+  export interface ComponentCustomProperties {
+    vLoading: typeof import('element-plus/es')['ElLoadingDirective']
+  }
 }

+ 1 - 1
src/store/user.js

@@ -259,7 +259,7 @@ export const useUserStore = defineStore('user',
         try {
           const data = await getStudentInfo()
           this.studentInfo = data
-          localStorage.setItem('studentInfo', JSON.stringify(data))
+          localStorage.setItem('studentInfo', data ? JSON.stringify(data) : '{}')
         } catch (error) {
           Snackbar.error(error.msg)
         }

+ 4 - 1
src/views/recruit/personal/PersonalCenter/index.vue

@@ -53,12 +53,16 @@ import { getCurrentLocaleLang } from '@/utils/lang.js'
 import personCenterRoute from '@/router/modules/components/recruit/personCenter'
 import { useUserStore } from '@/store/user'
 
+const userStore = useUserStore()
 const info = localStorage.getItem('baseInfo') ? JSON.parse(localStorage.getItem('baseInfo')) : {}
 
 const menuHide = { // 是否隐藏
   studentInformation: (info?.type && Number(info.type) !== 1) // 学生信息管理。 type:0是求职者,1是学生
 }
 
+// 是学生则获取详情
+if (info?.type && Number(info.type) === 1 && !localStorage.getItem('studentInfo')) userStore.getStudentInformation()
+
 // 左侧菜单列表
 const list = computed(() => {
   return getList(personCenterRoute[0].children[0].children)
@@ -88,7 +92,6 @@ const getList = (arr, obj = []) => {
   return obj
 }
 
-const userStore = useUserStore()
 // 更新账户信息
 const updateAccountInfo = async () => {
   await userStore.getUserAccountInfo()

+ 5 - 5
src/views/recruit/personal/PersonalCenter/student/information/index.vue

@@ -16,13 +16,14 @@
 defineOptions({name: 'personal-personCenter-studentInformation-index'})
 import { ref } from 'vue'
 import { saveStudentSimpleInfo } from '@/api/recruit/personal/shareJob'
-import { schoolList, departmentList, getStudentInfo } from '@/api/recruit/personal/resume'
+import { schoolList, departmentList } from '@/api/recruit/personal/resume'
 import { useI18n } from '@/hooks/web/useI18n'
 import Snackbar from '@/plugins/snackbar'
 import { isValidIdCard18 } from '@/utils/validate'
+import { useUserStore } from '@/store/user'
 
 const { t } = useI18n()
-
+const userStore = useUserStore()
 const overlay = ref(false)
 
 const CtFormRef = ref()
@@ -149,8 +150,7 @@ const getDepartmentList = async (e) => {
 
 // 获取学生基本信息
 const getStudentInfoFun = async () => {
-  const data = await getStudentInfo()
-  localStorage.setItem('studentInfo', data ? JSON.stringify(data) : '{}')
+  const data = JSON.parse(localStorage.getItem('studentInfo') || '{}')
   if (data.schoolId) getDepartmentList(data.schoolId)
   // 回显
   items.value.options.forEach(e => {
@@ -170,8 +170,8 @@ const handleSubmit = async () => {
     params[item.key] = item.value
   })
   await saveStudentSimpleInfo(params)
-  // getStudentInfoFun()
   setTimeout(async () => {
+    await userStore.getStudentInformation()
     Snackbar.success(t('common.submittedSuccessfully'))
     overlay.value = false
   }, 1000)