Xiao_123 пре 15 часа
родитељ
комит
4434584a14

+ 15 - 60
layout/components/authModal/login/index.vue

@@ -44,7 +44,7 @@
     </template>
 
     <template v-if="changeType === 'register'">
-      <view class="head-title pb-20">手机号验证</view>
+      <view class="head-title pb-20">企业注册</view>
 
       <uni-forms
         ref="registerForm"
@@ -55,30 +55,11 @@
         labelAlign="center"
       >
 
-        <uni-forms-item name="phone" label="手机号">
-          <uni-easyinput placeholder="请输入手机号" v-model="state.register.phone" :inputBorder="false" type="number">
-          </uni-easyinput>
+        <uni-forms-item name="phone" label="企业邮箱">
+          <uni-easyinput placeholder="请输入企业邮箱" v-model="state.register.phone" :inputBorder="false"></uni-easyinput>
         </uni-forms-item>
-
-        <uni-forms-item name="code" label="验证码">
-          <uni-easyinput
-            placeholder="请输入验证码"
-            v-model="state.register.code"
-            :inputBorder="false"
-            type="number"
-            maxlength="6"
-          >
-            <template v-slot:right>
-              <button
-                class="login-code"
-                :disabled="state.isMobileEnd"
-                :class="{ 'code-btn-end': state.isMobileEnd }"
-                @tap="handleRegisterCode"
-              >
-                {{ getSmsTimer('smsRegister') }}
-              </button>
-            </template>
-          </uni-easyinput>
+        <uni-forms-item name="password" label="登录密码">
+          <uni-easyinput type="password" placeholder="请输入密码" v-model="state.register.password" :inputBorder="false"></uni-easyinput>
         </uni-forms-item>
       </uni-forms>
       <view class="register login" style="text-align: end;" @tap="handleChangeLogin">已有账户?去登陆</view>
@@ -101,8 +82,7 @@
 
 <script setup>
 import { ref, unref } from 'vue'
-import { mobile, password, code, emailRequired } from '@/utils/validate'
-import { getSmsCode, getSmsTimer } from '@/utils/code'
+import { password, emailRequired } from '@/utils/validate'
 import { userStore } from '@/store/user'
 import { closeAuthModal } from '@/hooks/useModal'
 import { getEnterpriseRegisterApply } from '@/api/enterprise'
@@ -121,19 +101,19 @@ const state = ref({
   },
   register: {
     phone: '',
-    code: ''
+    password: ''
   },
   account: {
     phone: testEnvBool ? '1687284007@qq.com' : '', // 1687284007 18406571584 
-    password: testEnvBool ? 'Citu123456' : '',
+    password: testEnvBool ? 'Citu123456' : ''
   },
   rules: {
     phone: emailRequired,
-    password,
+    password
   },
   smsRules: {
-    code,
-    phone: mobile
+    phone: emailRequired,
+    password
   }
 })
 
@@ -153,18 +133,6 @@ const handleForgotPassword = () => {
 
 const changeType = ref('login')
 
-// 获取验证码
-const handleRegisterCode = () => {
-  if (!state.value.register.phone) {
-    uni.showToast({
-      title: '请输入手机号',
-      icon: 'none',
-      duration: 2000
-    })
-    return
-  }
-  getSmsCode('smsRegister', state.value.register.phone)
-}
 // 查看协议详情
 const handleToDetail = (type) => {
   const url = type === 'user' ? '/pagesB/agreement/user' : '/pagesB/agreement/privacy'
@@ -186,24 +154,11 @@ function handleChangeLogin () {
 async function handleRegister () {
   const validate = await unref(registerForm).validate()
   if (!validate) return
+  closeAuthModal()
   const query = state.value.register
-  Object.assign(query, {
-    account: query.phone,
-    autoRegister: true
-  })
-  try {
-    await useUserStore.handleRegister(query)
-    uni.showToast({
-      title: '手机号验证成功',
-      icon: 'none',
-      duration: 2000
-    })
-    // 查看用户是否有在申请中的数据
-    const { code } =  await useUserStore.getPersonalApplyingData()
-    changeType.value = 'login'
-    uni.navigateTo({ url: code ? '/pages/register/review?hasData=true' : '/pages/register/index' })
-  } finally {
-  }
+  uni.setStorageSync('isPersonalToken', true);
+  uni.setStorageSync('registerAccount', JSON.stringify(query))
+  uni.navigateTo({ url: '/pages/register/index' })
 }
 
 const handleCheckEnterprise = async () => {

+ 5 - 2
pages/index/components/recommend.vue

@@ -40,7 +40,8 @@ const more = ref('noMore')
 const total = ref(0)
 
 // 根据职位id获取推荐人才列表
-const getRecommendList = async () => {
+const getRecommendList = async (loading = false) => {
+	if (loading) uni.showLoading({ title: '加载中' })
   try {
 		more.value = 'loading'
 		const { data } = await getPersonRecommendPage(query.value)
@@ -61,6 +62,8 @@ const getRecommendList = async () => {
 	} catch {
 		query.value.pageNo--
 		more.value = 'more'
+	} finally {
+		if (loading) uni.hideLoading()
 	}
 }
 getRecommendList()
@@ -70,7 +73,7 @@ const handleChangeJob = () => {
 	query.value.pageNo = 1
 	items.value = []
 	total.value = 0
-	getRecommendList()
+	getRecommendList(true)
 }
 
 // 加载更多

+ 11 - 14
pages/index/search.vue

@@ -32,7 +32,6 @@ import { ref, watch, onMounted } from 'vue'
 import { onShow } from '@dcloudio/uni-app'
 import layoutPage from '@/layout'
 import Navbar from '@/components/Navbar'
-// import SwiperAd from '@/components/SwiperAd'
 import { getAccessToken } from '@/utils/request'
 import { showAuthModal } from '@/hooks/useModal'
 import { getJobAdvertised } from '@/api/search'
@@ -40,7 +39,6 @@ import { userStore } from '@/store/user'
 import { formatName } from '@/utils/getText'
 import RecommendPage from './components/recommend.vue'
 import ConditionPage from './components/condition.vue'
-import { getWebContent } from '@/api/common'
 
 const navbarHeight = ref(0)
 
@@ -64,17 +62,15 @@ const current = ref(0)
 const tabList = ['人才推荐', '条件筛选']
 const useUserStore = userStore()
 
-// 获取轮播图
-const swiperAdList = ref([])
-const getSystemWebContent = async () => {
-  const { data } = await getWebContent()
-  swiperAdList.value = data?.appHomeCarousel || []
-}
-
 // 职位列表
 const jobList = ref([])
 const getJobList = async () => {
-	if (!useUserStore.refreshToken || uni.getStorageSync('isPersonalToken')) {
+	// 仅企业登录并且有刷新token时获取;注册(个人令牌)不获取
+	if (!useUserStore.refreshToken) {
+		return
+	}
+	// 双保险:优先使用 store 标志,兼容本地缓存未及时写入
+	if (useUserStore.isPersonal || uni.getStorageSync('isPersonalToken')) {
 		return
 	}
   const { data } = await getJobAdvertised({ status: 0, exTime: 0 })
@@ -85,13 +81,13 @@ const getJobList = async () => {
   }
 }
 
-watch(() => useUserStore.refreshToken, () => {
+watch(() => [useUserStore.refreshToken, useUserStore.isPersonal], ([refreshToken, isPersonal]) => {
+	if (!refreshToken) return
+	if (isPersonal) return
 	getJobList()
 }, { immediate: true })
 
 onShow(() => {
-	// getSystemWebContent()
-
 	// 设置自定义tabbar选中值
   const currentPage = getCurrentPages()[0]  // 获取当前页面实例
   const currentTabBar = currentPage?.getTabBar?.()
@@ -100,7 +96,8 @@ onShow(() => {
   currentTabBar?.setData({ selected: 0 })
 
 	if (!getAccessToken()) return showAuthModal()
-	else getJobList()
+	if (uni.getStorageSync('isPersonalToken')) return
+	getJobList()
 })
 
 const changeControl = (e) =>{

+ 7 - 5
pages/register/contact.vue

@@ -45,8 +45,10 @@ import { enterpriseRegisterApply } from '@/api/enterprise'
 const useUserStore = userStore()
 const adminUserPhone = computed(() => useUserStore?.phone)
 const register = ref(JSON.parse(uni.getStorageSync('registerInfo')))
+const registerAccount = ref(uni.getStorageSync('registerAccount') ? JSON.parse(uni.getStorageSync('registerAccount')) : {})
 console.log(adminUserPhone.value, '注册手机号', register.value)
 
+
 const formRef = ref()
 const formRules = {
 	contactName: {
@@ -72,9 +74,9 @@ const contacts = ref([
   {
     contactName: '',
     phone: adminUserPhone.value || '',
-    email: '',
-    password: '',
-    passwordConfirm: ''
+    email: registerAccount.value?.phone || '',
+    password: registerAccount.value?.password || '',
+    passwordConfirm: registerAccount.value?.password || ''
   },
   {
     contactName: '',
@@ -87,8 +89,8 @@ const contacts = ref([
 
 onLoad((options) => {
 	if (options?.isEdit) {
-		const applyInfo = ref(uni.getStorageSync('entRegisterData') ? JSON.parse(uni.getStorageSync('entRegisterData')) : {})
-		contacts.value = applyInfo.value.contacts.map(e =>  {
+		const applyInfo = uni.getStorageSync('entRegisterData') ? JSON.parse(uni.getStorageSync('entRegisterData')) : {}
+		contacts.value = applyInfo?.contacts.map(e =>  {
 			e.passwordConfirm = e.password
 			return e
 		})

+ 97 - 10
pages/register/index.vue

@@ -38,7 +38,43 @@
       </uni-forms-item>
     </uni-forms>
 
-    <button class="send-button" @tap="handleNext">下一步</button>
+    <view v-if="!isEdit">
+      <view class="color-primary font-size-15 ss-m-b-20 font-weight-bold">手机号码验证</view>
+      <uni-forms
+        ref="validFormRef"
+        v-model="validData"
+        :rules="validRules"
+        validateTrigger="bind"
+        labelWidth="140"
+        labelAlign="center"
+      >
+        <uni-forms-item name="phone" label="手机号" required>
+          <uni-easyinput placeholder="请输入手机号" v-model="validData.phone" :inputBorder="false" type="number" />
+        </uni-forms-item>
+        <uni-forms-item name="code" label="验证码" required>
+          <uni-easyinput
+            placeholder="请输入六位数验证码"
+            v-model="validData.code"
+            :inputBorder="false"
+            type="number"
+            maxlength="6"
+          >
+            <template v-slot:right>
+              <button
+                class="login-code"
+                :disabled="isMobileEnd"
+                :class="{ 'code-btn-end': isMobileEnd }"
+                @tap="handleRegisterCode"
+              >
+                {{ getSmsTimer('smsRegister') }}
+              </button>
+            </template>
+          </uni-easyinput>
+        </uni-forms-item>
+      </uni-forms>
+    </view>
+
+    <button class="send-button ss-m-t-50" @tap="handleNext">下一步</button>
   </view>
 </template>
 
@@ -47,7 +83,12 @@
 import { ref, unref } from 'vue'
 import { uploadFile } from '@/api/file'
 import { getBusinessLicenseOCR } from '@/api/common'
+import { mobile, code } from '@/utils/validate'
+import { getSmsCode, getSmsTimer } from '@/utils/code'
+import { userStore } from '@/store/user'
 
+const useUserStore = userStore()
+const validFormRef = ref(null)
 const formRef = ref()
 const formData = ref({
   prepare: true,
@@ -57,12 +98,34 @@ const formData = ref({
   code: '',
   description: ''
 })
+const isMobileEnd = ref(false)
+const validData = ref({
+  phone: '',
+  code: ''
+})
+const validRules = ref({
+  code,
+  phone: mobile
+})
 
 const required = ref({
   code: false,
   businessLicenseUrl: false
 })
 
+// 获取验证码
+const handleRegisterCode = () => {
+  if (!validData.value.phone) {
+    uni.showToast({
+      title: '请输入手机号',
+      icon: 'none',
+      duration: 2000
+    })
+    return
+  }
+  getSmsCode('smsRegister', validData.value.phone)
+}
+
 const formRules = ref({
 	name:{
 		rules: [{required: true, errorMessage: '请输入企业名称' }]
@@ -168,8 +231,10 @@ const handleChangePrepare = (e, clear = true) => {
 
 // 申请拒绝-重新提交数据回显
 const applyInfo = ref(uni.getStorageSync('entRegisterData') ? JSON.parse(uni.getStorageSync('entRegisterData')) : {})
-console.log(applyInfo.value, '申请拒绝-重新提交数据回显')
+const isEdit = ref(false)
+console.log(applyInfo.value, '申请拒绝-重新提交数据回显', uni.getStorageSync('entRegisterData'))
 if (applyInfo.value && Object.keys(applyInfo.value).length > 0 && applyInfo.value.status === '2') {
+  isEdit.value = true
   for (let i in formData.value) {
     formData.value[i] = applyInfo.value[i]
   }
@@ -179,19 +244,32 @@ if (applyInfo.value && Object.keys(applyInfo.value).length > 0 && applyInfo.valu
 
 // 登录
 const handleNext = async () => {
+  // 基本信息效验
   const validate = await unref(formRef).validate()
   if (!validate) return
-
+  // 营业执照
   if (business.value && Object.keys(business.value).length) formData.value.ocr = business.value
   
-  const isEdit = applyInfo.value && Object.keys(applyInfo.value).length > 0 && applyInfo.value.status === '2'
-  if (isEdit) formData.value.id = applyInfo.value.id
-  console.log(formData.value, 'index-next-formData')
-
+  if (isEdit.value) formData.value.id = applyInfo.value.id
   uni.setStorageSync('registerInfo', JSON.stringify(formData.value))
-  uni.navigateTo({
-    url: isEdit ? '/pages/register/contact?isEdit=true' : '/pages/register/contact'
-  })
+  
+  // 手机号及验证码效验
+  if (!isEdit.value) {
+    const phoneValid = await unref(validFormRef).validate()
+    if (!phoneValid) return
+    
+    try {
+      await useUserStore.handleRegister({ ...validData.value, autoRegister: true, account: validData.value.phone })
+      // 查看用户是否有在申请中的数据,有申请中的数据则跳转等待审核页面
+      const { code } =  await useUserStore.getPersonalApplyingData()
+      if (code) return uni.navigateTo({ url: '/pages/register/review?hasData=true' })
+
+      // 没有注册中企业跳转下一步填写联系人信息
+      uni.navigateTo({ url: '/pages/register/contact' })
+    } finally {}
+  } else {
+    uni.navigateTo({ url: '/pages/register/contact?isEdit=true' })
+  }
 }
 </script>
 
@@ -217,4 +295,13 @@ const handleNext = async () => {
   align-items: center;
   border-radius: 10rpx;
 }
+.login-code {
+  width: 73px;
+  min-width: 73px;
+  color: #00B760;
+  text-align: center; 
+  font-size: 12px; 
+  cursor: pointer;
+  padding: 0;
+}
 </style>

+ 5 - 10
store/user.js

@@ -1,6 +1,6 @@
 import { defineStore } from 'pinia';
-import { getBaseInfo, getUserInfo, getUserAccountInfo } from '@/api/user';
-import { smsLogin, passwordLogin, weChatLogin, logout, userRegister, shareUserRegister } from '@/api/common'
+import { getUserInfo, getUserAccountInfo } from '@/api/user';
+import { smsLogin, passwordLogin, logout } from '@/api/common'
 import { closeAuthModal, showAuthModal } from '@/hooks/useModal'
 import { timesTampChange } from '@/utils/date'
 import { getBaseInfoDictOfName } from '@/utils/getText'
@@ -22,6 +22,7 @@ export const userStore = defineStore('user', {
     const userInfo = userLocal ? JSON.parse(userLocal) : {}
     return {
       phone: null,
+      isPersonal: false,
       baseInfo: userInfo.baseInfo ?? {}, // 用户信息
       userInfo: userInfo.userInfo ?? {},
       isLogin: !!uni.getStorageSync('token'), // 登录状态
@@ -49,7 +50,7 @@ export const userStore = defineStore('user', {
       this.isPersonal = false
       this.accountInfo = data
       uni.removeStorageSync('isPersonalToken') // 注册企业时个人登录
-      uni.removeStorageSync('entRegisterData') // 企业注册申请中的数据
+      // uni.removeStorageSync('entRegisterData') // 企业注册申请中的数据
 
       // 企业注册-审核被拒绝-重新提交-效验手机号不需要获取用户信息
       if (!isGetData) return
@@ -60,16 +61,10 @@ export const userStore = defineStore('user', {
 
     async handleRegister (query) {
       this.phone = query.phone
-      const { data, code } = await smsLogin(query)
-      if (code === 0) {
-        uni.showToast({
-          title: '手机号验证成功'
-        })
-      }
+      const { data } = await smsLogin(query)
       this.isPersonal = true
       this.accountInfo = data
       uni.setStorageSync('isPersonalToken', true); // 注册企业时个人登录
-      closeAuthModal()
     },
     // 获取用户信息
     async getUserInfos() {