index-card-task.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <index-card v-if="taskRoutes.length" title="班级任务">
  3. <index-card-content :list="taskRoutes" :line-size="6">
  4. <template #default="{item}">
  5. <div class="fx-column ai-cen active-pointer" :style="item.style" @click="$router.push(item.path)">
  6. <div class="index-banner task-item"/>
  7. <div class="mt15 f16 bold">{{ item.title }}</div>
  8. </div>
  9. </template>
  10. </index-card-content>
  11. </index-card>
  12. </template>
  13. <script>
  14. import {mapGetters} from 'vuex'
  15. import IndexCard from "@/views/index/components/index-card.vue";
  16. import IndexCardContent from "@/views/index/components/index-card-content.vue";
  17. export default {
  18. name: "index-card-task",
  19. components: {IndexCardContent, IndexCard},
  20. computed: {
  21. ...mapGetters(['middlebarRouters']),
  22. taskRoutes() {
  23. const parentRoute = this.middlebarRouters.find(item => item.meta.title == '班级任务')
  24. if (!parentRoute) return []
  25. return parentRoute.children.map((item, idx) => {
  26. return {
  27. path: item.path,
  28. title: item.meta.title,
  29. style: {
  30. '--bg-img': `url(${this.$imgBase}2023/index/lib/${item.meta.imgName}.png)`,
  31. '--bg-img-selected': `url(${this.$imgBase}2023/index/lib/${item.meta.imgName}-selected.png)`
  32. }
  33. }
  34. })
  35. },
  36. },
  37. }
  38. </script>
  39. <style scoped lang="scss">
  40. .active-pointer .task-item {
  41. width: 112px;
  42. height: 112px;
  43. background-image: var(--bg-img);
  44. }
  45. .active-pointer:hover .task-item {
  46. background-image: var(--bg-img-selected);
  47. }
  48. </style>