doum
2 天以前 d9dcd4a3476e32cb3ced994f66b1b89edaf157ae
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
<template>
    <view class="details" v-if="info">
        <u-swiper :list="info.banner" height="375" @click="preview"></u-swiper>
        <view class="info">
            <view class="info-title">
                {{info.name}}
            </view>
            <view class="commodity-item-box-price">
                <view class="commodity-item-box-price-a">
                    <text>{{info.minPrice[0]}}</text>
                    <text>.{{info.minPrice[1]}}</text>
                </view>
                <view class="commodity-item-box-price-b">
                    原价¥{{info.price}}
                </view>
            </view>
            <view class="info-num">
                <text>已售 {{info.saleNum + info.realSaleNum}}+</text>
                <text>库存 {{info.stock}}</text>
            </view>
        </view>
        <view class="content">
            <view class="content-label">商品详情</view>
            <view class="content-val" v-html="info.content"></view>
        </view>
        <view style="width: 100%; height: calc(env(safe-area-inset-bottom) + 108rpx);"></view>
        <view class="footer">
            <view class="edit">
                <view class="edit-left">
                    <view class="edit-left-row" @click="toIndex">
                        <image src="/static/icon/detail_ic_home@2x.png" mode="widthFix"></image>
                        <text>首页</text>
                    </view>
                    <view class="edit-left-row">
                        <button open-type="contact">客服</button>
                        <image src="/static/icon/detail_ic_kefu@2x.png" mode="widthFix"></image>
                        <text>客服</text>
                    </view>
                    <view class="edit-left-row" @click="toCard">
                        <image src="/static/icon/detail_ic_cart@2x.png" mode="widthFix"></image>
                        <text>购物车</text>
                        <view class="edit-left-row-num" v-if="cardObj && cardObj.cartTypeNum > 0">{{cardObj.cartTypeNum}}</view>
                    </view>
                </view>
                <view class="edit-btn">
                    <view class="edit-btn-a" @click="addCard(info)">加入购物车</view>
                    <view class="edit-btn-b">立即购买</view>
                </view>
            </view>
            <view style="width: 100%; height: env(safe-area-inset-bottom);"></view>
        </view>
    </view>
</template>
 
<script>
    import { mapState } from 'vuex'
    export default {
        computed: {
            ...mapState(['userInfo'])
        },
        data() {
            return {
                id: null,
                info: null,
                cardObj: null
            };
        },
        onLoad(option) {
            this.id = option.id
            this.getDetails()
            this.cardNum()
        },
        methods: {
            addCard(e) {
                this.$u.api.addCart({
                    goodsId: e.id,
                    goodsSkuId: e.skuResponsesList[0].id,
                    num: 1
                }).then(res => {
                    if (res.code === 200) {
                        this.cardNum()
                        uni.showToast({ title: '添加成功', icon: 'none' })
                    }
                })
            },
            toCard() {
                uni.navigateTo({
                    url: '/pages/shopping-cart/shopping-cart'
                })
            },
            toIndex() {
                uni.switchTab({
                    url: '/pages/index/index'
                })
            },
            cardNum() {
                this.$u.api.myInfo({})
                    .then(res => {
                        if (res.code === 200) {
                            this.cardObj = res.data
                        }
                    })
            },
            // 轮播图预览
            preview(index) {
                uni.previewImage({
                    urls: this.info.banner,
                    current: this.info.banner[index]
                })
            },
            getDetails() {
                this.$u.api.goodsInfo({
                    goodsId: this.id,
                    memberId: this.userInfo ? this.userInfo.id : null,
                }).then(res => {
                    if (res.code === 200) {
                        res.data.minPrice = res.data.minPrice.toFixed(2).split('.')
                        if (res.data.goodBannerMultiFiles && res.data.goodBannerMultiFiles.length > 0) {
                            res.data.banner = res.data.goodBannerMultiFiles.map(item => item.fileurlfull)
                        }
                        this.info = res.data
                    }
                })
            }
        }
    }
</script>
 
<style>
    page {
        background-color: #F9F9FB;
    }
</style>
<style lang="scss" scoped>
    .details {
        width: 100%;
        .footer {
            width: 100%;
            position: fixed;
            bottom: 0;
            left: 0;
            padding: 0 30rpx;
            box-sizing: border-box;
            background-color: #ffffff;
            height: calc(env(safe-area-inset-bottom) + 108rpx);
            .edit {
                width: 100%;
                height: 108rpx;
                display: flex;
                align-items: center;
                justify-content: space-between;
                .edit-left {
                    flex: 1;
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    .edit-left-row {
                        display: flex;
                        flex-direction: column;
                        align-items: center;
                        justify-content: center;
                        position: relative;
                        button {
                            position: absolute;
                            top: 0;
                            left: 0;
                            width: 100%;
                            height: 100%;
                            opacity: 0;
                        }
                        .edit-left-row-num {
                            position: absolute;
                            top: -10rpx;
                            right: -10rpx;
                            width: 30rpx;
                            height: 22rpx;
                            line-height: 22rpx;
                            text-align: center;
                            background: #E4001D;
                            border-radius: 12rpx;
                            border: 1rpx solid #FFFFFF;
                            font-weight: 400;
                            font-size: 20rpx;
                            color: #FFFFFF;
                        }
                        image {
                            width: 44rpx;
                            height: 44rpx;
                        }
                        text {
                            font-weight: 400;
                            font-size: 22rpx;
                            color: #666666;
                            margin-top: 4rpx;
                        }
                    }
                }
                .edit-btn {
                    flex-shrink: 0;
                    display: flex;
                    align-items: center;
                    margin-left: 24rpx;
                    display: flex;
                    align-items: center;
                    .edit-btn-a {
                        width: 200rpx;
                        height: 88rpx;
                        line-height: 88rpx;
                        text-align: center;
                        border-radius: 44rpx;
                        border: 1rpx solid #004096;
                        font-weight: 500;
                        font-size: 30rpx;
                        color: #004096;
                        margin-right: 20rpx;
                    }
                    .edit-btn-b {
                        width: 200rpx;
                        height: 88rpx;
                        line-height: 88rpx;
                        text-align: center;
                        background: #004096;
                        border-radius: 44rpx;
                        font-weight: 500;
                        font-size: 30rpx;
                        color: #FFFFFF;
                    }
                }
            }
        }
        .content {
            width: 100%;
            padding: 30rpx;
            box-sizing: border-box;
            background-color: #ffffff;
            margin-top: 20rpx;
            .content-label {
                font-weight: 500;
                font-size: 32rpx;
                color: #111111;
            }
            .content-val {
                width: 100%;
                margin-top: 30rpx;
            }
        }
        .info {
            width: 100%;
            padding: 30rpx;
            box-sizing: border-box;
            background-color: #ffffff;
            .info-title {
                width: 100%;
                font-weight: 600;
                font-size: 36rpx;
                color: #222222;
            }
            .commodity-item-box-price {
                width: 100%;
                display: flex;
                align-items: baseline;
                margin-top: 8rpx;
                .commodity-item-box-price-a {
                    display: flex;
                    align-items: baseline;
                    margin-right: 8rpx;
                    text {
                        &:nth-child(1) {
                            font-weight: bold;
                            font-size: 48rpx;
                            color: #E4001D;
                            &::before {
                                content: '¥';
                                font-weight: 400;
                                font-size: 26rpx;
                                color: #E4001D;
                            }
                        }
                        &:nth-child(2) {
                            font-weight: 400;
                            font-size: 26rpx;
                            color: #E4001D;
                        }
                    }
                }
                .commodity-item-box-price-b {
                    font-weight: 400;
                    font-size: 24rpx;
                    color: #999999;
                    text-decoration: line-through;
                }
            }
            .info-num {
                width: 100%;
                display: flex;
                align-items: center;
                justify-content: space-between;
                margin-top: 20rpx;
                text {
                    font-weight: 400;
                    font-size: 24rpx;
                    color: #999999;
                }
            }
        }
    }
</style>