12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <template>
- <slot name="header"></slot>
- <view class="content">
- <view v-for="(item,index) in items" :key="item.label" class="content-box" @tap="handleTo(item)">
- <view class="content-box-value">
- {{ item.count }}
- </view>
- <view class="content-box-title">
- {{ item.label }}
- </view>
- </view>
- </view>
-
- </template>
- <script setup>
- import { ref, watch } from 'vue';
- import { getRecommendCount } from '@/api/position.js'
- import { getDict } from '@/hooks/useDictionaries.js'
- // const props = defineProps({
- // type: {
- // type: String,
- // default: 'menduner_hire_job_cv_status'
- // }
- // })
- import { userStore } from '@/store/user'
- const useUserStore = userStore()
- watch(() => useUserStore.isLogin, (newVal, oldVal) => {
- if (useUserStore.isLogin) {
- // 监听登录状态
- console.log('重新登录了')
- recommendCount()
- }
- })
- const items = ref([])
- const handleTo = (item) => {
- uni.navigateTo({
- url: `/pagesA/recommendation/index?id=${item.value}`
- })
- }
- async function recommendCount () {
- try {
- const { data: dict } = await getDict('menduner_hire_job_cv_status')
- if (!dict?.data) {
- return
- }
- items.value = dict.data.map(e => {
- return {
- ...e,
- count: 0
- }
- })
- // console.log(items)
- const { data } = await getRecommendCount()
- if (!data) {
- return
- }
- items.value.forEach(e => {
- e.count = data.find(_e => _e.key === e.value)?.value || 0
- })
- } catch (error) {
- // console.log(error)
- }
- }
- recommendCount()
- </script>
- <style scoped lang="scss">
- .content {
- display: flex;
- justify-content: space-around;
- padding: 36rpx 12rpx;
- &-box {
- font-size: 24rpx;
- color: #999;
- text-align: center;
- &-value {
- font-size: 1.8em;
- color: #000;
- }
- }
- }
- </style>
|