<template>
    <bread-pages>
        <div class="main" v-loading="loading">
            <div class="top">
                <div class="img">
                    <el-carousel height="360px">
                        <el-carousel-item v-for="(item, index) in info.img" :key="index">
                            <el-image :src="item" fit="fill" style="width: 100%; height: 100%"></el-image>
                        </el-carousel-item>
                    </el-carousel>
                </div>
                <div class="main_con_title">
                    <div class="title">{{ info.name }}</div>
                    <div class="info">
                        <div class="info-item">
                            <span class="text1">所属领域：</span>
                            <span class="text2">{{ info.fieldName }}</span>
                        </div>
                        <div class="info-item">
                            <span class="text1">所处阶段：</span>
                            <span class="text2">{{ getLabelName(info.stage, stageOptions) }}</span>
                        </div>
                        <div class="info-item">
                            <span class="text1"
                                >{{ `${info.tpType == 'TECHNOLOGY' ? '成果所属人' : '产品持有人'}` }}：</span
                            >
                            <span class="text2">{{ info.owner }}</span>
                        </div>
                        <div class="info-item">
                            <span class="text1">价格：</span>
                            <span class="text2" v-if="info.negotiateDirectly">面议 </span>
                            <span class="text2" v-else>{{ info.expectedPrice }}万元 </span>
                        </div>
                        <div class="info-item">
                            <span class="text1">交易方式：</span>
                            <span v-if="info.tpType === 'TECHNOLOGY'" class="text2">{{
                                getLabelName(info.tradingMethod, tradingMethodOptionsDemand)
                            }}</span>
                            <span v-else class="text2">{{
                                getLabelName(info.tradingMethod, tradingMethodOptionsDemands)
                            }}</span>
                        </div>
                        <div class="info-item">
                            <span class="text1"
                                >{{ `${info.tpType == 'TECHNOLOGY' ? '是否专利技术' : '是否专利产品'}` }}：</span
                            >
                            <span class="text2" v-if="info.patented">{{ info.patentNo.join(',') }}</span>
                            <span class="text2" v-else> 否</span>
                        </div>

                        <div class="flex1"></div>
                    </div>
                    <div class="btn">
                        <div class="icon-button" @click.prevent="connectKefu">
                            <i class="iconfont iconfont-nav_icon_xiaoxi1"></i>
                            咨询
                        </div>
                        <div class="icon-button" @click="postMessage">
                            <i class="iconfont iconfont-nav_icon_xiaoxi"></i>
                            留言
                        </div>
                    </div>
                </div>
            </div>
            <div class="detail">
                <div class="detail_top">
                    <div class="detail-title" :class="{ active: active === 0 }" @click="active = 0">
                        {{ `${info.tpType == 'TECHNOLOGY' ? '摘要' : '产品概述'}` }}
                    </div>
                    <div class="detail-title" :class="{ active: active === 1 }" @click="active = 1">
                        {{ `${info.tpType == 'TECHNOLOGY' ? '成果描述' : '产品描述'}` }}
                    </div>
                    <!-- <div class="detail-title" :class="{ active: active === 2 }" @click="active = 2">
                        {{ `${info.tpType == 'TECHNOLOGY' ? '技术附图' : '产品附图'}` }}
                    </div> -->
                </div>
                <div class="detail_con">
                    <div class="detail-content" v-html="info.digest" v-if="active === 0"></div>
                    <div class="detail-content" v-html="info.manual" v-else></div>
                    <!-- <div class="ImgBox" v-else>
                        <el-carousel>
                            <el-carousel-item v-for="(item, index) in info.img" :key="index">
                                <el-image :src="getImg(item)" fit="fill"></el-image>
                            </el-carousel-item>
                        </el-carousel> -->
                        <!-- <el-image v-for="(item, index) in info.img" :key="index" :src="getImg(item)" fit="cover"></el-image> -->
                    <!-- </div> -->
                </div>
            </div>
            <!-- <div class="btn">
                <el-button type="primary" class="icon-button" @click.prevent="connectKefu" size="small">
                    <i class="iconfont iconfont-nav_icon_xiaoxi1"></i>
                    咨询客服
                </el-button>
                <el-button type="primary" @click="postMessage" class="icon-button" size="small">
                    <i class="iconfont iconfont-nav_icon_xiaoxi"></i>提交留言
                </el-button>
            </div> -->
        </div>
    </bread-pages>
</template>

<script>
import BreadPage from '../../components/page/BreadPage.vue';
import BreadPages from '../../components/page/BreadPages.vue';
import {
    stageOptions,
    tradingMethodOptionsDemands,
    tradingMethodOptionsDemand,
    tpTypeOptions
} from '../../utils/variables';
import comEvent from '../../mixins/comEvent';
export default {
    mixins: [comEvent],
    components: { BreadPage, BreadPages },
    data() {
        return {
            active: 0,
            loading: true,
            info: {},
            stageOptions,
            tradingMethodOptionsDemands,
            tradingMethodOptionsDemand
        };
    },
    mounted() {
        this.loading = true;
        this.$http.get('/technologyProduct/get/' + this.$route.query.id).then(res => {
            this.info = res;
            setTimeout(() => {
                this.loading = false;
            }, 500);

            let info = tpTypeOptions.find(item => {
                return item.value === res.tpType;
            });
            this.$EventBus.$emit('changePreTitle', {
                name: info.label,
                path: info.path || '/technologyProduct',
                query: {
                    tpType: res.tpType
                }
            });
            this.$EventBus.$emit('changeTitle', info.label + '详情');
            document.title = info.label + '详情';
        });
    },
    created() {
        let addView = {
            id: this.$route.query.id,
            type: 'TechnologyProduct'
        };
        // console.log(addView);
        this.loading = true;
        this.$http.get('/all/addView/', addView).then(res => {
            console.log(res);
        });
    }
};
</script>

<style lang="less" scoped>
// .main {
//     background-color: #fff;
//     padding: 22px 100px 150px;
// }
/deep/ .el-image {
    width: 100%;
    height: 400px;
}
.img {
    width: 360px;
}
/deep/ .el-carousel__container {
    margin: 0 auto;
    height: 500px;
    width: 360px;
}
/deep/ .el-image {
    width: 100%;
    height: 100%;
}
.top {
    width: 1200px;
    height: 360px;
    background: #ffffff;
    border: 1px solid #f5f7fa;
    display: flex;
    margin-bottom: 50px;
    .main_con_title {
        padding-top: 20px;
        margin-left: 50px;
    }
    .title {
        font-size: 24px;
        font-weight: bold;
        color: #000000;
        line-height: 33px;
        margin-bottom: 30px;
    }
    .info {
        .flex();
        flex-wrap: wrap;
        .info-item {
            width: 50%;
            padding-right: 50px;
            box-sizing: border-box;
            line-height: 32px;
            margin-bottom: 8px;
            .flex();

            .text1 {
                font-size: 14px;
                color: #999999;
                display: inline-block;
                min-width: 80px;
                flex-shrink: 0;
            }

            .text2 {
                font-size: 14px;
                color: #000;
                margin-left: 6px;
                display: inline-block;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
        }
    }
}

// .info-item {
//     width: 50%;
//     box-sizing: border-box;
//     line-height: 24px;
//     margin-bottom: 12px;
//     .flex();

//     .text1 {
//         font-size: 14px;
//         color: #999999;
//         display: inline-block;
//         min-width: 100px;
//         flex-shrink: 0;
//     }

//     .text2 {
//         font-size: 14px;
//         color: @warn;
//         margin-left: 6px;
//         display: inline-block;
//         overflow: hidden;
//         text-overflow: ellipsis;
//         white-space: nowrap;
//     }
// }
// .btn {
//     margin-top: 20px;
//     text-align: center;
//     .icon-button {
//         line-height: 42px;
//     }
// }
// .detail {
//     .detail-title {
//         font-size: 16px;
//         font-weight: bold;
//         color: #000000;
//         line-height: 22px;
//         padding: 7px 0;
//         border-bottom: 1px solid @bg;
//     }

//     .detail-content {
//         font-size: 12px;
//         color: #000000;
//         line-height: 22px;
//         padding: 20px 0;

//         /deep/ img {
//             display: block;
//             margin: 10px auto;
//         }

//         /deep/ p {
//             margin-top: 20px;
//         }
//     }
// }
.detail {
    width: 1200px;
    background: #ffffff;
    min-height: 768px;
    margin-bottom: 134px;
    .detail_top {
        height: 56px;
        background: #f5f7fa;
        font-size: 14px;
        font-weight: 400;
        color: #565b66;
        display: flex;
        cursor: pointer;
    }
    .detail-title {
        width: 110px;
        height: 56px;
        line-height: 56px;
        text-align: center;
    }
    .active {
        width: 110px;
        height: 56px;
        background: #ffffff;
        font-weight: bold;
        color: #01a041;
        box-sizing: border-box;
        position: relative;
        &::after{
            content: "";
            width: 110px;
            height: 3px;
            background-color: #01a041;
            position: absolute;
            left: 0px;
            top: 0px;
        }
    }
    .detail-content {
        padding: 20px 30px;
    }
    .ImgBox{
        padding-top: 60px;
    }
}
.appContainer {
    background: #ffffff !important;
}
.btn {
    margin-top: 37px;
    // text-align: center;
    .icon-button {
        width: 134px;
        height: 36px;
        border-radius: 2px;
        border: 1px solid #01a041;
        line-height: 36px;
        color: #01a041;
        justify-content: center;
        padding: 0px;
        cursor: pointer;
    }
    .icon-button:nth-of-type(1) {
        margin-right: 20px;
    }
}
</style>
