index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <slot name="header"></slot>
  3. <view class="content">
  4. <view v-for="item in items" :key="item.label" class="content-box default-text-color" @tap="handleTo(item)">
  5. <view class="content-box-value MiSans-Semibold">
  6. {{ item.count }}
  7. </view>
  8. <view class="content-box-title MiSans-Normal">
  9. {{ item.label }}
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script setup>
  15. import { ref, watch } from 'vue';
  16. import { getRecommendCount } from '@/api/position.js'
  17. import { getDict } from '@/hooks/useDictionaries.js'
  18. import { onShow } from '@dcloudio/uni-app'
  19. // const props = defineProps({
  20. // type: {
  21. // type: String,
  22. // default: 'menduner_hire_job_cv_status'
  23. // }
  24. // })
  25. import { userStore } from '@/store/user'
  26. const useUserStore = userStore()
  27. // 监听登录状态
  28. watch(() => useUserStore.refreshToken, (newVal, oldVal) => {
  29. const reset = Boolean(!newVal)
  30. recommendCount(reset)
  31. })
  32. onShow(() => {
  33. recommendCount()
  34. })
  35. const items = ref([])
  36. const handleTo = (item) => {
  37. uni.navigateTo({
  38. url: `/pagesA/recommendation/index?id=${item.value}`
  39. })
  40. }
  41. async function recommendCount (reset = false) {
  42. try {
  43. const { data: dict } = await getDict('menduner_hire_job_cv_status')
  44. if (!dict?.data) {
  45. return
  46. }
  47. items.value = dict.data.map(e => {
  48. return {
  49. ...e,
  50. count: 0
  51. }
  52. })
  53. // console.log(items)
  54. if (reset) {
  55. return
  56. }
  57. const { data } = await getRecommendCount()
  58. if (!data) {
  59. return
  60. }
  61. items.value.forEach(e => {
  62. e.count = data.find(_e => _e.key === e.value)?.value || 0
  63. })
  64. } catch (error) {
  65. // console.log(error)
  66. }
  67. }
  68. </script>
  69. <style scoped lang="scss">
  70. .content {
  71. display: flex;
  72. justify-content: space-around;
  73. padding: 20rpx 20rpx 20rpx 0;
  74. &-box {
  75. text-align: center;
  76. z-index: 1 !important;
  77. &-value {
  78. font-size: 30rpx;
  79. }
  80. &-title {
  81. font-size: 24rpx;
  82. }
  83. }
  84. }
  85. </style>