brand-shop-top.vue 3.48 KB
<template>
    <div v-if="showBrandInfo" class="brand-top-box" v-bind:style="{ 'background-image': `url(${brandIntro.brandBg})` }">
        <div class="brand-bottom">
            <img v-if="brandIntro.showBrandLogo" v-lazy="brandIntro.brandLogo" alt="{{ brandIntro.brandName }}">
            <div v-else class="brand-title">{{ brandIntro.brandName }}</div>
            <hr>
            <div v-show="showMore" transition="brand-intro" v-bind:class="{ 'brand-short': !showMore }">{{ brandIntro.brandIntro }}</div>
        </div>
        <div v-if="!showMore" class="showmore expand" @click="introTrans()"><span class="icon">&#xe602;</span></div>
        <div v-else class="showmore collapse" @click="introTrans()"><span class="icon">&#xe617;</span></div>
    </div>
</template>
<style>
    .brand-top-box {
        width: 100%;
        height: 468px;
        color: #fff;
        background-color: #000;
        position: relative;

        .brand-bottom {
            width: 100%;
            position: absolute;
            bottom: 20px;
            padding: 0 30px;

            .brand-title {
                font-weight: 700;
                font-size: 32px;
                font-style: italic;
                margin: 5px 0;
            }

            hr {
                width: 100%;
                border: #fff solid 1px;
                border-top: none;
                margin: 5px 0;
            }

            .brand-intro-transition {
                transition: all 0.3s ease;
                font-size: 16px;
                line-height: 32px;
                width: 82%;
                height: 220px;
                overflow-y: auto;
            }

            .brand-intro-enter,
            .brand-intro-leave {
                height: 60px;
            }

            .brand-short {
                height: 60px !important;
                display: -webkit-box !important;
                font-size: 16px;
                line-height: 32px;
                width: 82%;
                text-overflow: ellipsis;
                overflow-y: hidden;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
            }
        }

        .showmore {
            width: 60px;
            height: 60px;
            position: absolute;
            bottom: 10px;
            right: 30px;
            font-size: 32px;
        }
    }
</style>
<script>
    const $ = require('yoho-jquery');
    const tip = require('common/tip');
    const qs = require('yoho-qs');

    module.exports = {
        data() {
            return {
                brandIntro: {},
                showMore: false,
                showBrandInfo: false
            };
        },
        watch: {
            domain() {
                this.getShopIntro();
            }
        },
        methods: {
            getShopIntro() {
                let data = {
                    domain: qs.domain
                };

                $.ajax({
                    url: '/get-brand-intro',
                    data: data
                }).then(result => {
                    if (result) {
                        this.showBrandInfo = true;
                        this.brandIntro = result;
                    }
                }).fail(() => {
                    tip('网络错误');
                });
            },
            introTrans() {
                this.showMore = this.showMore !== true;
            }
        },
        created() {
            this.getShopIntro();
        }
    };
</script>