gx
queenwuli
2021-01-28 b83ba3cc4687f21d744e9866e10e30e91229e8a4
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
<template>
    <!-- 商品详情 -->
    <view>
        <navigator open-type="navigateBack" hover-class="none">
            <view class="back iconfont iconzuojiantou"></view>
        </navigator>
        <swiper class="banner"
            autoplay="true" 
            interval="5000" 
            duration="1500"    
            @change="swiperChange">
            <swiper-item v-for="(item,index) in banner" :key="index">
                <image class="img" :src="item?item:'../../../static/images/no-img.png'"></image>
                <view class="indicator">
                    <text>{{swiperIndex+1}}/{{banner.length}}</text>
                </view>
            </swiper-item>
        </swiper>
        <view class="product-info">
            <text class="price">¥{{productInfo.salePrice}}</text>
            <view class="flex justify-between align-center">
                <text>{{productInfo.goodsName}}</text>
                <text class="gray">月销:{{productInfo.saleCnt}}</text>
            </view>
        </view>
        <view class="product-desc-wrap">
            <h-tabs
                class="tab"
                :tabData="tabs" 
                :config="{
                    color: '#abb1cc',
                    activeColor: '#518EFF',
                    underLineColor: '#518EFF',
                    underLineHeight: 4,
                    fontSize: '28',
                    underLineWidth: 110
                }"
                @tabClick="tabClick($event)"
            />
            <template v-if="tabIndex==0">
                <view class="product-desc" v-html="productInfo.desc"></view>
            </template>
            <template v-else>
                <product :productInfo="productInfo" v-if="goodsType=='家居产品'"></product>
                <project :productInfo="productInfo" v-if="goodsType=='项目'"></project>
                <combo :productInfo="productInfo" v-if="goodsType=='套餐'"></combo>
                <refillCard :productInfo="productInfo" v-if="goodsType=='充值卡'"></refillCard>
            </template>
        </view>
    </view>
</template>
 
<script>
    import HTabs from "@/components/liuyuno-tabs/liuyuno-tabs.vue";
    import product from './product.vue';
    import project from './project.vue';
    import combo from './combo.vue'
    import refillCard from './refillCard.vue'
    export default{
        components: {
            HTabs,
            product,
            project,
            combo,
            refillCard
        },
        data(){
            return{
                goodsType: '家居产品',
                banner:[],
                swiperIndex:0,
                tabs:[
                    {
                        state: 1,
                        name: '商品介绍'
                    },
                    {
                        state: 2,
                        name: '商品属性'
                    }
                ],
                tabIndex:0,
                productInfo: {}
            }
        },
        onLoad(options) {
            this.goodsType = options.goodsType;
            this.getInfo(options.id);
        },
        methods:{
            swiperChange(e){
                this.swiperIndex = e.detail.current;
            },
            tabClick(index){
                this.tabIndex=index
            },
            getInfo(id){
                this.$httpUtils.request('/api/order/findGoodsDetailById/'+id).then((res) => {
                    if(res.status == 200){
                        this.productInfo = res.mapInfo.goods;
                        this.banner = this.productInfo.img?this.productInfo.img.split(','):[];
                        if(this.productInfo.desc){
                            this.productInfo.desc = this.productInfo.desc.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ');
                        }
                        
                    }
                })
            }
        }
    }
</script>
 
<style>
    page{
        background: #F6F6F8;
    }
    .back{
        position: absolute;
        top: var(--status-bar-height);
        left: 10px;
        z-index: 9;
        font-size: 28px;
        opacity: 0.5;
    }
    .banner{
        width: 100%;
        height: 300px;
    }
    .banner .img{
        width: 100%;
        height: 100%;
    }
    .banner .indicator{
        position: absolute;
        right: 10px;
        bottom: 10px;
        background: rgba(0,0,0,0.5);
        border-radius: 20px;
        padding: 2px 15px;
        color: #FFFFFF;
        font-size: 10px;
    }
    .product-info{
        background: #FFFFFF;
        padding: 15px 10px;
        font-size: 14px;
        margin-bottom: 10px;
    }
    .product-info .price{
        display: block;
        font-size: 24px;
        font-weight: bold;
        color: #FA5151;
        margin-bottom: 5px;
    }
    .product-desc-wrap{
        background: #FFFFFF;
    }
    .tab{
        background: #FFFFFF;
        border-bottom: 1px solid #EDEAF4;
    }
    .product-desc{
        padding: 10px;
        min-height: 500rpx;
        font-size: 14px;
    }
    
</style>