<!--
 * @Description  : 
 * @Author       : 黎志恒
 * @Date         : 2020-05-09 12:46:05
 * @LastEditTime: 2020-10-10 14:47:15
 * @LastEditors: 李璕
 * @FilePath     : \see-title.vue
 -->

<template>
    <div
        class="see-title"
        :class="{ mobile: componentData.commonVariable.isMobile }"
        v-if="componentData&&isShow"
    >
        <div class="title">
            <div
                class="image"
                v-if="
                    !componentData.commonVariable.isMobile &&
                    (componentData.commonVariable.pageType == 'design' ||
                        componentData.logo)
                "
                :style="{
                    'background-image': 'url(' + componentData.logo + ')',
                }"
            ></div>
            <div class="text" :title="componentData.title">
                {{ handlerData(this.componentData.title, "大标题") }}
            </div>
        </div>

        <div class="sub-title">
            {{ handlerData(this.componentData.desc, "概要说明…") }}
        </div>

        <span
            v-for="(item, index) in btns"
            :key="index"
            @click="btnClick(item.linkUrl)"
            class="btn"
            >{{ handlerData(item.linkText, "链接文字") }}</span
        >
    </div>
</template>
<script>
import permissionMixin from "./permission-mixin";
export default {
    name: "see-title",
    mixins: [permissionMixin],
    components: {},
    props: {
        componentData: {
            required: false,
        },
    },
    data() {
        return {
            items: [],
        };
    },
    computed: {
        btns() {
            if (this.componentData.commonVariable.pageType == "design") {
                return this.componentData.group;
            } else {
                let btn = [];
                this.componentData.group.map((r) => {
                    if (r.linkText) {
                        btn.push(r);
                    }
                });
                return btn;
            }
        },
    },
    watch: {},
    created() {},
    mounted() {},
    methods: {
        handlerData(d, v) {
            if (this.componentData.commonVariable.pageType == "design") {
                return d || v;
            } else {
                return d;
            }
        },
        btnClick(url) {
            url && window.open(url);
        },
    },
    destroyed() {},
};
</script>

<style lang="scss" >
$m-fontSize-big: 16px;
$m-fontSize-small: 12px;

$pc-fontSize-big: 24px;
$pc-fontSize-small: 12px;

$txt-font-color: #000;
$txt-font-desc: #333;
$btn-font-color: #007aff;

$m-btn-font-color: #fff;
$m-btn-bg-color: #007aff;

.see-title {
    .title {
        color: $txt-font-color;
        font-size: $pc-fontSize-big;
        line-height: 24px;

        display: flex;
        .text {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-weight: bold;
            font-size: 34px;
            line-height: 34px;
        }
    }
    .btn {
        color: $btn-font-color;
        margin-right: 44px;
        margin-top: 12px;
        display: inline-block;
        height: 28px;
        line-height: 28px;
        cursor: pointer;
    }
    .sub-title {
        line-height: 24px;
        font-size: 14px;
        // color: $txt-font-desc;
        color: #666;
        margin-top: 15px;
        word-break: break-all;
    }
    .image {
        background: rgba(204, 204, 204, 0.14);
        background-size: contain;
        border: 1px dashed rgba(0, 0, 0, 0.14);
        height: 36px;
        width: 36px;
        margin-right: 12px;
    }
}

.see-title.mobile {
    .title {
        color: $txt-font-desc;
        font-size: $m-fontSize-big;
        line-height: $m-fontSize-big;
        display: flex;
        .text {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-weight: bold;
            font-size: 18px;
        }
    }

    .sub-title {
        margin-top: 6px;
        line-height: 22px;
        color: $txt-font-desc;
        // font-size: $m-fontSize-small;
        font-size: 12px;
    }
    .btn {
        color: $m-btn-font-color;
        background-color: $m-btn-bg-color;
        margin-right: 11px;
        margin-top: 6px;
        padding: 5px 16px;
        border-radius: 2px;
        font-size: 14px;
        line-height: 22px;
    }
}
</style>

