index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. import { onLoad } from '@dcloudio/uni-app'
  26. const current = ref(0)
  27. // 获取参数
  28. const controlList = ref([])
  29. const controlListText = ref([])
  30. const pageInfo = ref({
  31. pageNo: 1,
  32. pageSize: 10
  33. })
  34. const total = ref(0)
  35. const items = ref([])
  36. const loading = ref(false)
  37. const more = ref('more')
  38. async function initDict () {
  39. try {
  40. const { data } = await getDict('menduner_hire_job_cv_status')
  41. if (!data?.data) {
  42. return
  43. }
  44. controlList.value = data.data
  45. controlListText.value = data.data.map(e => e.label)
  46. // current.value = +controlList.value[0].value
  47. init()
  48. } catch (error) {
  49. // console.log(error)
  50. }
  51. }
  52. function handleChange (val) {
  53. current.value = val.currentIndex
  54. pageInfo.value.pageNo = 1
  55. total.value = 0
  56. items.value = []
  57. init()
  58. }
  59. function loadingMore () {
  60. if (total.value === items.value.length) {
  61. return
  62. }
  63. if (loading.value) {
  64. return
  65. }
  66. more.value = 'loading'
  67. pageInfo.value.pageNo++
  68. init()
  69. }
  70. async function init () {
  71. try {
  72. loading.value = true
  73. const { data } = await getRecommendationList({
  74. ...pageInfo.value,
  75. status: current.value
  76. })
  77. if (!data?.list) {
  78. pageInfo.value.pageNo--
  79. return
  80. }
  81. items.value.push(...data.list)
  82. total.value = +data.total
  83. more.value = items.value.length === total.value ? 'noMore' : 'more'
  84. } catch (error) {
  85. pageInfo.value.pageNo--
  86. } finally {
  87. loading.value = false
  88. }
  89. }
  90. onLoad(async (options) => {
  91. if (options?.id) {
  92. current.value = +options.id
  93. }
  94. initDict()
  95. })
  96. </script>
  97. <style lang="scss" scoped>
  98. </style>