index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. // const props = defineProps({
  19. // type: {
  20. // type: String,
  21. // default: 'menduner_hire_job_cv_status'
  22. // }
  23. // })
  24. import { userStore } from '@/store/user'
  25. const useUserStore = userStore()
  26. watch(() => useUserStore.isLogin, (newVal, oldVal) => {
  27. if (useUserStore.isLogin) {
  28. // 监听登录状态
  29. console.log('重新登录了')
  30. recommendCount()
  31. }
  32. })
  33. const items = ref([])
  34. const handleTo = (item) => {
  35. uni.navigateTo({
  36. url: `/pagesA/recommendation/index?id=${item.value}`
  37. })
  38. }
  39. async function recommendCount () {
  40. try {
  41. const { data: dict } = await getDict('menduner_hire_job_cv_status')
  42. if (!dict?.data) {
  43. return
  44. }
  45. items.value = dict.data.map(e => {
  46. return {
  47. ...e,
  48. count: 0
  49. }
  50. })
  51. // console.log(items)
  52. const { data } = await getRecommendCount()
  53. if (!data) {
  54. return
  55. }
  56. items.value.forEach(e => {
  57. e.count = data.find(_e => _e.key === e.value)?.value || 0
  58. })
  59. } catch (error) {
  60. // console.log(error)
  61. }
  62. }
  63. recommendCount()
  64. </script>
  65. <style scoped lang="scss">
  66. .content {
  67. display: flex;
  68. justify-content: space-around;
  69. padding: 36rpx 12rpx;
  70. &-box {
  71. font-size: 24rpx;
  72. color: #999;
  73. text-align: center;
  74. &-value {
  75. font-size: 1.8em;
  76. color: #000;
  77. }
  78. }
  79. }
  80. </style>