search.vue 1.7 KB

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