Blame view

components/MobileProductDetail.vue 26.9 KB
1
<template>
2
  <div>
柏杨 authored
3
    <!-- <v-breadcrumbs
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
      divider="/"
      dense
      style="
        padding-top: 8px;
        font-size: 14px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
      "
    >
      <template v-for="(item, index) in items" :key="index">
        <v-breadcrumbs-item
          :disabled="item.disabled"
          :href="item.href"
          :class="{
            'breadcrumb-last': index === items.length - 1,
          }"
          :style="
            index === items.length - 1
              ? 'color: black; font-weight: bold;'
              : 'color:black'
          "
        >
          {{ item.title }}
        </v-breadcrumbs-item>
        <span
          v-if="index < items.length - 1"
          class="breadcrumb-divider"
柏杨 authored
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
          style="margin: 0 4px; font-size: 14px; color: gray"
          >/</span
        >
      </template>
    </v-breadcrumbs> -->
    <v-breadcrumbs
      divider="/"
      dense
      style="
        padding-top: 8px;
        font-size: 14px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
      "
    >
      <template v-for="(item, index) in items" :key="index">
        <v-breadcrumbs-item
          :disabled="item.disabled"
          :href="item.href"
          style="color: #1e88e5"
        >
          {{ item.title }}
        </v-breadcrumbs-item>
        <span
          v-if="index < items.length - 1"
          class="breadcrumb-divider"
          style="margin: 0 4px; font-size: 14px; color: gray"
60
61
62
63
64
65
          >/</span
        >
      </template>
    </v-breadcrumbs>
  </div>
66
  <v-container class="ma-0 pa-0 bg-grey-lighten-5">
67
68
69
70
71
72
73
74
    <v-carousel
      class="tw-float-left"
      height="450"
      v-model="slide"
      hide-delimiter-background
    >
      <v-carousel-item
        cover
75
        v-for="(slide, i) in info?.productimageliststore"
76
77
78
79
        :src="slide.url"
        :key="i"
        :alt="info.name"
      >
80
81
      </v-carousel-item>
    </v-carousel>
82
    <h1 class="mb-3 bg-white mb-sm-10 text-h4 font-weight-medium pa-4">
83
      {{ info.name }}
84
    </h1>
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
    <v-row class="mx-4 mt-0 mb-4 bg-white rounded-lg">
      <v-col cols="6">
        <div class="text-body-1 text-grey-darken-3">Brand:</div>
        <div class="text-h6">{{ info.brandName }}</div>
      </v-col>
      <v-col cols="6">
        <div class="text-body-1 text-grey-darken-3">Product Model:</div>
        <div class="text-h6">{{ info.model }}</div>
      </v-col>
      <v-col cols="6" v-if="info.basename1">
        <div class="text-body-1 text-grey-darken-3">{{ info.basename1 }}:</div>
        <div class="text-h6">{{ info.basecore1 }}</div>
      </v-col>
      <v-col cols="6" v-if="info.basename2">
        <div class="text-body-1 text-grey-darken-3">{{ info.basename2 }}:</div>
        <div class="text-h6">{{ info.basecore2 }}</div>
      </v-col>
      <v-col cols="6" v-if="info.basename3">
        <div class="text-body-1 text-grey-darken-3">{{ info.basename3 }}:</div>
        <div class="text-h6">{{ info.basecore3 }}</div>
      </v-col>
    </v-row>
107
    <div
柏杨 authored
108
      ref="ticketDiv"
109
      v-if="info.ticketTypes?.length"
110
      class="py-0 mx-4 rounded-lg tw-flex tw-flex-wrap tw-justify-around"
111
    >
112
      <!-- <v-sheet
113
114
115
116
117
118
        v-for="item in info.ticketTypes || []"
        :key="item.rank"
        rounded="lg"
        border
        class="tw-w-[40%] mb-4"
      >
119
        <div
120
121
          class="tw-bg-[#dcecfa] tw-h-[64px] !tw-leading-[64px] rounded-lg rounded-b-0 pa-2 tw-text-center text-h6 tw-overflow-hidden tw-text-ellipsis"
        >
122
123
124
125
126
127
128
129
          {{ item.typeName }}
        </div>
        <div class="tw-h-[82px] pa-2">
          <div class="text-caption">Product Code</div>
          <div class="text-body-1 !tw-font-[500]">
            {{ item.rank }}
          </div>
        </div>
130
131
132
      </v-sheet> -->
      <v-table
        density="comfortable"
133
        style="width: 100%"
134
135
136
137
138
        class="table1 tw-mt-[0px] tw-overflow-x-auto"
        v-if="info.ticketTypes?.length"
      >
        <thead>
          <tr class="bg-grey-lighten-3">
139
            <th class="text-left headerBorder text-grey-darken-1">Name/Code</th>
140
            <th class="text-left headerBorder text-grey-darken-1">
141
              Specification
142
143
144
145
146
147
148
            </th>
            <th
              v-if="info.priceShow !== undefined && info.priceShow"
              class="text-left headerBorder text-grey-darken-1"
            >
              Price
            </th>
149
            <!-- <th class="text-left headerBorder text-grey-darken-1">Actions</th> -->
150
151
152
153
154
155
156
157
158
159
160
161
162
163
          </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>
柏杨 authored
164
165
166
167
168
169
            <td v-if="item.priceShow" class="td">
              <div style="color: #df3931">${{ item.price }}</div>
              <s style="font-size: 13px; color: #757575">
                ${{ item.originPrice }}</s
              >
            </td>
170
            <!-- <td class="td">
171
172
173
174
175
176
177
              <v-btn
                size="small"
                color="blue-darken-1"
                @click="router.push('/contact')"
              >
                Quote
              </v-btn>
178
            </td> -->
179
180
181
182
183
184
185
186
          </tr>
        </tbody>
      </v-table>
      <!-- <div  v-for="item in info.ticketTypes || []"
            :key="item.rank">

      </div> -->
      <!-- <v-btn
187
        style="margin-top: 6px"
188
189
190
        color="blue-darken-1"
        @click="router.push('/contact')"
      >
191
        Quotation Inquiry
192
      </v-btn> -->
193
194
195
196
197
198
199
      <!-- <div
        v-if="showBottomButton"
        ref="bottomButton"
        :class="['button-container', { fixed: isFixed }]"
      > -->
      <v-btn
        style="margin-top: 12px"
柏杨 authored
200
        color="blue-darken-1 tw-sticky"
201
202
203
204
205
        @click="router.push('/contact')"
      >
        Quotation Inquiry
      </v-btn>
      <!-- </div> -->
206
207
208
209
210
    </div>
    <!-- <v-dialog v-model="dialog" activator="parent" width="auto">
          <v-card> Contact us Email: contact@canrd.com QQ: 3003597584 / 2902385824 </v-card>
        </v-dialog> -->
    <div class="tw-pb-[64px] ma-4 rounded-lg">
211
212
213
      <v-tabs
        class="tabs"
        v-model="tab"
214
215
216
217
        style="margin-top: 25px; margin-bottom: 20px"
        color="white"
        bg-color="#eeeeee"
        slider-color="blue-lighten-1"
218
219
        selected-class="active"
      >
220
        <v-tab :value="1">Product Details</v-tab>
柏杨 authored
221
        <v-tab :value="2" v-if="info.productAttributeList">Specification</v-tab>
222
223
224
225
226
        <!-- <v-tab :value="3">商品百科</v-tab> -->
      </v-tabs>
      <v-window v-model="tab">
        <v-window-item key="1" :value="1">
          <div v-if="info.advantage" class="tw-mb-[24px]">
柏杨 authored
227
228
            <!--            <div class="py-2 pl-2 text-h6">Advantage</div>-->
            <!--            <v-divider class="tw-mb-[12px]"></v-divider>-->
229
230
231
            <div v-html="info.advantage"></div>
          </div>
          <div v-if="info.physicalproperty" class="tw-mb-[24px]">
柏杨 authored
232
233
            <!--            <div class="py-2 pl-2 text-h6">Physical Property</div>-->
            <!--            <v-divider class="tw-mb-[12px]"></v-divider>-->
柏杨 authored
234
            <div v-html="clearSpanStyle(info.physicalproperty)"></div>
235
          </div>
236
          <div v-if="info.storage" class="tw-mb-[24px]">
柏杨 authored
237
238
            <!--            <div class="py-2 pl-2 text-h6">Storage</div>-->
            <!--            <v-divider class="tw-mb-[12px]"></v-divider>-->
柏杨 authored
239
            <div v-html="clearSpanStyle(info.storage)"></div>
240
241
          </div>
          <div v-if="info.introduction" class="tw-mb-[24px]">
柏杨 authored
242
243
            <!--            <div class="py-2 pl-2 text-h6">Introduction</div>-->
            <!--            <v-divider class="tw-mb-[12px]"></v-divider>-->
柏杨 authored
244
            <div v-html="clearSpanStyle(info.introduction)"></div>
245
          </div>
246
          <div v-if="info.description" class="tw-mb-[24px]">
柏杨 authored
247
248
            <!--            <div class="py-2 pl-2 text-h6">Description</div>-->
            <!--            <v-divider class="tw-mb-[12px]"></v-divider>-->
柏杨 authored
249
            <div v-html="clearSpanStyle(info.description)"></div>
250
251
252
253
254
          </div>
        </v-window-item>
        <v-window-item key="2" :value="2">
          <v-table density="compact" class="table2">
            <tbody>
255
256
257
258
259
              <tr
                class="tr"
                v-for="item in info.productAttributeList || []"
                :key="item.name"
              >
260
                <td class="td tw-w-[350px]">{{ item.name }}</td>
261
262
263
264
265
266
267
268
                <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>
269
270
271
272
    <div class="tw-pb-[64px] ma-4 rounded-lg" style="padding-bottom: 30px">
      <v-tabs
        class="tabs"
        v-model="tabProduct"
273
274
275
        color="white"
        bg-color="#eeeeee"
        slider-color="blue-lighten-1"
276
277
278
        selected-class="active"
        style="margin-bottom: 20px"
      >
柏杨 authored
279
280
        <v-tab :value="1">Best Sellers</v-tab>
        <v-tab :value="2">Related Products</v-tab>
281
282
283
284
        <!-- <v-tab :value="3">商品百科</v-tab> -->
      </v-tabs>
      <v-window v-model="tabProduct">
        <v-window-item key="1" :value="1">
柏杨 authored
285
          <div class="tw-text-center" v-if="hotLoading && isMobile()">
286
287
288
289
290
291
292
293
            <v-progress-circular
              color="blue-lighten-2"
              indeterminate
              size="64"
              class="tw-m-auto"
            ></v-progress-circular>
          </div>
          <v-item-group multiple v-if="isMobile()">
柏杨 authored
294
            <v-row v-if="!hotLoading">
295
              <v-col
柏杨 authored
296
                v-for="(item, i) in recommendImagesHot"
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
                :key="i"
                cols="6"
                lg="3"
                md="4"
                sm="6"
              >
                <div v-if="item !== null">
                  <v-card
                    :elevation="4"
                    class="mx-auto"
                    :href="item[0].productUrl"
                  >
                    <!-- 设置 eager 属性,确保图片直接加载 -->
                    <v-img
                      :src="item[0].url"
                      :alt="item[0].name"
                      eager
                      class="d-block"
                    />
                    <v-card-text class="tw-text-left font-weight-medium title">
柏杨 authored
317
                      <h4 class="clamp-text">{{ item[0].name }}</h4>
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
                    </v-card-text>
                  </v-card>
                </div>
              </v-col>
            </v-row>
            <!-- <div
          v-if="!hotTotal"
          class="text-medium-emphasis text-body-1 tw-text-center tw-m-[64px]"
        >
          no data
        </div> -->
          </v-item-group>
          <v-row v-if="isMobile()">
            <v-col>
              <v-pagination
                :size="isMobile() ? 'small' : 'default'"
柏杨 authored
334
335
336
337
                v-if="hotTotal"
                v-model="currentIndexHot"
                @update:modelValue="toggleRowMobileHot"
                :length="hotLength"
338
339
340
341
342
343
344
345
                rounded="0"
                class="tw-float-right tw-mt-[32px]"
                total-visible="5"
              ></v-pagination></v-col
          ></v-row>
        </v-window-item>
        <!-- best sellers -->
        <v-window-item key="2" :value="2">
柏杨 authored
346
          <div class="tw-text-center" v-if="loading && isMobile()">
347
348
349
350
351
352
353
354
            <v-progress-circular
              color="blue-lighten-2"
              indeterminate
              size="64"
              class="tw-m-auto"
            ></v-progress-circular>
          </div>
          <v-item-group multiple v-if="isMobile()">
柏杨 authored
355
            <v-row v-if="!loading">
356
              <v-col
柏杨 authored
357
                v-for="(item, i) in recommendImages"
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
                :key="i"
                cols="6"
                lg="3"
                md="4"
                sm="6"
              >
                <div v-if="item !== null">
                  <v-card
                    :elevation="4"
                    class="mx-auto"
                    :href="item[0].productUrl"
                  >
                    <!-- 设置 eager 属性,确保图片直接加载 -->
                    <v-img
                      :src="item[0].url"
                      :alt="item[0].name"
                      eager
                      class="d-block"
                    />
                    <v-card-text class="tw-text-left font-weight-medium title">
柏杨 authored
378
                      <h4 class="clamp-text">{{ item[0].name }}</h4>
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
                    </v-card-text>
                  </v-card>
                </div>
              </v-col>
            </v-row>
            <!-- <div
          v-if="!hotTotal"
          class="text-medium-emphasis text-body-1 tw-text-center tw-m-[64px]"
        >
          no data
        </div> -->
          </v-item-group>
          <v-row v-if="isMobile()">
            <v-col>
              <v-pagination
                :size="isMobile() ? 'small' : 'default'"
柏杨 authored
395
396
397
398
                v-if="total"
                v-model="currentIndex"
                @update:modelValue="toggleRowMobile"
                :length="length"
399
400
401
402
403
404
405
406
407
                rounded="0"
                class="tw-float-right tw-mt-[32px]"
                total-visible="5"
              ></v-pagination></v-col
          ></v-row>
        </v-window-item>
        <!-- <v-window-item key="3" :value="3"> 2 </v-window-item> -->
      </v-window>
    </div>
408
    <div class="tw-pb-[64px] ma-4 rounded-lg">
409
410
411
      <v-tabs
        class="tabs"
        v-model="tabJournal"
412
413
414
        color="white"
        bg-color="#eeeeee"
        slider-color="blue-lighten-1"
415
416
        selected-class="active"
      >
417
        <v-tab :value="1">Product-related Journals</v-tab>
418
      </v-tabs>
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
      <v-window v-model="tabJournal">
        <v-window-item key="1" :value="1">
          <v-list>
            <v-list-item
              v-for="item in info.journals"
              :key="item.id"
              @click="navigateToUrl(item.link)"
              @mouseenter="hoveredItem = item.id"
              @mouseleave="hoveredItem = null"
            >
              <v-list-item-title>
                <span
                  :class="['title', { 'full-title': hoveredItem === item.id }]"
                >
                  {{ item.title }}
                </span>
              </v-list-item-title>
            </v-list-item>
          </v-list>
        </v-window-item>
439
      </v-window>
440
    </div>
柏杨 authored
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
    <!-- Basic use -->
    <div class="social-share-container">
      <SocialShare
        network="facebook"
        :styled="true"
        :label="true"
        :title="info.name"
        :url="currentUrl"
        style="color: #1e88e5; width: 140px"
      />

      <SocialShare
        network="twitter"
        :styled="true"
        :label="true"
        :title="info.name"
        :url="currentUrl"
        style="color: #1e88e5; width: 140px"
      />

      <SocialShare
        network="linkedin"
        :styled="true"
        :label="true"
        :title="info.name"
        :url="currentUrl"
        style="color: #1e88e5; width: 140px"
      />
    </div>
470
471
472
473
  </v-container>
</template>

<script setup lang="ts">
474
import type { Product } from "~/type";
475
476
import { isMobile } from "~/utils";
import { defineProps, ref } from "vue";
477
478
import { useDialogStore } from "~/stores/dialog";
const dialogStore = useDialogStore();
479
480

const props = defineProps<{
481
482
483
  info: Product;
}>();
const info = props.info;
484
485
// onMounted(() => {
//   dialogStore.updateDialog(true)
486
// })
487
488
489
const tab = ref();
const tabProduct = ref();
const tabJournal = ref();
490
491
492
493
494
495
const slide = ref(0);
const router = useRouter();
const href1 = ref("/products");
const href2 = ref("/products");
const routeQuery = useRouteQuery();
const productStore = useProductListStore();
496
const currentUrl = ref("https://www.canrud.com/products");
497
498
499
500
501
502
503
504
505
506
507
508
509
510
const hotLoading = ref(false);
const loading = ref(false);
const maxPage = ref(1);
const maxPageRe = ref(1);
const tabRecom = ref();
const recommendList = ref();
const recommendListHot = ref();
const recommendImages = ref();
const recommendImagesHot = ref();
const currentIndex = ref(1);
const currentIndexHot = ref(1);
const total = ref(3);
const hotTotal = ref(10);
const isOrNotMobile = isMobile();
511
const hoveredItem = ref(null);
512
柏杨 authored
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
const clearSpanStyle = (htmlContent) => {
  if (!htmlContent) return ""; // 检查是否为空
  // 创建一个 DOM 解析器
  const parser = new DOMParser();
  const doc = parser.parseFromString(htmlContent, "text/html");

  // 清理 span 的 style 属性
  const spans = doc.querySelectorAll("span");
  spans.forEach((span) => {
    span.removeAttribute("style"); // 清空 style 属性
  });

  // 修改 img 的 style 属性,追加 width: 100%
  const imgs = doc.querySelectorAll("img");
  imgs.forEach((img) => {
    const style = img.getAttribute("style") || ""; // 获取现有 style
    if (!style.includes("width: 100%")) {
      img.setAttribute("style", `${style} width: 100%;`.trim()); // 添加 width: 100%
    }
  });

  // 返回处理后的 HTML
  return doc.body.innerHTML;
};
537
538
539
const navigateToUrl = (url) => {
  window.open(url); // 在新标签页中打开链接
};
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
const loadProducts = async () => {
  const pageSize = 4;
  loading.value = true;

  let { data: resData } = await useAsyncData(
    "list",
    () =>
      $fetch("/shop/product/list", {
        method: "GET",
        params: {
          pageNo: currentIndex.value,
          pageSize: pageSize,
          ids: info.relatedProductIds,
        },
      }),
    {
      server: true, // 仅在服务器端获取数据
    }
  );
  total.value = resData.value.data.total;
560
561
  if (total.value > 50) {
    total.value = 50;
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
  }
  recommendList.value = resData.value.data.records;
  maxPageRe.value = resData.value.data.pages;
  // recommendImages.value = recommendList.value.slice(0, 10).map((item) => {
  recommendImages.value = Array.from({ length: 4 }).map((_, index) => {
    const item = recommendList.value[index];
    if (!item) {
      return null;
    }
    // 检查 productimageliststore 是否为字符串格式,如果是,则尝试解析
    if (typeof item.productimageliststore === "string") {
      try {
        item.productimageliststore = JSON.parse(item.productimageliststore);
      } catch (error) {
        item.productimageliststore = []; // 解析失败时,设置为空数组
      }
    }
    const ree = (item.productimageliststore = item?.productimageliststore.map(
      (productItem: ProductImage) => ({
        ...productItem,
        // url: `http://112.74.45.244:8100/api/show/image?fileKey=${item.fileKey}`,
        url: `https://www.canrud.com/api/show/image?fileKey=${productItem.fileKey}&psize=p256`,
        name: item.name,
        productUrl: `https://www.canrud.com/products/detail/${item.id}`,
      })
    ));
    return ree;
  });
  loading.value = false;
};
const loadHotProducts = async () => {
  const pageSizeHot = ref(5);
  if (isOrNotMobile) {
    pageSizeHot.value = 4;
  }
  hotLoading.value = true;

  let { data: hotProducts } = await useAsyncData(
    "hotProducts",
    () =>
      $fetch("/shop/product/hotProducts", {
        method: "GET",
        params: {
          pageNo: currentIndexHot.value,
          pageSize: pageSizeHot.value,
        },
      }),
    {
      server: true, // 仅在服务器端获取数据
    }
  );
  hotTotal.value = hotProducts.value.data.total;
  recommendListHot.value = hotProducts.value.data.records;
  maxPage.value = hotProducts.value.data.pages;
  // recommendImages.value = recommendList.value.slice(0, 10).map((item) => {
  recommendImagesHot.value = Array.from({ length: pageSizeHot.value }).map(
    (_, index) => {
      const item = recommendListHot.value[index];
      if (!item) {
        return null;
      }
      // 检查 productimageliststore 是否为字符串格式,如果是,则尝试解析
      if (typeof item.productimageliststore === "string") {
        try {
          item.productimageliststore = JSON.parse(item.productimageliststore);
        } catch (error) {
          item.productimageliststore = []; // 解析失败时,设置为空数组
        }
      }
      const ree = (item.productimageliststore = item?.productimageliststore.map(
        (productItem: ProductImage) => ({
          ...productItem,
          // url: `http://112.74.45.244:8100/api/show/image?fileKey=${item.fileKey}`,
          url: `https://www.canrud.com/api/show/image?fileKey=${productItem.fileKey}&psize=p256`,
          name: item.name,
          productUrl: `https://www.canrud.com/products/detail/${item.id}`,
        })
      ));
      return ree;
    }
  );
  hotLoading.value = false;
};

const toggleRowMobile = (value: number) => {
  currentIndex.value = value;
};
const toggleRowMobileHot = (value: number) => {
  currentIndexHot.value = value;
};

watch(currentIndexHot, (newIndex) => {
  loadHotProducts(); // Call loadHotProducts when currentIndex changes
});
watch(currentIndex, (newIndex) => {
  loadProducts(); // Call loadHotProducts when currentIndex changes
});
// Initial load of hot products
await loadHotProducts(); // Load hot products the first time
await loadProducts(); // Load hot products the first time
662
663
664
665
666
667
668
669
670
671
672
673
interface BreadcrumbItem {
  title: string; // 标题
  disabled: boolean; // 是否禁用
  href: string; // 链接地址
}

// 示例数据
const items = ref<BreadcrumbItem[]>([
  {
    title: "Products",
    disabled: false,
674
    href: "https://www.canrud.com/products",
675
676
677
678
679
680
681
  },
  {
    title: "CATEGORY",
    disabled: false,
    href: href1.value,
  },
  {
682
    title: "Not specified",
683
684
685
686
    disabled: false,
    href: href2.value,
  },
  {
687
    title: "Not specified",
688
689
690
691
692
    disabled: false,
    href: "/products",
  },
]);
watchEffect(() => {
693
  currentUrl.value = "https://www.canrud.com/products/detail/" + info.id;
694
695
696
  if (info?.productCrumbsVO?.category1 && productStore.keyword) {
    items.value[1].title = info.productCrumbsVO.category1;
    items.value[1].href =
697
      "https://www.canrud.com/products?categories=" +
698
699
      info.productCrumbsVO.category1;
    href1.value =
700
      "https://www.canrud.com/products?categories=" +
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
      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;
    }
  } else 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 =
734
735
      "https://www.canrud.com/products?categories=" + mainCategory;
    href1.value = "https://www.canrud.com/products?categories=" + mainCategory;
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
    // 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 =
753
      "https://www.canrud.com/products?categories=" +
754
755
      info.productCrumbsVO.category1;
    href1.value =
756
      "https://www.canrud.com/products?categories=" +
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
      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;
    }
  }
});
775
776
777
778
const length = computed(() => (total.value ? Math.ceil(total.value / 4) : 0));
const hotLength = computed(() =>
  hotTotal.value ? Math.ceil(hotTotal.value / 4) : 0
);
779
780
781
</script>

<style lang="scss" scoped>
782
// .tabs {
783
//   border-bottom: 2px solid #cbd9e4;
784
785
786
// }

// .active {
787
//   background-color: #fff;
788
// }
789
790
791
792
793
794
795
796
797
.tabs {
  border-bottom: 2px solid #1f88e5;
}

.active {
  background-color: #1086e8;
}
柏杨 authored
798
799
800
801
.tw-sticky {
  position: sticky;
}
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
// .button-container {
//   margin-top: 6px;
//   display: flex;
//   justify-content: center;
//   position: absolute;
//   width: 100%;
//   bottom: auto; /* 默认情况下不固定 */
// }

// .button-container.fixed {
//   position: fixed;
//   bottom: 16px; /* 固定在页面底部 */
//   left: 0;
//   z-index: 1000;
//   background-color: rgba(255, 255, 255, 0.9);
//   box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1);
//   padding: 8px 0;
// }
柏杨 authored
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
.social-share-container {
  display: flex;
  flex-direction: row; /* 父容器横向排列 */
  gap: 1rem; /* 设置每个分享项之间的间距 */
  margin-left: 10px;
  margin-bottom: 10px;
}

.social-share-item {
  display: flex;
  flex-direction: row; /* 每个分享项横向排列 */
  align-items: center; /* 垂直居中对齐 */
  gap: 0.5rem; /* 标题与按钮之间的间距 */
}

.social-share-title {
  font-size: 1rem;
  font-weight: bold;
}
839
840
841
.v-card {
  transition: all 0.3s ease-in-out;
}
柏杨 authored
842
843
844
845
846
847
848
849
850
851
.clamp-text {
  display: -webkit-box; /* 使用弹性盒子 */
  -webkit-box-orient: vertical; /* 设置为垂直方向 */
  -webkit-line-clamp: 3; /* 限制最多显示3行 */
  overflow: hidden; /* 隐藏多余内容 */
  text-overflow: ellipsis; /* 添加省略号 */
  white-space: normal; /* 允许换行 */
  line-height: 1.5em; /* 设置每行的高度 */
  min-height: calc(3 * 1.5em); /* 确保最小高度为3行 */
}
852
</style>