index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <layout-page>
  3. <uni-segmented-control :current="current" :values="controlListText" @clickItem="handleChange" styleType="text" activeColor="#00897B"></uni-segmented-control>
  4. <scroll-view class="scrollBox defaultBgc" scroll-y="true" @scrolltolower="loadingMore" style="height: calc(100vh - 72rpx);">
  5. <view v-if="items.length" class="listBox">
  6. <m-list :items="items"></m-list>
  7. <uni-load-more :status="more" />
  8. </view>
  9. <view v-else class="nodata-img-parent">
  10. <image
  11. src="https://minio.citupro.com/dev/static/nodata.png"
  12. mode="widthFix"
  13. style="width: 100vw;height: 100vh;"
  14. ></image>
  15. </view>
  16. </scroll-view>
  17. </layout-page>
  18. </template>
  19. <script setup>
  20. import { ref } from 'vue'
  21. import layoutPage from '@/layout'
  22. import MList from './list'
  23. import { getDict } from '@/hooks/useDictionaries.js'
  24. import { getRecommendationList } from '@/api/position.js'
  25. const current = ref(0)
  26. const controlList = ref([])
  27. const controlListText = ref([])
  28. const pageInfo = ref({
  29. pageNo: 1,
  30. pageSize: 10
  31. })
  32. const total = ref(0)
  33. const items = ref([])
  34. const loading = ref(false)
  35. const more = ref('more')
  36. async function initDict () {
  37. try {
  38. const { data } = await getDict('menduner_hire_job_cv_status')
  39. if (!data?.data) {
  40. return
  41. }
  42. controlList.value = data.data
  43. controlListText.value = data.data.map(e => e.label)
  44. current.value = +controlList.value[0].value
  45. init()
  46. } catch (error) {
  47. // console.log(error)
  48. }
  49. }
  50. function handleChange (val) {
  51. current.value = val.currentIndex
  52. pageInfo.value.pageNo = 1
  53. total.value = 0
  54. items.value = []
  55. init()
  56. }
  57. function loadingMore () {
  58. if (total.value === items.value.length) {
  59. return
  60. }
  61. if (loading.value) {
  62. return
  63. }
  64. more.value = 'loading'
  65. pageInfo.value.pageNo++
  66. init()
  67. }
  68. async function init () {
  69. try {
  70. loading.value = true
  71. const { data } = await getRecommendationList({
  72. ...pageInfo.value,
  73. status: current.value
  74. })
  75. if (!data?.list) {
  76. pageInfo.value.pageNo--
  77. return
  78. }
  79. items.value.push(...data.list)
  80. total.value = +data.total
  81. more.value = items.value.length === total.value ? 'noMore' : 'more'
  82. } catch (error) {
  83. pageInfo.value.pageNo--
  84. } finally {
  85. loading.value = false
  86. }
  87. }
  88. initDict()
  89. </script>
  90. <style lang="scss" scoped>
  91. </style>