sanmu
authored
|
1
|
<template>
|
sanmu
authored
|
2
|
<div class="tw-m-auto tw-pb-[64px]">
|
sanmu
authored
|
3
4
|
<CategoryList />
<v-container class="">
|
sanmu
authored
|
5
6
|
<div class="tw-text-center" v-if="loading">
<v-progress-circular
|
sanmu
authored
|
7
|
color="blue-lighten-2"
|
sanmu
authored
|
8
9
10
11
12
|
indeterminate
size="64"
class="tw-m-auto"
></v-progress-circular>
</div>
|
sanmu
authored
|
13
|
<v-item-group multiple>
|
sanmu
authored
|
14
|
<v-row v-if="!loading">
|
sanmu
authored
|
15
16
17
18
19
20
21
22
23
24
25
|
<v-col v-for="(item, i) in productStore.list" :key="i" cols="12" lg="3" md="4" sm="6">
<v-hover v-slot="{ isHovering, props }" open-delay="200">
<v-card
:elevation="isHovering ? 16 : 2"
:class="{ 'on-hover': isHovering }"
class="mx-auto"
height="350"
width="260"
v-bind="props"
:to="`/products/detail/${item.id}`"
>
|
sanmu
authored
|
26
|
<v-img :src="item.imgList[0].url" height="280">
|
sanmu
authored
|
27
28
29
30
31
32
33
34
35
36
|
<!-- <v-expand-transition>
<div
v-if="isHovering"
class="d-flex transition-fast-in-fast-out bg-orange-darken-2 v-card--reveal tw-p-[12px] tw-text-justify"
style="height: 100%"
>
产品描述描述描述描述描述描述描述描述
</div>
</v-expand-transition> -->
</v-img>
|
sanmu
authored
|
37
38
39
|
<v-card-text class="tw-text-left font-weight-medium title">{{
item.name
}}</v-card-text>
|
sanmu
authored
|
40
41
42
43
|
</v-card>
</v-hover>
</v-col>
</v-row>
|
sanmu
authored
|
44
45
46
47
48
49
|
<div
v-if="!productStore.total && !loading"
class="text-medium-emphasis text-body-1 tw-text-center tw-m-[64px]"
>
no data
</div>
|
sanmu
authored
|
50
|
</v-item-group>
|
sanmu
authored
|
51
52
53
54
55
56
57
58
59
60
61
62
|
<v-row>
<v-col>
<v-pagination
v-if="productStore.total"
v-model="productStore.pageNo"
@update:modelValue="productStore.updatePageNo"
:length="length"
rounded="0"
class="tw-float-right tw-mt-[32px]"
total-visible="5"
></v-pagination></v-col
></v-row>
|
sanmu
authored
|
63
64
65
66
67
68
69
70
|
</v-container>
</div>
</template>
<script setup lang="ts">
import { useProductListStore } from '@/stores/product_list'
import { useCategoryStore } from '@/stores/category'
import CategoryList from '@/components/CategoryList.vue'
|
sanmu
authored
|
71
|
import { watchEffect, computed, ref } from 'vue'
|
sanmu
authored
|
72
|
import { isEqual } from 'lodash'
|
sanmu
authored
|
73
74
75
|
const productStore = useProductListStore()
const categoryStore = useCategoryStore()
|
sanmu
authored
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
const loading = ref(false)
watchEffect(async () => {
let params = {
// productCategoryId: '78b86c6e917841cf9a292234f2805e24',
productCategoryId: categoryStore.selectedSubCategory,
pageNo: productStore.pageNo,
pageSize: 20
} as any
if (categoryStore.selectedFuncCategory) {
params.productFunctionId = categoryStore.selectedFuncCategory
}
|
sanmu
authored
|
90
91
92
93
|
if (productStore.keyword) {
params.keyword = productStore.keyword
}
|
sanmu
authored
|
94
95
96
97
98
|
if (categoryStore.selectedSubCategory && !isEqual(productStore.params, params)) {
loading.value = true
productStore.updateParams(params)
await productStore.getList(params)
loading.value = false
|
sanmu
authored
|
99
100
101
|
}
})
|
sanmu
authored
|
102
103
104
105
|
const length = computed(() =>
productStore.total ? Math.ceil(productStore.total / productStore.pageSize) : 0
)
</script>
|
sanmu
authored
|
106
107
108
109
110
111
112
113
114
115
116
|
<style scoped>
.title {
height: 60px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
</style>
|