Blame view

src/views/ProductDetail.vue 4.38 KB
sanmu authored
1
<template>
sanmu authored
2
3
4
5
6
7
8
9
10
11
  <!-- <v-breadcrumbs class="pt-0" :items="['首页', '产品中心', '详情']"></v-breadcrumbs> -->
  <v-container>
    <v-row class="ma-0">
      <v-col cols="5"
        ><v-carousel class="tw-float-left" height="550" v-model="slide">
          <v-carousel-item
            cover
            v-for="(slide, i) in info.productimageliststore"
            :src="slide.url"
            :key="i"
sanmu authored
12
          >
sanmu authored
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
          </v-carousel-item>
        </v-carousel>
      </v-col>
      <v-col>
        <v-card-title class="mb-10 text-h4"> {{ info.name }} </v-card-title>
        <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>
          <!-- <v-col>
            <span class="tw-leading-[10px]">Category:{{ info.brandName }}</span>
          </v-col> -->

          <div class="tw-w-1/2 tw-mb-[12px]">
            <span class="tw-leading-[10px] tw-m-[16px]">产品型号:{{ 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
sanmu authored
42
            >
sanmu authored
43
          </div>
sanmu authored
44
45
        </div>
        <v-col>
sanmu authored
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
          <v-table density="compact" class="table1 tw-mt-[32px]">
            <thead>
              <tr>
                <th class="text-left">name</th>
                <th class="text-left">weight</th>
                <th class="text-left">price</th>
              </tr>
            </thead>
            <tbody>
              <tr class="tr" v-for="item in info.ticketTypes || []" :key="item.rank">
                <td class="td">{{ item.rank }}</td>
                <td class="td">{{ item.typeName }}</td>
                <td class="td">{{ item.price }}</td>
              </tr>
            </tbody>
          </v-table>
sanmu authored
62
        </v-col>
sanmu authored
63
64
65
      </v-col>
    </v-row>
    <div>
sanmu authored
66
67
68
69
70
71
72
73
74
75
      <v-tabs v-model="tab" color="blue-lighten-1" align-tabs="start">
        <v-tab :value="1">商品介绍</v-tab>
        <v-tab :value="2">规格参数</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-html="info.physicalproperty"></div>
          <div v-html="info.storage"></div>
        </v-window-item>
sanmu authored
76
77
78
79
80
81
82
83
84
85
        <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>
sanmu authored
86
87
88
89
90
91
92
93
        <!-- <v-window-item key="3" :value="3"> 2 </v-window-item> -->
      </v-window>
    </div>
  </v-container>
</template>

<script setup lang="ts">
import { getDetail } from '@/service'
sanmu authored
94
95
import type { Product } from '@/type'
import type { ProductImage } from '@/type'
sanmu authored
96
97
98
99
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
sanmu authored
100
const info = ref<Partial<Product>>({
sanmu authored
101
102
103
104
105
106
  productimageliststore: []
})

onMounted(() => {
  getDetail({ id: route.params.id as string }).then((res) => {
    const data = res.data.data || {}
sanmu authored
107
108
    data.productimageliststore = (JSON.parse(data.productimageliststore) || []) as ProductImage[]
    data.productimageliststore = data.productimageliststore.map((item: ProductImage) => ({
sanmu authored
109
110
111
112
113
114
115
116
117
118
119
      ...item,
      url: `http://112.74.45.244:8100/api/show/image?fileKey=${item.fileKey}`
    }))
    info.value = data
  })
})

const tab = ref(0)
const slide = ref(0)
</script>
sanmu authored
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<style lang="scss" scoped>
.td,
th {
  border: 1px solid #dcdcdc;
  border-right: 0px;
  border-bottom: 0px !important;

  &:last-child {
    border: 1px solid #dcdcdc;
  }
}

.tr:last-child {
  .td {
    border-bottom: 1px solid #dcdcdc !important;
  }
}
</style>