wangzhibo
4 天以前 10595d8632f959d0954d1939243196f4eed02372
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
<template>
    <view class="goods-info">
        <view class="banner">
            <swiper class="cl-banner" indicator-dots>
                <swiper-item v-for="(item, index) in banner" :key="index">
                    <image class="cl-banner-item__image" mode="aspectFill" :src="item" />
                </swiper-item>
            </swiper>
        </view>
 
        <view class="content">
            <!-- 售价 -->
            <cl-row type="flex" justify="space-between" :padding="[20, 0, 20, 0]">
                <cl-skeleton
                    :height="54"
                    :loading="!info"
                    :loading-style="{
                        width: '200rpx',
                    }"
                >
                    <cl-text
                        type="price"
                        bold
                        color="error"
                        :size="50"
                        :value="spec.info?.price || info?.price"
                    />
                </cl-skeleton>
 
                <cl-skeleton
                    :loading-style="{
                        height: '38rpx',
                        width: '90rpx',
                        borderRadius: '38rpx',
                    }"
                    :loading="!info"
                >
                    <cl-tag round size="small">已售 {{ info?.sold || 0 }}</cl-tag>
                </cl-skeleton>
            </cl-row>
 
            <!-- 优惠券 -->
            <cl-row :margin="[0, 0, 20, 0]">
                <coupon-get />
            </cl-row>
 
            <!-- 标题 -->
            <cl-skeleton
                :margin="[0, 0, 20, 0]"
                :loading-style="{
                    height: '48rpx',
                }"
                :loading="!info"
            >
                <cl-text bold block :line-height="1.5" :size="32">
                    {{ info?.title }} {{ spec.info?.name }}
                </cl-text>
            </cl-skeleton>
 
            <!-- 其他 -->
            <view class="menu">
                <!-- 规格 -->
                <view
                    class="item"
                    @tap="
                        spec.open({
                            action: 'select',
                            goods: info!,
                        })
                    "
                >
                    <cl-icon class-name="shop-icon-sku" :size="52" :margin="[0, 10, 0, 0]" />
                    <cl-text :ellipsis="1">
                        {{ spec.text }}
                    </cl-text>
 
                    <text
                        class="cl-icon-close-border"
                        @tap.stop="spec.clear"
                        v-if="!!spec.info"
                    ></text>
                </view>
            </view>
        </view>
    </view>
</template>
 
<script lang="ts" setup>
import { computed, type PropType } from "vue";
import { useUpload } from "/@/cool";
import { useSpec } from "/@/hooks";
import { isEmpty } from "lodash-es";
import CouponGet from "/@/components/coupon/get.vue";
 
const props = defineProps({
    info: Object as PropType<Eps.GoodsInfoEntity>,
});
 
const { resizeImage } = useUpload();
const spec = useSpec();
 
// 轮播图列表
const banner = computed(() => {
    // 规格图
    if (!isEmpty(spec.info?.images)) {
        return spec.info?.images;
    }
 
    // 商品示例图
    if (!isEmpty(props.info?.pics)) {
        return props.info?.pics;
    }
 
    // 主图
    return [props.info?.mainPic];
});
</script>
 
<style lang="scss" scoped>
.goods-info {
    margin-bottom: 24rpx;
 
    .banner {
        .cl-banner {
            height: 760rpx;
 
            .cl-banner-item__image {
                border-radius: 0;
            }
        }
    }
 
    .content {
        padding: 10rpx 30rpx;
        background-color: #fff;
 
        .menu {
            .item {
                display: flex;
                align-items: center;
                height: 80rpx;
                background-color: $cl-color-bg;
                padding: 0 16rpx;
                border-radius: 12rpx;
                margin-bottom: 20rpx;
                padding-right: 60rpx;
                position: relative;
 
                .cl-icon-close-border {
                    position: absolute;
                    right: 20rpx;
                    color: $cl-color-info;
                }
            }
        }
    }
}
</style>