Blame view

src/components/MainTitleList.vue 3.5 KB
sanmu authored
1
<template>
sanmu authored
2
  <div class="text-blue-darken-1 text-h4 text-sm-h3 tw-text-center tw-mb-[16px] font-weight-bold">
sanmu authored
3
    <div :class="titleCls">{{ title }}</div>
sanmu authored
4
  </div>
sanmu authored
5
  <div class="text-body-1 tw-max-w-[600px] tw-m-auto tw-mb-8">
sanmu authored
6
7
8
    <span class="tw-mb-[64px] tw-max-w-[600px] tw-m-auto font-weight-medium text-grey-darken-1">{{
      desc
    }}</span>
sanmu authored
9
10
    <router-link :to="href" v-if="href">
      <span
sanmu authored
11
        class="font-weight-bold text-decoration-underline tw-inline-block tw-underline tw-text-sky-500 hover:tw-text-sky-800"
sanmu authored
12
13
14
15
16
17
18
        >detail
        <v-icon class="tw-mt-[-4px]" size="18" icon="mdi-arrow-right"></v-icon>
      </span>
    </router-link>
  </div>
  <v-item-group multiple v-if="!responsive">
    <v-row>
sanmu authored
19
      <v-col v-for="(item, index) in list" :key="index" cols="6" :lg="lgCol" md="4" sm="6">
sanmu authored
20
21
        <v-hover v-slot="{ isHovering, props }" open-delay="200" :disabled="disabled">
          <v-card
sanmu authored
22
            color="blue-darken-1"
sanmu authored
23
            variant="outlined"
sanmu authored
24
25
26
            :elevation="isHovering ? 16 : 2"
            :class="{ 'on-hover': isHovering }"
            class="mx-auto"
sanmu authored
27
            max-width="260"
sanmu authored
28
            v-bind="props"
sanmu authored
29
            @click="handleCardClick(item)"
sanmu authored
30
          >
sanmu authored
31
            <v-img :src="item.imageUrl" :alt="item.name" />
sanmu authored
32
            <div class="text-center bg-blue-darken-1 tw-text-center tw-w-full tw-h-9 tw-leading-9">
sanmu authored
33
              {{ item.name }}
sanmu authored
34
            </div>
sanmu authored
35
36
37
38
39
40
41
42
43
44
          </v-card>
        </v-hover>
      </v-col>
    </v-row>
  </v-item-group>
  <v-item-group multiple v-if="responsive">
    <v-row>
      <v-col v-for="(item, index) in list" :key="index">
        <v-hover v-slot="{ isHovering, props }" open-delay="200" :disabled="disabled">
          <v-card
sanmu authored
45
            color="blue-darken-1"
sanmu authored
46
            variant="outlined"
sanmu authored
47
48
            :elevation="isHovering ? 16 : 2"
            :class="{ 'on-hover': isHovering }"
sanmu authored
49
            class="pt-5 mx-auto"
sanmu authored
50
51
            height="350"
            v-bind="props"
sanmu authored
52
            :href="item.href ? item.href : undefined"
sanmu authored
53
            @click="handleCardClick(item)"
sanmu authored
54
          >
sanmu authored
55
56
            <v-img :src="item.imageUrl" width="250" class="text-center ma-auto" />
            <div
sanmu authored
57
              class="text-center bg-blue-darken-1 tw-absolute tw-bottom-0 tw-text-center tw-w-full tw-h-9 tw-leading-9"
sanmu authored
58
            >
sanmu authored
59
              {{ item.name }}
sanmu authored
60
            </div>
sanmu authored
61
62
63
64
65
66
67
68
69
          </v-card>
        </v-hover>
      </v-col>
    </v-row>
  </v-item-group>
</template>

<script setup lang="ts">
import type { Category } from '@/type'
sanmu authored
70
import { computed } from 'vue'
sanmu authored
71
sanmu authored
72
73
74
75
76
77
78
79
import { useCategoryStore } from '@/stores/category'
import { useRouter } from 'vue-router'
import { useProductListStore } from '@/stores/product_list'

const router = useRouter()
const categoryStore = useCategoryStore()
const productStore = useProductListStore()
sanmu authored
80
81
82
const props = defineProps<{
  title: string
  desc?: string
sanmu authored
83
  list: Category[] | { name: string; imageUrl?: string; href?: string }[]
sanmu authored
84
85
86
87
88
89
  cardNum?: number
  href?: string
  disabled?: boolean
  responsive?: boolean
  titleCls?: string
  titleDivider?: boolean
sanmu authored
90
  listType?: string
sanmu authored
91
92
93
}>()

const lgCol = computed(() => (props.cardNum === 3 ? 4 : 3))
sanmu authored
94
95

const handleCardClick = (item: any) => {
sanmu authored
96
  console.log('%c [ item ]-96', 'font-size:13px; background:pink; color:#bf2c9f;', item)
sanmu authored
97
98
99
100
  if (props.listType !== 'equipment' && item.href) {
    router.push(item.href)
  } else {
    categoryStore.updateCategory(categoryStore.list[3].categoryDisplayName)
sanmu authored
101
    categoryStore.updateSubCategory(item.id)
sanmu authored
102
103
104
105
    productStore.updatePageNo(1)
    router.push(item.href)
  }
}
sanmu authored
106
</script>