Browse Source

用户注册选择角色,在校学生和职场人士必填表单不同,学生信息认证

lifanagju_citu 2 tháng trước cách đây
mục cha
commit
ebc6be00d6

+ 27 - 0
api/pickerData.js

@@ -0,0 +1,27 @@
+import request from "@/utils/request"
+
+// 学校列表
+export const schoolList = (data) => {
+  return request({
+    url: '/app-api/flames/school/list',
+    method: 'POST',
+    data,
+    custom: {
+      showLoading: false,
+      auth: false
+    }
+  })
+}
+
+// 院系列表
+export const departmentList = (data) => {
+  return request({
+    url: '/app-api/flames/school/department/list',
+    method: 'POST',
+    data,
+    custom: {
+      showLoading: false,
+      auth: false
+    }
+  })
+}

+ 26 - 0
api/user.js

@@ -377,3 +377,29 @@ export const savePersonSimpleInfo = (data) => {
     }
   })
 }
+
+// 保存学生基本信息
+export const saveStudentSimpleInfo = (data) => {
+  return request({
+    url: '/app-api/menduner/system/person/resume/student/save',
+    method: 'POST',
+    data,
+    custom: {
+      auth: true,
+      showLoading: false
+    }
+  })
+}
+
+// 获取学生基本信息
+export const getStudentInfo = (data) => {
+  return request({
+    url: '/app-api/menduner/system/person/resume/student/get',
+    method: 'POST',
+    data,
+    custom: {
+      auth: true,
+      showLoading: false
+    }
+  })
+}

+ 5 - 1
layout/components/auth-modal.vue

@@ -5,7 +5,10 @@
       <login></login>
     </ct-popup>
     <ct-popup :show="authType === 'necessaryInfo'" round="0" :showClose="false" @close="closeAuthModal">
-      <necessaryInfo ></necessaryInfo>
+      <necessaryInfo></necessaryInfo>
+    </ct-popup>
+    <ct-popup :show="authType === 'selectUserType'" round="0" :showClose="false" @close="closeAuthModal">
+      <selectUserType></selectUserType>
     </ct-popup>
   </view>
 </template>
@@ -16,6 +19,7 @@ import ctPopup from '@/components/ui/ct-popup'
 import { modalStore } from '@/store/modal';
 import login from './authModal/login'
 import necessaryInfo from './authModal/necessaryInfo'
+import selectUserType from './authModal/selectUserType'
 
 
 const modal = modalStore()

+ 59 - 0
layout/components/authModal/selectUserType/index.vue

@@ -0,0 +1,59 @@
+<!-- 选择是否是学生 -->
+<template>
+  <scroll-view class="scrollBox" scroll-y="true">
+    <template v-if="showSelect">
+      <view class="text-center ss-m-t-50" style="color: #666; font-weight: 400; font-size: 18px">请选择当前角色</view>
+      <view class="ss-p-50">
+        <uni-card class="ss-m-t-30" @tap="handleClickRole(0)">
+          <view class="d-flex flex-column align-center ss-p-y-50">
+            <image src="/static/svg/workMan.svg" class="svg ss-m-l-10"></image>
+            <view class="color-primary text-center" style="font-size: 24px">职场人士</view>
+          </view>
+        </uni-card>
+        <uni-card class="ss-m-t-80" @tap="handleClickRole(1)">
+          <view class="d-flex flex-column align-center ss-p-y-50">
+            <image src="/static/svg/student.svg" class="svg ss-m-l-10"></image>
+            <view class="color-primary text-center" style="font-size: 24px">在校学生</view>
+          </view>
+        </uni-card>
+      </view>
+    </template>
+    <template v-else>
+      <studentInfoForm></studentInfoForm>
+    </template>
+  </scroll-view>
+</template>
+
+<script setup>
+import { ref } from 'vue'
+import studentInfoForm from './studentInfoForm.vue'
+import { showAuthModal } from '@/hooks/useModal'
+
+const showSelect = ref(true)
+
+const handleClickRole = (type) => {
+  if (type) {
+    // 学生用户
+    showSelect.value = false
+  } else {
+    // 普通用户
+    showAuthModal('necessaryInfo')
+    uni.setStorageSync('necessaryInfoReady', 'fddeaddc47868b')
+  }
+}
+
+</script>
+<style lang="scss" scoped>
+.scrollBox {
+  width: 100vw;
+  // height: 100vh;
+  height: calc(100vh - 30rpx);
+  margin-bottom: 30rpx;
+}
+
+.svg {
+  width: 100px;
+  height: 100px;
+  margin-bottom: 30px;
+}
+</style>

+ 270 - 0
layout/components/authModal/selectUserType/studentInfoForm.vue

@@ -0,0 +1,270 @@
+<!-- 校验是否完善人才必填信息 -->
+<template>
+  <scroll-view class="scrollBox" scroll-y="true">
+    <view class="content">
+      <view class="text-center ss-m-b-50 font-size-20 color-primary">请完善学生信息</view>
+      <uni-forms
+        ref="baseInfoRef"
+        v-model="formData"
+        :rules="formRules"
+        validateTrigger="bind"
+        label-width="90px"
+        labelAlign="center"
+      >
+        <uni-forms-item label="头像" name="avatar" class="f-straight" required>
+          <view style="display: flex;flex-wrap: wrap;">
+            <view class="upload-img" v-if="formData?.avatar">
+              <uni-icons size="35" type="clear" color="#fe574a" style="position: absolute;right: -15px; top: -15px; z-index: 9" @click="formData.avatar = ''"></uni-icons>
+              <image :src="formData?.avatar" mode="contain" style="width: 200rpx;height: 200rpx;" @click="handlePreviewImage"></image>
+            </view>
+            <view v-else class="upload-file" @click="uploadPhotos">
+              <uni-icons type="plusempty" size="50" color="#f1f1f1"></uni-icons>
+            </view>
+          </view>
+        </uni-forms-item>
+        <uni-forms-item name="name" label="姓名" required>
+          <uni-easyinput placeholder="请输入姓名" v-model="formData.name" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="sex" label="性别" required>
+          <uni-data-picker v-model="formData.sex" :localdata="dictObj.sex" :clear-icon="false" popup-title="请选择性别" :map="{ text: 'label', value: 'value' }"></uni-data-picker>
+        </uni-forms-item>
+        <uni-forms-item name="idCardNo" label="身份证号码" required>
+          <uni-easyinput placeholder="请输入身份证号码" v-model="formData.idCardNo" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <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 required label="出生日期" name="birthday">
+          <uni-datetime-picker type="date" return-type="timestamp" v-model="formData.birthday" />
+        </uni-forms-item>
+        <uni-forms-item name="schoolId" label="就读学校" required>
+          <uni-data-picker v-model="formData.schoolId" :localdata="schools" :clear-icon="false" popup-title="请选择就读学校" @change="getDepartmentList" :map="{ text: 'schoolName', value: 'schoolId' }"></uni-data-picker>
+        </uni-forms-item>
+        <uni-forms-item name="schoolDepartmentName" label="所在院系" required>
+          <uni-data-picker v-model="formData.schoolDepartmentName" :localdata="schoolDepartmentList" :clear-icon="false" popup-title="请选择所在院系" :map="{ text: 'departmentTitle', value: 'schoolDepartmentId' }"></uni-data-picker>
+        </uni-forms-item>
+        <uni-forms-item name="majorName" label="所学专业" required>
+          <uni-easyinput placeholder="请输入所学专业" v-model="formData.majorName" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="schoolClassName" label="所在班级" required>
+          <uni-easyinput placeholder="请填写所在班级" v-model="formData.schoolClassName" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="studentNo" label="学号" required>
+          <uni-easyinput placeholder="请填写学号" v-model="formData.studentNo" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="emergencyContactName" label="紧急联系人姓名" required>
+          <uni-easyinput placeholder="请填写紧急联系人姓名" v-model="formData.emergencyContactName" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="emergencyContactPhone" label="紧急联系人手机号" required>
+          <uni-easyinput placeholder="请填写紧急联系人手机号" v-model="formData.emergencyContactPhone" :inputBorder="false" type="number"></uni-easyinput>
+        </uni-forms-item>
+      </uni-forms>
+      <view class="f-horizon-center">
+        <button type="primary" size="default" class="send-button" @click="submit">提 交</button>
+      </view>
+      <view class="f-horizon-center">
+        <view class="changeRole" @tap="handleLogout">退出登录</view>
+      </view>
+    </view>
+    <uni-popup ref="logoutPopup" type="dialog">
+      <uni-popup-dialog type="warn" cancelText="取消" confirmText="确定" title="系统提示" content="确认退出账号?" @confirm="handleLogoutConfirm" @close="handleLogoutClose">
+      </uni-popup-dialog>
+    </uni-popup>
+  </scroll-view>
+</template>
+<script setup>
+import { ref, unref, onMounted, nextTick } from 'vue'
+import { mobile, isValidIdCard18 } from '@/utils/validate'
+import { dictObj } from '@/utils/position.js'
+import { saveStudentSimpleInfo } from '@/api/user'
+import { showAuthModal } from '@/hooks/useModal'
+import { userStore } from '@/store/user'; const useUserStore = userStore()
+import { uploadFile } from '@/api/file'
+import { schoolList, departmentList } from '@/api/pickerData'
+
+const baseInfoRef = ref()
+const formData = ref({ // 必填项目
+  name: null,
+  sex: null,
+  idCardNo: null,
+  phone: null,
+  birthday: '1990-01-01',
+  schoolId: null,
+  schoolDepartmentName: null,
+  majorName: null,
+  schoolClassName: null,
+  studentNo: null,
+  emergencyContactName: null,
+  emergencyContactPhone: null,
+})
+
+onMounted(() => {
+  nextTick(() => {
+    const baseInfo = useUserStore?.baseInfo || null
+    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
+      })
+    }
+    if (!formData.value.phone && useUserStore?.phone) formData.value.phone = useUserStore.phone
+  })
+})
+
+const schools = ref([])
+// // 学校下拉列表
+const getSchoolListData = async () => {
+  const res = await schoolList({current: 1, size: 9999})
+  schools.value = res?.data?.records?.length ? res.data.records : []
+}
+getSchoolListData()
+
+const schoolDepartmentList = ref([])
+const getDepartmentList = async (event) => {
+  const e = event?.detail?.value?.length ? event.detail.value[0].value : ''
+  if (!e) return
+  
+  const query = {
+    page: { size: 9999,	current: 1	},
+    entity: { schoolId: e }
+  }
+  schoolDepartmentList.value = []
+  formData.value.schoolDepartmentName = null
+  const res = await departmentList(query)
+  const list = res?.data?.records?.length ? res.data.records : []
+  schoolDepartmentList.value = list.map(e => e.entity)
+}
+
+const formRules = {
+	avatar:{
+		rules: [{required: true, errorMessage: '请上传头像' }]
+	},
+	name:{
+		rules: [{required: true, errorMessage: '请输入姓名' }]
+	},
+  sex: {
+    rules: [{required: true, errorMessage: '请选择您的性别' }]
+  },
+  idCardNo: isValidIdCard18,
+  phone: mobile,
+  birthday:{
+		rules: [{required: true, errorMessage: '请选择就读学校' }]
+	},
+  schoolId:{
+		rules: [{required: true, errorMessage: '请选择所在院系' }]
+	},
+  schoolDepartmentName:{
+		rules: [{required: true, errorMessage: '请输入所学专业' }]
+	},
+  majorName: {
+		rules: [{required: true, errorMessage: '请填写所在班级' }]
+	},
+  schoolClassName: {
+		rules: [{required: true, errorMessage: '请填写学号' }]
+	},
+  studentNo: {
+		rules: [{required: true, errorMessage: '请填写紧急联系人姓名' }]
+	},
+  emergencyContactName: {
+		rules: [{required: true, errorMessage: '请填写紧急联系人手机号' }]
+	},
+  emergencyContactPhone: mobile,
+}
+
+const logoutPopup = ref()
+// 退出登录
+const handleLogout = () => {
+  logoutPopup.value.open()
+}
+const handleLogoutClose = () => {
+  logoutPopup.value.close()
+}
+const handleLogoutConfirm = async () => {
+  await useUserStore.handleLogout()
+  showAuthModal()
+}
+
+// 图片预览
+const handlePreviewImage = () => {
+  uni.previewImage({
+    current: 0,
+    urls: [formData.value.avatar]
+  })
+}
+// 选择头像
+const uploadPhotos = () => {
+  wx.chooseImage({
+    count: 1,
+    sizeType: ['original', 'compressed'],
+    sourceType: ['album', 'camera'],
+    success: function(res){
+      const size = res.tempFiles[0]?.size || 0
+      if (size >= 31457280) {
+        uni.showToast({
+          icon: 'none',
+          title: '头像上传大小不得超过 20MB !',
+          duration: 2000
+        })
+        return
+      }
+      const path = res.tempFilePaths[0]
+      uploadFile(path, 'img').then(res => {
+        formData.value.avatar = res.data
+      }).catch(error => {
+        uni.showToast({
+          icon: 'error',
+          title: '图片上传失败!',
+          duration: 2000
+        })
+      })
+    }
+  })
+}
+
+const submit = async () => {
+  const validate = await unref(baseInfoRef).validate()
+  if (!validate) return uni.showToast({ title: '请将信息补充完整', icon: 'none' })
+  try {
+    await saveStudentSimpleInfo(formData.value)
+    uni.showToast({ title: '保存成功', icon: 'none' })
+    await useUserStore.getInfo()
+  } catch (err) {
+    uni.showToast({ title: err?.msg || '保存失败', icon: 'none' })
+  }
+}
+
+</script>
+<style lang="scss" scoped>
+.scrollBox {
+  width: 100vw;
+  // height: 100vh;
+  height: calc(100vh - 30rpx);
+  margin-bottom: 30rpx;
+}
+.content {
+  padding: 30rpx;
+}
+
+.changeRole {
+  color: var(--color-666);
+  font-size: 15px;
+  line-height: 26px;
+  margin-bottom: 40rpx;
+}
+.upload-img{
+  position: relative;
+  width: 200rpx;
+  height: 200rpx;
+  border: 1px solid #f1f1f1;
+  margin: 10rpx;
+}
+.upload-file{
+  width: 200rpx;
+  height: 200rpx;
+  border: 1px solid #f1f1f1;
+  margin: 10rpx;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  border-radius: 10rpx;
+}
+</style>

+ 6 - 0
pages.json

@@ -116,6 +116,12 @@
 						"navigationBarTitleText": "附件简历"
 					}
 				},
+				{
+					"path": "student/index",
+					"style": {
+						"navigationBarTitleText": "学生信息认证"
+					}
+				},
 				{
 					"path": "collect/index",
 					"style": {

+ 19 - 2
pages/index/my.vue

@@ -102,9 +102,10 @@ const itemList = [
 	{ title:'关注我的', path:'/pagesA/seenMe/index', icon:'staff' }
 ]
 
-const list = ref([
+const defaultList = [
 	{	title: '在线简历',	path: '/pagesA/resumeOnline/index'	},					
 	{	title: '附件简历',	path: '/pagesA/resume/index'	},					
+	{ title: '学生信息', path: '/pagesA/student/index', key: 'student', hide: true },
 	{ title: '面试管理', path: '/pagesA/interview/index' },
 	{	title: '会员套餐', path: '/pagesA/vipPackage/index'	},		
 	// {	title: '我的分享码',	path: 'shareQrCode'	},					
@@ -115,7 +116,23 @@ const list = ref([
 	// { title: '招聘会', path: '/pagesB/jobFair/index', open: true },
 	{ title: '联系我们', path: '/pagesB/contactUs/index' },
 	{ title: '协议中心', path: '/pagesB/agreement/index', open: true }
-])
+]
+const list = ref(defaultList.filter(e => !e.hide))
+
+watch(
+  () => baseInfo.value, 
+  (newVal) => {
+		if (newVal) {
+			list.value = defaultList.map(e => {
+				if (e?.key === 'student' && newVal.type === '1') e.hide = false // 学生信息管理。 type:0是求职者,1是学生
+				return e.hide ? null : e
+			}).filter(Boolean)
+		}
+  },
+  { immediate: true },
+  // { deep: true }
+)
+
 watch(
   () => vip.value, 
   (newVal) => {

+ 174 - 0
pagesA/student/index.vue

@@ -0,0 +1,174 @@
+<!-- 校验是否完善人才必填信息 -->
+<template>
+  <scroll-view class="scrollBox" scroll-y="true">
+    <view class="content">
+      <view class="text-center ss-m-b-50 font-size-20 color-primary">学生信息认证</view>
+      <uni-forms
+        ref="baseInfoRef"
+        v-model="formData"
+        :rules="formRules"
+        validateTrigger="bind"
+        label-width="90px"
+        labelAlign="center"
+      >
+        <uni-forms-item name="schoolId" label="就读学校" required>
+          <uni-data-picker v-model="formData.schoolId" :localdata="schools" :clear-icon="false" popup-title="请选择就读学校" @change="getDepartmentList" :map="{ text: 'schoolName', value: 'schoolId' }"></uni-data-picker>
+        </uni-forms-item>
+        <uni-forms-item name="schoolDepartmentName" label="所在院系" required>
+          <uni-data-picker v-model="formData.schoolDepartmentName" :localdata="schoolDepartmentList" :clear-icon="false" popup-title="请选择所在院系" :map="{ text: 'departmentTitle', value: 'schoolDepartmentId' }"></uni-data-picker>
+        </uni-forms-item>
+        <uni-forms-item name="majorName" label="所学专业" required>
+          <uni-easyinput placeholder="请输入所学专业" v-model="formData.majorName" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="schoolClassName" label="所在班级" required>
+          <uni-easyinput placeholder="请填写所在班级" v-model="formData.schoolClassName" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="studentNo" label="学号" required>
+          <uni-easyinput placeholder="请填写学号" v-model="formData.studentNo" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="idCardNo" label="身份证号码" required>
+          <uni-easyinput placeholder="请输入身份证号码" v-model="formData.idCardNo" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="emergencyContactName" label="紧急联系人姓名" required>
+          <uni-easyinput placeholder="请填写紧急联系人姓名" v-model="formData.emergencyContactName" :inputBorder="false" type="text"></uni-easyinput>
+        </uni-forms-item>
+        <uni-forms-item name="emergencyContactPhone" label="紧急联系人手机号" required>
+          <uni-easyinput placeholder="请填写紧急联系人手机号" v-model="formData.emergencyContactPhone" :inputBorder="false" type="number"></uni-easyinput>
+        </uni-forms-item>
+      </uni-forms>
+      <view class="f-horizon-center">
+        <button type="primary" size="default" class="send-button" @click="submit">保 存</button>
+      </view>
+    </view>
+  </scroll-view>
+</template>
+<script setup>
+import { ref, unref } from 'vue'
+import { mobile, isValidIdCard18 } from '@/utils/validate'
+import { saveStudentSimpleInfo, getStudentInfo } from '@/api/user'
+// import { userStore } from '@/store/user'; const useUserStore = userStore()
+import { schoolList, departmentList } from '@/api/pickerData'
+
+const baseInfoRef = ref()
+const formData = ref({ // 必填项目
+  schoolId: null,
+  schoolDepartmentName: null,
+  majorName: null,
+  schoolClassName: null,
+  studentNo: null,
+  idCardNo: null,
+  emergencyContactName: null,
+  emergencyContactPhone: null,
+})
+
+// 获取学生基本信息
+const studentInfoFun = async () => {
+  const { data } = await getStudentInfo()
+  // 回显
+  formData.value = { ...formData.value, ...data }
+  getDepartmentList()
+}
+studentInfoFun()
+
+const schools = ref([])
+// // 学校下拉列表
+const getSchoolListData = async () => {
+  const res = await schoolList({current: 1, size: 9999})
+  schools.value = res?.data?.records?.length ? res.data.records : []
+}
+getSchoolListData()
+
+const schoolDepartmentList = ref([])
+const getDepartmentList = async (e) => {
+  if (!formData.value?.schoolId) return
+  const query = {
+    page: { size: 9999,	current: 1	},
+    entity: { schoolId: formData.value.schoolId }
+  }
+  schoolDepartmentList.value = []
+  if (e) formData.value.schoolDepartmentName = null // 切换学校的时清院系
+  const res = await departmentList(query)
+  const list = res?.data?.records?.length ? res.data.records : []
+  schoolDepartmentList.value = list.map(e => e.entity)
+}
+
+const formRules = {
+  idCardNo: isValidIdCard18,
+  phone: mobile,
+  schoolId:{
+		rules: [{required: true, errorMessage: '请选择所在院系' }]
+	},
+  schoolDepartmentName:{
+		rules: [{required: true, errorMessage: '请输入所学专业' }]
+	},
+  majorName: {
+		rules: [{required: true, errorMessage: '请填写所在班级' }]
+	},
+  schoolClassName: {
+		rules: [{required: true, errorMessage: '请填写学号' }]
+	},
+  studentNo: {
+		rules: [{required: true, errorMessage: '请填写紧急联系人姓名' }]
+	},
+  emergencyContactName: {
+		rules: [{required: true, errorMessage: '请填写紧急联系人手机号' }]
+	},
+  emergencyContactPhone: mobile,
+}
+
+const submit = async () => {
+  const validate = await unref(baseInfoRef).validate()
+  if (!validate) return uni.showToast({ title: '请将信息补充完整', icon: 'none' })
+  try {
+    await saveStudentSimpleInfo(formData.value)
+    uni.showToast({
+			icon: 'success',
+			title: '保存成功'
+		})
+    // await useUserStore.getInfo()
+		setTimeout(() => {
+      uni.navigateBack({
+        delta: 1
+      })
+    }, 1000)
+  } catch (err) {
+    uni.showToast({ title: err?.msg || '保存失败', icon: 'none' })
+  }
+}
+
+</script>
+<style lang="scss" scoped>
+.scrollBox {
+  width: 100vw;
+  // height: 100vh;
+  height: calc(100vh - 30rpx);
+  margin-bottom: 30rpx;
+}
+.content {
+  padding: 30rpx;
+}
+
+.changeRole {
+  color: var(--color-666);
+  font-size: 15px;
+  line-height: 26px;
+  margin-bottom: 40rpx;
+}
+.upload-img{
+  position: relative;
+  width: 200rpx;
+  height: 200rpx;
+  border: 1px solid #f1f1f1;
+  margin: 10rpx;
+}
+.upload-file{
+  width: 200rpx;
+  height: 200rpx;
+  border: 1px solid #f1f1f1;
+  margin: 10rpx;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  border-radius: 10rpx;
+}
+</style>

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
static/svg/student.svg


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
static/svg/workMan.svg


+ 5 - 0
store/user.js

@@ -104,6 +104,11 @@ export const userStore = defineStore('user', {
     // 校验是否完善人才必填信息
     checkPersonBaseInfoFun(data) {
       data = data || {}
+      // 待测试完毕开放
+      // if (!data || !Object.keys(data).length || data.type === undefined || data.type === null) {
+      //   showAuthModal('selectUserType')
+      //   return
+      // }
       const necessaryInfoReady = checkPersonBaseInfo(data)
       data.necessaryInfoReady = necessaryInfoReady
       if (necessaryInfoReady) closeAuthModal()

+ 1 - 1
utils/check.js

@@ -1,7 +1,7 @@
 // 校验是否完善人才必填信息
 export const checkPersonBaseInfo = (info) => {
-  // const info = baseInfo ? baseInfo : localStorage.getItem('baseInfo') ? JSON.parse(localStorage.getItem('baseInfo')) : {}
   if (!info || !Object.keys(info).length) return false
+  if (info.type && Number(info.type) === 1) return true // 0是求职者,1是学生
   const keyArr = [ // 必填项目
     'name',
     'sex',

+ 50 - 0
utils/validate.js

@@ -4,6 +4,56 @@
  */
 import test from './test.js';
 
+// 效验身份证号码
+export const isValidIdCard18 = {
+  rules: [
+    {
+      required: true,
+      errorMessage: '请输入您的身份证号码',
+    },
+    {
+      validateFunction: function (rule, value, data, callback) {
+        // 身份证号码正则表达式(18位)
+        var regex = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(10|11|12))(([012]\d)|3[01])\d{3}(\d|X|x)$/
+
+        // 校验长度,类型
+        if (!regex.test(value)) {
+          return false
+        }
+
+        // 提取出生年月日,并验证是否为有效日期
+        var year = value.substring(6, 10)
+        var month = value.substring(10, 12)
+        var day = value.substring(12, 14)
+        var date = new Date(year, month - 1, day)
+
+        if (date.getFullYear() !== parseInt(year, 10) ||
+          date.getMonth() !== parseInt(month, 10) - 1 ||
+          date.getDate() !== parseInt(day, 10)) {
+          return false
+        }
+
+        // 校验码部分
+        var idCardBase = value.substring(0, 17)
+        var weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
+        var checkCodes = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
+        var sum = 0
+        for (var i = 0; i < idCardBase.length; i++) {
+          sum += idCardBase[i] * weights[i]
+        }
+        var index = sum % 11
+        var last = checkCodes[index]
+
+        // return last.toUpperCase() === value.substring(17).toUpperCase()
+        if (last.toUpperCase() !== value.substring(17).toUpperCase()) {
+          callback('请输入正确的身份证号码');
+        }
+        return true;
+      },
+    },
+  ],
+};
+
 // 手机号
 export const mobile = {
   rules: [

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác