Browse Source

职位搜索

Xiao_123 5 months ago
parent
commit
70294b7de2
2 changed files with 25 additions and 14 deletions
  1. 16 4
      pages/index/position.vue
  2. 9 10
      pagesB/headhunting/pages/contact.vue

+ 16 - 4
pages/index/position.vue

@@ -175,8 +175,9 @@ const checkValue = (obj) => {
   })
   })
 }
 }
 
 
+const type = ref('recommend')
 const positionListData = ref([])
 const positionListData = ref([])
-const query = reactive({ 
+const query = reactive({
   pageSize: 20, 
   pageSize: 20, 
   pageNo: 1,
   pageNo: 1,
   hire: false,
   hire: false,
@@ -192,10 +193,19 @@ const getData = async () => {
   const { content, areaIds, industryIds, jobType, payScope, positionId } = query
   const { content, areaIds, industryIds, jobType, payScope, positionId } = query
   const hasValue = checkValue({ content, areaIds, industryIds, jobType, payScope, positionId })
   const hasValue = checkValue({ content, areaIds, industryIds, jobType, payScope, positionId })
 
 
-  // 带查询条件时返回到顶部
-  if (hasValue) {
+  // 当前接口为推荐列表时,带查询条件需返回到列表顶部
+  if (hasValue && type.value === 'recommend') {
     scrollTop.value = old.value.scrollTop
     scrollTop.value = old.value.scrollTop
     nextTick(() => {
     nextTick(() => {
+      type.value = 'position'
+      scrollTop.value = 0
+    })
+  }
+  // 当前接口为只为列表时,清除查询条件需返回到列表顶部
+  if (!hasValue && type.value === 'position') {
+    scrollTop.value = old.value.scrollTop
+    nextTick(() => {
+      type.value = 'recommend'
       scrollTop.value = 0
       scrollTop.value = 0
     })
     })
   }
   }
@@ -203,6 +213,7 @@ const getData = async () => {
   // 带搜索条件(除分页外)用职位搜索接口,无条件则用推荐接口
   // 带搜索条件(除分页外)用职位搜索接口,无条件则用推荐接口
   const api = hasValue ? getJobAdvertisedSearch : getPromotedPosition
   const api = hasValue ? getJobAdvertisedSearch : getPromotedPosition
   const params = hasValue ? query : { pageSize: query.pageSize, pageNo: query.pageNo, hire: 0 }
   const params = hasValue ? query : { pageSize: query.pageSize, pageNo: query.pageNo, hire: 0 }
+  type.value = hasValue ? 'position' : 'recommend'
   try {
   try {
     const res = await api(params)
     const res = await api(params)
     const arr = res?.data?.list || []
     const arr = res?.data?.list || []
@@ -253,7 +264,8 @@ const onSearch = () => {
   getData()
   getData()
 }
 }
 
 
-const loadingMore = () => { // 加载更多
+// 加载更多
+const loadingMore = () => {
   more.value = 'loading'
   more.value = 'loading'
   query.pageNo++
   query.pageNo++
   getData()
   getData()

+ 9 - 10
pagesB/headhunting/pages/contact.vue

@@ -1,13 +1,13 @@
 <template>
 <template>
   <view class="pa-3">
   <view class="pa-3">
-    <uni-forms ref="baseForm" v-model="baseFormData" validateTrigger="bind" :rules="rules" label-width="100px" label-align="right">
-      <uni-forms-item label="姓名" required  >
+    <uni-forms ref="baseFormRef" v-model="baseFormData" validateTrigger="bind" :rules="rules" label-width="100px" label-align="right">
+      <uni-forms-item label="姓名" required  name="name">
         <uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" />
         <uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" />
       </uni-forms-item>
       </uni-forms-item>
-      <uni-forms-item label="联系手机号" required >
+      <uni-forms-item label="联系手机号" required name="phone">
         <uni-easyinput v-model="baseFormData.phone" placeholder="请输入联系手机号" />
         <uni-easyinput v-model="baseFormData.phone" placeholder="请输入联系手机号" />
       </uni-forms-item>
       </uni-forms-item>
-      <uni-forms-item label="企业名称" required>
+      <uni-forms-item label="企业名称" required name="enterpriseName">
         <uni-easyinput v-model="baseFormData.enterpriseName" placeholder="请输入企业名称" />
         <uni-easyinput v-model="baseFormData.enterpriseName" placeholder="请输入企业名称" />
       </uni-forms-item>
       </uni-forms-item>
       <button type="primary" @click="submit" :disabled="loading">提交</button>
       <button type="primary" @click="submit" :disabled="loading">提交</button>
@@ -18,7 +18,8 @@
 <script setup>
 <script setup>
 import { ref, unref } from 'vue'
 import { ref, unref } from 'vue'
 import { huntSubmit } from '@/api/common'
 import { huntSubmit } from '@/api/common'
-const baseForm = ref()
+
+const baseFormRef = ref()
 const baseFormData = ref({
 const baseFormData = ref({
   name: null,
   name: null,
   phone: null,
   phone: null,
@@ -40,12 +41,10 @@ const rules = {
 }
 }
 const loading = ref(false)
 const loading = ref(false)
 const submit = async () => {
 const submit = async () => {
+  const valid = await unref(baseFormRef).validate()
+  if (!valid) return
+  loading.value = true
   try {
   try {
-    const valid = await unref(baseForm).validate()
-    if (!valid) return
-
-    loading.value = true
-
     const { code, msg } = await huntSubmit(baseFormData.value)
     const { code, msg } = await huntSubmit(baseFormData.value)
     if (code !== 0) {
     if (code !== 0) {
       loading.value = false
       loading.value = false