Xiao_123 1 năm trước cách đây
mục cha
commit
70c0da4357

+ 8 - 0
src/api/common/index.js

@@ -55,4 +55,12 @@ export const getDictData = async (params) => {
     url: '/app-api/system/dict-data/type',
     params
   })
+}
+
+// 获取行业树形
+export const getIndustryTreeData = async (params) => {
+  return await request.get({
+    url: '/app-api/menduner/system/industry/get/tree',
+    params
+  })
 }

+ 0 - 9
src/api/personal/position.js

@@ -1,9 +0,0 @@
-import request from '@/config/axios'
-
-// 获取推荐职位
-export const getPromotedPosition = async (params) => {
-  return await request.get({
-    url: '/app-api/menduner/system/job/advertised/get/recommended',
-    params
-  })
-}

+ 25 - 0
src/api/position.js

@@ -0,0 +1,25 @@
+import request from '@/config/axios'
+
+// 获取推荐职位
+export const getPromotedPosition = async (params) => {
+  return await request.get({
+    url: '/app-api/menduner/system/job/advertised/get/recommended',
+    params
+  })
+}
+
+// 获取最新发布的职位
+export const getLatestPosition = async (params) => {
+  return await request.get({
+    url: '/app-api/menduner/system/job/advertised/get/latest',
+    params
+  })
+}
+
+// 获取急聘的职位
+export const getUrgentPosition = async (params) => {
+  return await request.get({
+    url: '/app-api/menduner/system/job/advertised/get/urgent',
+    params
+  })
+}

+ 23 - 52
src/components/Position/item.vue

@@ -4,24 +4,24 @@
       <div class="job-info">
         <div class="sub-li-top">
           <div class="sub-li-info">
-            <p class="name">{{ item.recruitName }}</p>
+            <p class="name">{{ item.name }}</p>
             <v-chip size="x-small" color="error" label variant="outlined" class="mr-1">急聘</v-chip>
             <v-chip size="x-small" color="warning" label variant="outlined">NEW</v-chip>
           </div>
-          <p class="salary">{{ item.salary }}</p>
+          <p class="salary">{{ item.payFrom }}-{{ item.payTo }}/{{ item.payName }}</p>
         </div>
-        <v-chip size="x-small" label v-for="(k, i) in item.welfareList" :key="i" class="mr-1" color="#666">{{ k }}</v-chip>
+        <v-chip size="x-small" label v-for="(k, i) in tagList" :key="i" class="mr-1" color="#666">{{ k }}</v-chip>
       </div>
       <div class="sub-li-bottom">
         <div class="user-info">
           <div class="d-flex align-center">
-            <v-img :src="item.company.headImg" width="40" style="height: 40px;" />
-            <span class="names ml-2" style="font-size: 14px">{{ item.company.enterpriseName }}</span>
+            <v-img src="../../assets/logo.png" width="40" style="height: 40px;" />
+            <span class="names ml-2" style="font-size: 14px">{{ item.anotherName }}</span>
           </div>
           <p class="names float-right">
-            <span>{{ item.company.industry }}</span>
+            <span>{{ item.industryName }}</span>
             <span class="vline"></span>
-            <span>{{ item.company.scale }}</span>
+            <span>{{ item.scaleName }}</span>
           </p>
         </div>
       </div>
@@ -31,52 +31,23 @@
 
 <script setup>
 defineOptions({ name: 'position-card-item' })
-const list = [
-  {
-    recruitName: '产品经理',
-    salary: '6-11k',
-    welfareList: ['广州','本科','1-3年'],
-    company: {
-      headImg: 'https://img.bosszhipin.com/beijin/mcs/banner/06123cabdf75ed08313530ec8a42aef2cfcd208495d565ef66e7dff9f98764da.jpg',
-      enterpriseName: '卓越教育',
-      industry: '互联网行业',
-      scale: '0-20人'
-    }
-  },
-  {
-    recruitName: '产品经理',
-    salary: '6-11k',
-    welfareList: ['广州','本科','1-3年'],
-    company: {
-      headImg: 'https://img.bosszhipin.com/beijin/mcs/banner/06123cabdf75ed08313530ec8a42aef2cfcd208495d565ef66e7dff9f98764da.jpg',
-      enterpriseName: '卓越教育',
-      industry: '互联网行业',
-      scale: '0-20人'
-    }
-  },
-  {
-    recruitName: '产品经理',
-    salary: '6-11k',
-    welfareList: ['广州','本科','1-3年'],
-    company: {
-      headImg: 'https://img.bosszhipin.com/beijin/mcs/banner/06123cabdf75ed08313530ec8a42aef2cfcd208495d565ef66e7dff9f98764da.jpg',
-      enterpriseName: '卓越教育',
-      industry: '互联网行业',
-      scale: '0-20人'
-    }
-  },
-  {
-    recruitName: '产品经理',
-    salary: '6-11k',
-    welfareList: ['广州','本科','1-3年'],
-    company: {
-      headImg: 'https://img.bosszhipin.com/beijin/mcs/banner/06123cabdf75ed08313530ec8a42aef2cfcd208495d565ef66e7dff9f98764da.jpg',
-      enterpriseName: '卓越教育',
-      industry: '互联网行业',
-      scale: '0-20人'
-    }
+import { ref, watch } from 'vue'
+const props = defineProps({
+  items: {
+    type: Array,
+    default: () => []
   }
-]
+})
+const tagList = ['广州','本科','1-3年']
+const list = ref([])
+watch(
+  () => props.items, 
+  (newVal) => {
+    list.value = newVal
+  },
+  { immediate: true },
+  { deep: true }
+)
 </script>
 
 <style lang="scss" scoped>

+ 14 - 7
src/hooks/web/useDictionaries.js

@@ -1,8 +1,17 @@
 
-import { getDictData } from '@/api/common/index'
+import { getDictData, getIndustryTreeData } from '@/api/common/index'
 // 定义对应的api
 const DICT_CITY_API = {
-  menduner_exp_type: getDictData
+  menduner_exp_type: getDictData, // 工作经验
+  menduner_pay_unit: getDictData, // 薪酬单位
+  menduner_enterprise_type: getDictData, // 企业类型
+  menduner_business_status: getDictData, // 经营状态
+  menduner_scale: getDictData, // 人员规模
+  menduner_financing_status: getDictData, // 融资状态
+  menduner_education_system_type: getDictData, // 学制类型
+  menduner_education_type: getDictData, // 学历
+  menduner_job_type: getDictData, // 求职类型
+  menduner_industry_type: getIndustryTreeData // 行业类型
 }
 
 const setDict = (type, val, cacheTime) => {
@@ -12,17 +21,15 @@ const setDict = (type, val, cacheTime) => {
   }))
 }
 
-export const getDict = (type) => {
+export const getDict = (type, params) => {
     return new Promise((resolve) => {
       const item = localStorage.getItem(type)
       const catchData = item ? JSON.parse(item) : null
       if (catchData && catchData.expire && (Date.now() <= catchData.expire)) {
-        return resolve(catchData.data)
+        return resolve({ data: catchData.data })
       }
       // 传参按照规范参数传
-      const query = {
-        type
-      }
+      const query = params ? params : { type }
       DICT_CITY_API[type](query).then(data => {
         setDict(type, data, Date.now())
         resolve({ data })

+ 1 - 1
src/layout/personal/slider.vue

@@ -5,7 +5,7 @@
         <template v-slot:activator="{ props }">
           <v-icon size="30" class="icons" v-bind="props">{{ item.mdi }}</v-icon>
         </template>
-        <template #default>
+        <template v-slot:default>
           <div v-if="item.showImg" class="ma-3" style="text-align: center">
             <v-img cover aspect-ratio="1/1" src="https://minio.citupro.com/dev/static/mendunerCode.jpg" :width="170" style="height: 170px;"></v-img>
             <span class="tips-text">关注门墩儿直聘微信公众号</span>

+ 39 - 14
src/views/Home/personal/components/hotPromotedPositions.vue

@@ -1,19 +1,19 @@
 <template>
   <div>
-    <v-tabs v-model="tab" align-tabs="start" color="primary" bg-color="#fff">
+    <v-tabs v-model="tab" align-tabs="start" color="primary" bg-color="#fff" @click="getPositionList">
       <v-tab :value="1">推荐职位</v-tab>
       <v-tab :value="2">最新职位</v-tab>
       <v-tab :value="3">急聘职位</v-tab>
     </v-tabs>
     <v-window v-model="tab" class="mt-3">
       <v-window-item :value="1">
-        <PositionCard></PositionCard>
+        <PositionCard :items="items"></PositionCard>
       </v-window-item>
       <v-window-item :value="2">
-        <PositionCard></PositionCard>
+        <PositionCard :items="items"></PositionCard>
       </v-window-item>
       <v-window-item :value="3">
-        <PositionCard></PositionCard>
+        <PositionCard :items="items"></PositionCard>
       </v-window-item>
     </v-window>
     <div class="text-center">
@@ -24,19 +24,44 @@
 
 <script setup name="hotPromotedPositions">
 import PositionCard from '@/components/Position/item.vue'
-import { ref } from 'vue'
-// import { getPromotedPosition } from '@/api/personal/position'
+import { ref, reactive } from 'vue'
+import { getPromotedPosition, getLatestPosition, getUrgentPosition } from '@/api/position'
 import { getDict } from '@/hooks/web/useDictionaries'
 
-const tab = ref(0)
+const tab = ref(1)
+const items = ref([])
+const dictObj = reactive({
+  payUnit: [], // 薪资单位
+  scale: [], // 规模
+  industry: [] // 行业
+})
+const dictList = [
+  { type: 'menduner_pay_unit', value: 'payUnit', key: 'payUnit', label: 'payName' },
+  { type: 'menduner_scale', value: 'scale', key: 'scale', label: 'scaleName' }
+  // { type: 'menduner_industry_type', value: 'industry', key: 'industryId', label: 'industryName', params: {} }
+]
 
 // 推荐职位
-// const getPositionList = async () => {
-//   const { list } = await getPromotedPosition({ pageNo: 1, pageSize: 10 })
-//   console.log(list, 'list')
-// }
-// getPositionList()
+const getPositionList = async () => {
+  const api = tab.value === 1 ? getPromotedPosition : (tab.value === 2 ? getLatestPosition : getUrgentPosition)
+  const { list } = await api({ pageNo: 1, pageSize: 9 })
+  dictList.forEach(item => {
+    items.value = list.map(e => {
+      // const valueKey = item.type === 'menduner_industry_type' ? 'nameCn' : 'label'
+      // const idKey = item.type === 'menduner_industry_type' ? 'id' : 'value'
+      e[item.label] = dictObj[item.value].find(k => Number(k.value) === e[item.key]).label
+      return e
+    })
+  })
+}
 
-const uuu = getDict('menduner_business_status')
-console.log(uuu, 'gggg')
+// 字典
+const getDictList = async () => {
+  dictList.forEach(async (val) => {
+    const { data } = await getDict(val.type, val.params)
+    dictObj[val.value] = data
+  })
+}
+getDictList()
+getPositionList()
 </script>