ProductDetail.vue
12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<template>
<v-container>
<div>
<v-breadcrumbs divider="/" style="padding-top: 0">
<template v-for="(item, index) in items" :key="index">
<v-breadcrumbs-item
:disabled="item.disabled"
:href="item.href"
:class="{
'breadcrumb-disabled': item.disabled,
'breadcrumb-active': !item.disabled,
}"
>
{{ item.title }}
</v-breadcrumbs-item>
<!-- 添加分隔符,排除最后一个 item -->
<span v-if="index < items.length - 1" class="breadcrumb-divider"
>/</span
>
</template>
<span class="breadcrumb-divider">/</span>
<span style="margin-left: 5px">{{ info.name }}</span>
</v-breadcrumbs>
</div>
<v-row class="mb-16 ma-0">
<v-col cols="12" sm="5" class="carousel-container">
<v-carousel
class="tw-float-left tw-sticky tw-top-[16px]"
height="450"
v-model="slide"
hide-delimiter-background
style="top: 16px"
>
<v-carousel-item
cover
v-for="(slide, i) in info.productimageliststore"
:src="slide.url"
:key="i"
:alt="info.name"
>
</v-carousel-item>
</v-carousel>
</v-col>
<v-col cols="12" sm="7" class="table-container">
<!-- <v-row class="bg-white mb-sm-10 text-h4 font-weight-medium">
<v-col>{{ info.name }}</v-col>
</v-row> -->
<h1>{{ info.name }}</h1>
<div class="tw-flex tw-flex-wrap">
<div class="tw-w-1/2">
<span class="tw-leading-[10px] tw-m-[16px]">
Brand:{{ info.brandName }}
</span>
</div>
<div class="tw-w-1/2 tw-mb-[12px]">
<span class="tw-leading-[10px] tw-m-[16px]"
>Product Model:{{ info.model }}</span
>
</div>
<div class="tw-w-1/2 tw-mb-[12px]" v-if="info.basename1">
<span class="tw-leading-[10px] tw-m-[16px]"
>{{ info.basename1 }}:{{ info.basecore1 }}</span
>
</div>
<div class="tw-w-1/2 tw-mb-[12px]" v-if="info.basename2">
<span class="tw-leading-[10px] tw-m-[16px]"
>{{ info.basename2 }}:{{ info.basecore2 }}</span
>
</div>
<div class="tw-w-1/2 tw-mb-[12px]" v-if="info.basename3">
<span class="tw-leading-[10px] tw-m-[16px]"
>{{ info.basename3 }}:{{ info.basecore3 }}</span
>
</div>
</div>
<div
class="tw-flex tw-flex-wrap"
v-if="
info.productAttributeList && info.productAttributeList.length > 0
"
>
<div
v-for="(attribute, index) in info.productAttributeList"
:key="index"
class="tw-w-1/2 tw-mb-[12px]"
>
<span class="tw-leading-[10px] tw-m-[16px]"
>{{ attribute.name }}:{{ attribute.value }}</span
>
</div>
</div>
<!-- <v-table
density="comfortable"
class="table1 tw-mt-[32px]"
v-if="info.ticketTypes?.length"
> -->
<v-table
density="comfortable"
class="table1 tw-mt-[32px] tw-overflow-x-auto"
v-if="info.ticketTypes?.length"
>
<thead>
<tr class="bg-grey-lighten-3">
<th class="text-left headerBorder text-grey-darken-1">
Product Name / Code
</th>
<th class="text-left headerBorder text-grey-darken-1">
Specification and model
</th>
<th
v-if="info.priceShow !== undefined && info.priceShow"
class="text-left headerBorder text-grey-darken-1"
>
Price
</th>
<th class="text-left headerBorder text-grey-darken-1">Actions</th>
</tr>
</thead>
<tbody>
<tr
class="tr"
v-for="item in info.ticketTypes || []"
:key="item.rank"
>
<td class="td text-grey-darken-4 font-weight-medium">
{{ item.rank }}
</td>
<td class="td text-grey-darken-4 font-weight-medium">
{{ item.typeName }}
</td>
<td v-if="item.priceShow" class="td">
{{ item.price + " " + item.priceUnit }}
</td>
<td class="td">
<v-btn
size="small"
color="blue-darken-1"
@click="router.push('/contact')"
>
<!-- Quotation Inquiry -->
Quote
</v-btn>
</td>
</tr>
</tbody>
</v-table>
<!-- <v-dialog v-model="dialog" activator="parent" width="auto">
<v-card> Contact us Email: contact@canrd.com QQ: 3003597584 / 2902385824 </v-card>
</v-dialog> -->
</v-col>
</v-row>
<div class="tw-pb-[64px]">
<v-tabs
class="tabs"
v-model="tab"
color="white"
bg-color="#eeeeee"
slider-color="blue-lighten-1"
selected-class="active"
>
<v-tab :value="1">Product Details</v-tab>
<v-tab :value="2">Specification</v-tab>
<!-- <v-tab :value="3">商品百科</v-tab> -->
</v-tabs>
<v-window v-model="tab" class="tw-p-[24px]">
<v-window-item key="1" :value="1">
<div v-if="info.advantage" class="tw-mb-[24px]">
<div class="text-h6">Advantage</div>
<v-divider class="tw-mb-[12px]"></v-divider>
<div v-html="info.advantage"></div>
</div>
<div v-if="info.physicalproperty" class="tw-mb-[24px]">
<div class="text-h6">Physical Property</div>
<v-divider class="tw-mb-[12px]"></v-divider>
<div v-html="info.physicalproperty"></div>
</div>
<div v-if="info.storage" class="tw-mb-[24px]">
<div class="text-h6">Storage</div>
<v-divider class="tw-mb-[12px]"></v-divider>
<div v-html="info.storage"></div>
</div>
<div v-if="info.introduction" class="tw-mb-[24px]">
<div class="text-h6">Introduction</div>
<v-divider class="tw-mb-[12px]"></v-divider>
<div v-html="info.introduction"></div>
</div>
<div v-if="info.description" class="tw-mb-[24px]">
<div class="text-h6">Description</div>
<v-divider class="tw-mb-[12px]"></v-divider>
<div v-html="info.description"></div>
</div>
</v-window-item>
<v-window-item key="2" :value="2">
<v-table density="compact" class="table2">
<tbody>
<tr
class="tr"
v-for="item in info.productAttributeList || []"
:key="item.name"
>
<td class="td tw-w-[400px]">{{ item.name }}</td>
<td class="td">{{ item.value }}</td>
</tr>
</tbody>
</v-table>
</v-window-item>
<!-- <v-window-item key="3" :value="3"> 2 </v-window-item> -->
</v-window>
</div>
</v-container>
</template>
<script setup lang="ts">
import type { Product, ProductImage } from "~/type";
import { onMounted, ref } from "vue";
import { useDialogStore } from "~/stores/dialog";
import { useRouter, useRoute } from "vue-router";
import { useRouteQuery } from "@/stores/route_query";
const route = useRoute();
const router = useRouter();
const routeQuery = useRouteQuery();
const dialogStore = useDialogStore();
const href1 = ref("/products");
const href2 = ref("/products");
// 定义单个 item 的接口
interface BreadcrumbItem {
title: string; // 标题
disabled: boolean; // 是否禁用
href: string; // 链接地址
}
// 示例数据
const items = ref<BreadcrumbItem[]>([
{
title: "Products",
disabled: false,
href: "/products",
},
{
title: "CATEGORY",
disabled: false,
href: href1.value,
},
{
title: "DEVICE TYPE",
disabled: false,
href: href2.value,
},
{
title: "FUNCTION",
disabled: false,
href: "/products",
},
// {
// title: "TITLE",
// disabled: false,
// href: "",
// },
]);
const props = defineProps<{
info: Product;
}>();
const info = props.info;
watchEffect(() => {
if (routeQuery.categories) {
if (!routeQuery.categories.includes("Energy materials")) {
routeQuery.updateFunction("Not specified");
}
const categories = routeQuery.categories.split(",");
const mainCategory = categories[0].trim(); // 取第一个值
const subCategoryName = ref(
categories[1] ? categories[1].trim() : "Not specified"
); // 取第二个值(如果存在)
if (subCategoryName.value == "Accessories & fixtures") {
subCategoryName.value = encodeURIComponent("Accessories & fixtures");
items.value[2].title = "Accessories & fixtures";
} else {
items.value[2].title = subCategoryName.value;
}
items.value[1].title = mainCategory;
items.value[1].href = href1.value + "?categories=" + mainCategory;
href1.value = href1.value + "?categories=" + mainCategory;
// items.value[1].title = subCategoryName.value;
href2.value = href1.value + "," + subCategoryName.value;
items.value[2].href = href1.value + "," + subCategoryName.value;
if (routeQuery?.selectedFunction) {
// items.value.push({
// title: routeQuery.selectedFunction,
// disabled: false,
// href: href2.value + "&function=" + routeQuery.selectedFunction,
// });
items.value[3].title = routeQuery.selectedFunction;
items.value[3].href =
href2.value + "&function=" + routeQuery.selectedFunction;
// routeQuery.updateFunction(null);
}
} else if (info?.productCrumbsVO?.category1) {
items.value[1].title = info.productCrumbsVO.category1;
items.value[1].href =
href1.value + "?categories=" + info.productCrumbsVO.category1;
href1.value = href1.value + "?categories=" + info.productCrumbsVO.category1;
if (info?.productCrumbsVO?.category2) {
items.value[2].title = info.productCrumbsVO.category2;
href2.value = href1.value + "," + info.productCrumbsVO.category2;
items.value[2].href = href1.value + "," + info.productCrumbsVO.category2;
}
if (info?.productCrumbsVO?.function) {
// items.value.push({
// title: info.productCrumbsVO.function,
// disabled: false,
// href: href2.value + "&function=" + info.productCrumbsVO.function,
// });
items.value[3].title = info.productCrumbsVO.function;
items.value[3].href =
href2.value + "&function=" + info.productCrumbsVO.function;
}
}
});
// onMounted(() => {
// dialogStore.updateDialog(true)
// })
const tab = ref(0);
const slide = ref(0);
</script>
<style lang="scss" scoped>
.headerBorder {
border-top: 3px solid #1f88e5 !important;
}
.tabs {
border-bottom: 2px solid #1f88e5;
}
.active {
background-color: #1086e8;
}
.td,
th {
border: 1px solid #dcdcdc;
border-right: 0px;
border-bottom: 0px !important;
height: 50px !important;
&:last-child {
border: 1px solid #dcdcdc;
}
}
.tr:last-child {
.td {
border-bottom: 1px solid #dcdcdc !important;
}
}
.tw-sticky {
position: sticky;
}
.carousel-container {
position: relative;
}
.table-container {
overflow-x: auto; /* 防止表格超出页面宽度 */
}
.table1 {
width: 100%;
min-width: 600px; /* 设置表格最小宽度 */
}
.tr {
border-bottom: 1px solid #e0e0e0; /* 表格行样式 */
}
.headerBorder {
border-bottom: 2px solid #ccc; /* 表头边框 */
}
.text-grey-darken-4 {
color: #333; /* 表格文字颜色 */
}
.breadcrumb-disabled {
color: black;
pointer-events: none; /* 禁用点击 */
text-decoration: none; /* 移除链接样式 */
}
.breadcrumb-active {
color: gray;
}
</style>