lifanagju_citu hace 6 meses
padre
commit
5ee83aa6d7

+ 31 - 21
layout/components/authModal/necessaryInfo/index.vue

@@ -20,20 +20,20 @@
         <uni-forms-item name="phone" label="联系电话" required>
           <uni-easyinput placeholder="请输入联系电话" v-model="formData.phone" :inputBorder="false" type="number"></uni-easyinput>
         </uni-forms-item>
-        <uni-forms-item name="email" label="联系邮箱" required>
-          <uni-easyinput v-model="formData.email" placeholder="请输入联系邮箱" />
+        <uni-forms-item name="email" label="常用邮箱" required>
+          <uni-easyinput v-model="formData.email" placeholder="请输入常用邮箱" />
         </uni-forms-item>
         <uni-forms-item required label="出生日期" name="birthday">
           <uni-datetime-picker type="date" return-type="timestamp" v-model="formData.birthday" />
         </uni-forms-item>
         <uni-forms-item name="enterpriseName" label="任职企业名称" required>
-          <uni-easyinput placeholder="请填写任职企业名称(可填暂无)" v-model="formData.enterpriseName" :clear-icon="true" :inputBorder="false" type="text"></uni-easyinput>
+          <uni-easyinput placeholder="请填写任职企业名称(可填暂无)" v-model="formData.enterpriseName" :clear-icon="true" type="text"></uni-easyinput>
         </uni-forms-item>
         <uni-forms-item name="positionName" label="任职职位名称" required>
-          <uni-easyinput placeholder="请填写任职职位名称(可填暂无)" v-model="formData.positionName" :clear-icon="true" :inputBorder="false" type="text"></uni-easyinput>
+          <uni-easyinput placeholder="请填写任职职位名称(可填暂无)" v-model="formData.positionName" :clear-icon="true" type="text"></uni-easyinput>
         </uni-forms-item>
-        <uni-forms-item name="interestedPositionList" label="意向职位" required>
-          <uni-data-picker v-model="formData.interestedPositionList" :localdata="dictObj.positionSecondData" :clear-icon="false" popup-title="请选择意向职位" :map="{ text: 'nameCn', value: 'id' }"></uni-data-picker>
+        <uni-forms-item name="interestedPositionId" label="意向职位" required>
+          <uni-data-picker v-model="formData.interestedPositionId" :localdata="dictObj.positionSecondData" :clear-icon="false" popup-title="请选择意向职位" :map="{ text: 'nameCn', value: 'id' }"></uni-data-picker>
         </uni-forms-item>
         <uni-forms-item name="jobStatus" label="求职状态" required>
           <uni-data-picker v-model="formData.jobStatus" :localdata="dictObj.jobStatus" :clear-icon="false" popup-title="请选择求职状态" :map="{ text: 'label', value: 'value' }"></uni-data-picker>
@@ -59,7 +59,7 @@
   </scroll-view>
 </template>
 <script setup>
-import { ref, unref, watch } from 'vue'
+import { ref, unref, onMounted, nextTick } from 'vue'
 import { mobile, emailRequired } from '@/utils/validate'
 import { dictObj } from '@/utils/position.js'
 import { savePersonSimpleInfo } from '@/api/user'
@@ -75,20 +75,23 @@ const formData = ref({ // 必填项目
   birthday: '1990-01-01',
   enterpriseName: null,
   positionName: null,
-  interestedPositionList: null,
+  interestedPositionId: null,
   jobStatus: null,
   expType: null,
   eduType: null,
 })
 
-// 监听登录状态
-watch(() => useUserStore?.baseInfo, (newVal) => {
-  if (newVal && Object.keys(newVal).length) {
-    Object.keys(formData.value).forEach(key => {
-      formData.value[key] = newVal[key] || newVal[key] === 0 ? newVal[key] : null
-    })
-  }
-}, { deep: true, immediate: true })
+onMounted(() => {
+  nextTick(() => {
+    const baseInfo = useUserStore?.baseInfo || null
+    console.log('baseInfo:', baseInfo)
+    if (baseInfo && Object.keys(baseInfo).length) {
+      Object.keys(formData.value).forEach(key => {
+        formData.value[key] = baseInfo[key] || baseInfo[key] === 0 ? baseInfo[key] : formData.value[key] ? formData.value[key] : null
+      })
+    }
+  })
+})
 
 const formRules = {
 	name:{
@@ -129,22 +132,29 @@ const handleLogoutClose = () => {
 }
 const handleLogoutConfirm = async () => {
   await useUserStore.handleLogout()
-  // necessaryInfoPopup.value.close()
   showAuthModal()
 }
 
+const dealQuery = () => {
+  const interestedList = [{ positionId: formData.value.interestedPositionId || null }]
+  const workExpList = [{
+    enterpriseName: formData.value.enterpriseName || null,
+    positionName: formData.value.positionName || null,
+  }]
+  return { ...formData.value, interestedList, workExpList }
+}
 const submit = async () => {
   const validate = await unref(baseInfoRef).validate()
   if (!validate) return uni.showToast({ title: '请将信息补充完整', icon: 'none' })
-  if (!formData.value.email) return uni.showToast({ title: '请输入邮箱', icon: 'none' })
-  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.value.email)) return uni.showToast({ title: '邮箱格式不正确', icon: 'none' })
+  
   try {
-    // console.log(1, '23456', formData.value)
-    await savePersonSimpleInfo(formData.value)
+    const query = dealQuery()
+    await savePersonSimpleInfo(query)
     uni.showToast({ title: '保存成功', icon: 'none' })
     await useUserStore.getInfo()
     // await useUserStore.getUserInfo()
   } catch (err) {
+    console.log('err:', err)
     uni.showToast({ title: err.msg || '保存失败', icon: 'none' })
   }
 }

+ 4 - 2
pages/login/index.vue

@@ -196,8 +196,11 @@ const handleLogin = async () => {
   }
   const result = await useUserStore.handleShareUserRegister(state.value.sms)
   if (!result || !Object.keys(result).length) return
+  uni.switchTab({
+    url: '/pages/index/my'
+  })
   
-  uni.showToast({ icon: 'none', title: '请先完善信息' })
+  // uni.showToast({ icon: 'none', title: '请先完善信息' })
   // formData.value.phone = state.value.sms.phone
   // popup.value.open()
 }
@@ -206,7 +209,6 @@ const handleLogin = async () => {
 //   const validate = await unref(baseInfoRef).validate()
 //   if (!validate) return uni.showToast({ title: '请将信息补充完整', icon: 'none' })
 //   try {
-//     await savePersonSimpleInfo(formData.value)
 //     uni.showToast({ title: '保存成功', icon: 'none' })
 //     await useUserStore.getInfo()
 //     await useUserStore.getUserInfo()

+ 3 - 1
pagesA/info/index.vue

@@ -21,7 +21,7 @@
       <uni-forms-item label="联系电话" name="phone">
         <uni-easyinput v-model="formData.phone" placeholder="请输入电话号码" />
 			</uni-forms-item>
-      <uni-forms-item label="常用邮箱" name="email">
+      <uni-forms-item label="常用邮箱" name="email" required>
         <uni-easyinput v-model="formData.email" placeholder="请输入常用邮箱" />
 			</uni-forms-item>
       <uni-forms-item required label="出生日期" name="birthday">
@@ -65,6 +65,7 @@ import { dictObj } from '@/utils/position.js'
 import { uploadFile } from '@/api/file'
 import { cloneDeep } from 'lodash-es'
 import { saveBaseInfo, updatePersonAvatar } from '@/api/user'
+import { emailRequired } from '@/utils/validate'
 
 const form = ref()
 const sexData = ref([])
@@ -137,6 +138,7 @@ const rules = {
 	birthday: {
 		rules: [{required: true, errorMessage: '请选择您的出生日期' }]
 	},
+  email: emailRequired,
   expType: {
 		rules: [{required: true, errorMessage: '请选择您的工作年限' }]
 	},

+ 3 - 1
pagesA/resumeOnline/baseInfoEdit.vue

@@ -21,7 +21,7 @@
       <uni-forms-item label="联系电话" name="phone" clearable>
         <uni-easyinput v-model="formData.phone" placeholder="请输入电话号码" />
 			</uni-forms-item>
-      <uni-forms-item label="常用邮箱" name="email" clearable>
+      <uni-forms-item label="常用邮箱" name="email" clearable required>
         <uni-easyinput v-model="formData.email" placeholder="请输入常用邮箱" />
 			</uni-forms-item>
       <uni-forms-item required label="出生日期" name="birthday">
@@ -65,6 +65,7 @@ import { dictObj } from '@/utils/position.js'
 import { uploadFile } from '@/api/file'
 import { cloneDeep } from 'lodash-es'
 import { saveBaseInfo, updatePersonAvatar } from '@/api/user'
+import { emailRequired } from '@/utils/validate'
 
 const form = ref()
 const sexData = ref([])
@@ -152,6 +153,7 @@ const rules = {
 	birthday: {
 		rules: [{required: true, errorMessage: '请选择您的出生日期' }]
 	},
+  email: emailRequired,
   expType: {
 		rules: [{required: true, errorMessage: '请选择您的工作年限' }]
 	},

+ 6 - 4
store/user.js

@@ -67,7 +67,7 @@ export const userStore = defineStore('user', {
     },
 
     async handleRegister (query) {
-      phone = query?.phone || ''
+      phone = query.phone || ''
       const { data, code } = await userRegister(query)
       if (code === 0) {
         uni.showToast({
@@ -82,7 +82,7 @@ export const userStore = defineStore('user', {
     // 扫码注册登录
     async handleShareUserRegister (query) {
       try {
-        phone = query?.phone || ''
+        phone = query.phone || ''
         const { data, code } = await shareUserRegister(query)
         if (code === 0) {
           uni.showToast({
@@ -103,7 +103,8 @@ export const userStore = defineStore('user', {
 
     // 校验是否完善人才必填信息
     checkPersonBaseInfoFun(data) {
-      data = data || { phone }
+      data = data || {}
+      if (phone && !data.phone) data.phone = phone; data.mobile = phone
       const necessaryInfoReady = checkPersonBaseInfo(data)
       data.necessaryInfoReady = necessaryInfoReady
       if (necessaryInfoReady) closeAuthModal()
@@ -115,13 +116,14 @@ export const userStore = defineStore('user', {
     async getInfo() {
       const { code, data } = await getBaseInfo({ userId: this.accountInfo.userId });
       updateEventList() // 更新事件列表
-      this.checkPersonBaseInfoFun(data) // 校验是否完善人才必填信息
+      await this.checkPersonBaseInfoFun(data) // 校验是否完善人才必填信息
       if (code !== 0) {
         return;
       }
       if (!data) return
       const _data = await this.getFieldText(data)
       this.baseInfo = _data
+      console.log('baseInfo:', _data)
       return Promise.resolve(data);
     },
     // 获取用户信息