search.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <layout-page>
  3. <view >
  4. <view style="padding: 0 15px 0 15px;">
  5. <uni-segmented-control
  6. :current="current"
  7. :values="tabList"
  8. @clickItem="changeControl"
  9. styleType="text"
  10. activeColor="#00B760"
  11. ></uni-segmented-control>
  12. </view>
  13. <!-- 职位推荐 -->
  14. <RecommendPage v-if="current === 0" :jobList="jobList" />
  15. <!-- 条件筛选 -->
  16. <ConditionPage v-else />
  17. </view>
  18. </layout-page>
  19. </template>
  20. <script setup>
  21. import layoutPage from '@/layout'
  22. import { ref } from 'vue'
  23. import { onShow } from '@dcloudio/uni-app'
  24. import { getAccessToken } from '@/utils/request'
  25. import { showAuthModal } from '@/hooks/useModal'
  26. import { getJobAdvertised } from '@/api/search'
  27. import { dealDictArrayData } from '@/utils/position'
  28. import { formatName } from '@/utils/getText'
  29. import RecommendPage from './components/recommend.vue'
  30. import ConditionPage from './components/condition.vue'
  31. const current = ref(1)
  32. const tabList = ['职位推荐', '条件筛选']
  33. // 职位列表
  34. const jobList = ref([])
  35. const getJobList = async () => {
  36. const { data } = await getJobAdvertised({ status: 0 })
  37. if (data.length) {
  38. const list = dealDictArrayData([], data)
  39. jobList.value = list.map(e => {
  40. return { text: `${formatName(e.name)}_${e.areaName ? e.area?.str : '全国'}`, value: e.id, data: e }
  41. })
  42. }
  43. }
  44. onShow(() => {
  45. // 设置自定义tabbar选中值
  46. const currentPage = getCurrentPages()[0] // 获取当前页面实例
  47. const currentTabBar = currentPage?.getTabBar?.()
  48. // 设置当前tab页的下标index
  49. currentTabBar?.setData({ selected: 0 })
  50. if (!getAccessToken()) return showAuthModal()
  51. getJobList()
  52. })
  53. const changeControl = (e) =>{
  54. current.value = e.currentIndex
  55. }
  56. </script>
  57. <style scoped lang="scss">
  58. </style>