index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <slot name="header"></slot>
  3. <view class="content">
  4. <view v-for="(item,index) in items" :key="item.label" class="content-box" @tap="handleTo(item)">
  5. <view class="content-box-value">
  6. {{ item.count }}
  7. </view>
  8. <view class="content-box-title">
  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. watch(() => useUserStore.refreshToken, (newVal, oldVal) => {
  28. if (useUserStore.refreshToken) {
  29. // 监听登录状态
  30. console.log('重新登录了')
  31. recommendCount()
  32. }
  33. })
  34. onShow(() => {
  35. recommendCount()
  36. })
  37. const items = ref([])
  38. const handleTo = (item) => {
  39. uni.navigateTo({
  40. url: `/pagesA/recommendation/index?id=${item.value}`
  41. })
  42. }
  43. async function recommendCount () {
  44. try {
  45. const { data: dict } = await getDict('menduner_hire_job_cv_status')
  46. if (!dict?.data) {
  47. return
  48. }
  49. items.value = dict.data.map(e => {
  50. return {
  51. ...e,
  52. count: 0
  53. }
  54. })
  55. // console.log(items)
  56. const { data } = await getRecommendCount()
  57. if (!data) {
  58. return
  59. }
  60. items.value.forEach(e => {
  61. e.count = data.find(_e => _e.key === e.value)?.value || 0
  62. })
  63. } catch (error) {
  64. // console.log(error)
  65. }
  66. }
  67. </script>
  68. <style scoped lang="scss">
  69. .content {
  70. display: flex;
  71. justify-content: space-around;
  72. padding: 36rpx 12rpx;
  73. &-box {
  74. font-size: 24rpx;
  75. color: #999;
  76. text-align: center;
  77. &-value {
  78. font-size: 1.8em;
  79. color: #000;
  80. }
  81. }
  82. }
  83. </style>