sanmu
authored
about a year ago
1
2
3
4
5
6
<template>
<div class="tw-m-auto tw-pb-[64px]">
<CategoryList v-if="categoryStore.categoryVisible && !isMobile()" />
<MobileCategoryList v-if="categoryStore.categoryVisible && isMobile()" />
<v-container class="">
<div class="tw-text-center" v-if="loading">
7
8
9
10
11
12
<v-progress-circular
color="blue-lighten-2"
indeterminate
size="64"
class="tw-m-auto"
></v-progress-circular>
sanmu
authored
about a year ago
13
14
15
</div>
<v-item-group multiple>
<v-row v-if="!loading">
16
17
18
19
20
21
22
23
<v-col
v-for="(item, i) in productStore.list"
:key="i"
cols="6"
lg="3"
md="4"
sm="6"
>
sanmu
authored
about a year ago
24
<v-hover v-slot="{ isHovering, props }" open-delay="200">
25
26
27
28
29
30
31
<v-card
:elevation="isHovering ? 16 : 2"
:class="{ 'on-hover': isHovering }"
class="mx-auto"
v-bind="props"
:to="`/products/detail/${item.id}`"
>
sanmu
authored
about a year ago
32
33
34
35
36
37
38
39
40
41
42
<v-img :src="item.imgList[0].url" :alt="item.name">
<!-- <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
10 months ago
43
<v-card-text class="tw-text-left font-weight-medium title">
44
45
46
<h3 style="color: red" v-if="item.price">
${{ item.price }}
</h3>
47
<h4>{{ item.name }}</h4>
sanmu
authored
10 months ago
48
</v-card-text>
sanmu
authored
about a year ago
49
50
51
52
</v-card>
</v-hover>
</v-col>
</v-row>
53
54
55
56
<div
v-if="!productStore.total && !loading"
class="text-medium-emphasis text-body-1 tw-text-center tw-m-[64px]"
>
sanmu
authored
about a year ago
57
58
59
60
61
no data
</div>
</v-item-group>
<v-row>
<v-col>
62
63
64
65
66
67
68
69
70
71
72
<v-pagination
:size="isMobile() ? 'small' : 'default'"
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
about a year ago
73
74
75
76
77
</v-container>
</div>
</template>
<script setup lang="ts">
78
79
80
81
82
83
import { isMobile, isEqual } from "~/utils";
import { useProductListStore } from "~/stores/product_list";
import { useCategoryStore } from "~/stores/category";
import CategoryList from "~/components/CategoryList.vue";
import MobileCategoryList from "~/components/MobileCategoryList.vue";
import { watchEffect, computed, ref } from "vue";
sanmu
authored
about a year ago
84
85
86
87
88
const productStore = useProductListStore();
const categoryStore = useCategoryStore();
const loading = ref(false);
const route = useRoute(); // 获取路由信息
89
90
91
92
93
94
95
96
97
98
99
100
const router = useRouter(); // 获取路由信息
const title = ref("");
watchEffect(() => {
// 遍历数组
if (router.currentRoute.value.query.categories) {
title.value = `${router.currentRoute.value.query.categories}`;
}
if (router.currentRoute.value.query.function) {
title.value += `,${router.currentRoute.value.query.function}`;
}
// document.title = title.value;
});
101
102
useHead({
103
title: title.value,
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
meta: [
{
name: "title",
content:
"科路得,助您科研之路势在必得。Canrd aims to be the world's leading one-stop service provider in new energy research. With a dedication to excellence, we offer Material Reagents, Lab Devices, Customized Batteries, Testing, and Advanced Packaging for energy materials and storage systems. We master advanced technologies to provide high-quality solutions. Our team's quick responses ensure tailored and professional services to meet your unique needs. Contact us at contact@canrd.com or call +86 19867737979 to explore our innovative offerings. Together, let's shape a greener, brighter world!",
},
{
name: "keywords",
content:
"科路得,canrd,canrud,Energy Storage Research,Lithium Batteries Research,Material Reagents,Lab Device,Customized Battery,Testing,Pack",
},
{
name: "description",
content:
"科路得,助您科研之路势在必得。We offer a wide range of research materials and related equipment, technical services, and battery material performance evaluation in areas such as pouch cells, lithium-ion batteries, supercapacitors, lithium-sulfur batteries, fuel cells, lithium-air batteries, and sodium-ion batteries.",
},
],
});
122
123
const loadProducts = async () => {
sanmu
authored
about a year ago
124
125
let params: any = {
pageNo: productStore.pageNo,
126
127
pageSize: 20,
};
sanmu
authored
about a year ago
128
129
loading.value = true;
sanmu
authored
about a year ago
130
if (productStore.keyword && !isEqual(productStore.params, params)) {
131
132
133
134
135
params.keyword = productStore.keyword;
productStore.updateParams(params);
await productStore.getList(params);
loading.value = false;
return;
sanmu
authored
about a year ago
136
137
}
138
params.productCategoryId = categoryStore.selectedSubCategory;
sanmu
authored
about a year ago
139
140
141
// productCategoryId: '78b86c6e917841cf9a292234f2805e24',
if (categoryStore.selectedFuncCategory) {
142
params.productFunctionId = categoryStore.selectedFuncCategory;
sanmu
authored
about a year ago
143
144
}
145
146
147
148
149
if (
categoryStore.selectedSubCategory &&
!isEqual(productStore.params, params)
) {
productStore.updateParams(params);
sanmu
authored
about a year ago
150
151
await productStore.getList(params);
sanmu
authored
about a year ago
152
}
153
154
loading.value = false;
};
155
156
watchEffect(async () => {
157
158
if (route.query.keyword !== undefined) {
productStore.keyword = route.query.keyword;
159
160
}
loadProducts();
161
});
sanmu
authored
about a year ago
162
163
164
const length = computed(() =>
productStore.total ? Math.ceil(productStore.total / productStore.pageSize) : 0
165
);
sanmu
authored
about a year ago
166
167
168
169
170
171
172
173
174
175
176
177
</script>
<style scoped>
.title {
height: 60px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
</style>