<template>
    <bread-page>
        <div class="main" v-loading="loading">
            <div class="title">{{ info.name }}</div>
            <div class="content">
                <div class="sub-title">需求项</div>
                <div class="info">
                    <div class="info-item">
                        <span class="text1">所属领域：</span>
                        <span class="text2">{{ info.industryName }}</span>
                    </div>

                    <!-- <div class="info-item" v-if="info.patentType">
                        <span class="text1">专利类型：</span>
                        <span class="text2">{{ getLabelName(info.patentType, patentTypeOptions) }}</span>
                    </div> -->
                    <div class="info-item">
                        <span class="text1">{{ `是否专利${info.tpType === 'TECHNOLOGY' ? '技术' : '产品'}` }}：</span>
                        <span class="text2" v-if="info.isPatented">{{
                            getLabelName(info.patentType, patentTypeOptionss)
                        }}</span>
                        <span class="text2" v-else>否</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">交易方式：</span>
                        <span v-if="info.tpType === 'TECHNOLOGY'" class="text2">{{
                            getLabelName(info.mode, tradingMethodOptionsDemand)
                        }}</span>
                        <span v-else class="text2">{{ getLabelName(info.mode, tradingMethodOptionsDemands) }}</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 class="text2">{{ formatTime(info.createdAt, 'YYYY-MM-DD') }}</span>
                    </div>
                    <!-- <div class="info-item">
                        <span class="text1">联系人：</span>
                        <span class="text2">{{ info.contact }}</span>
                    </div>
                    <div class="info-item">
                        <span class="text1">所在地区：</span>
                        <span class="text2">{{ info.address }}</span>
                    </div> -->
                </div>

                <div class="sub-title">需求描述</div>
                <div class="text">
                    {{ info.description }}
                </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 @click.prevent="postMessage" type="primary" class="icon-button" size="small">
                        <i class="iconfont iconfont-nav_icon_xiaoxi"></i>提交留言
                    </el-button>
                </div>
            </div>
            <!-- <div class="btn">
                <el-button type="primary" class="icon-button" size="small" plain>
                    <i class="iconfont iconfont-nav_icon_xiaoxi1"></i>
                    咨询客服
                </el-button>
                <el-button type="primary" class="icon-button"  size="small" plain>
                    <i class="iconfont iconfont-nav_icon_xiaoxi"></i>提交留言
                </el-button>
            </div> -->
        </div>
    </bread-page>
</template>

<script>
import BreadPage from '../../components/page/BreadPage.vue';
import comEvent from '../../mixins/comEvent';
import {
    // patentTypeOptions,
    tradingMethodOptionsDemand,
    tradingMethodOptionsDemands,
    stageOptions,
    tpTypeOptions
} from '../../utils/variables';
export default {
    data() {
        return {
            info: {},
            patentTypeOptionss: [
                { label: '发明', value: 'INVENTION' },
                { label: '实用新型', value: 'UTILITY_MODEL' },
                { label: '外观设计', value: 'APPEARANCE_DESIGN' }
            ],
            stageOptions,
            tradingMethodOptionsDemand,
            tradingMethodOptionsDemands,
            loading: true
        };
    },
    components: {
        BreadPage
    },
    mixins: [comEvent],
    mounted() {
        this.loading = true;
        this.$http.get('/techProductDemand/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 || '/techProductDemand',
                query: {
                    tpType: res.tpType
                }
            });
            this.$EventBus.$emit('changeTitle', info.label + '详情');
            document.title = info.label + '详情';
        });
    },
    created() {
        let addView = {
            id: this.$route.query.id,
            type: 'TechProductDemand'
        };
        // 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: 0 30px 150px;
    position: relative;
}

.title {
    font-size: 24px;
    font-weight: bold;
    color: @warn;
    line-height: 34px;
    text-align: center;
    padding: 50px 0 20px;
    border-bottom: 1px solid @bg;
    margin: 0 70px;
    border-bottom: 1px solid @bg;
}

.sub-title {
    font-size: 16px;
    font-weight: bold;
    color: @warn;
    line-height: 22px;
    padding: 50px 0 16px;
    .flex();
    &::before {
        content: '';
        width: 5px;
        height: 16px;
        background: @warn;
        border-radius: 3px;
        margin-right: 10px;
    }
}

.info {
    .flex();
    flex-wrap: wrap;
    .info-item {
        width: 45%;
        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: 72px;
            flex-shrink: 0;
        }

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

        &:nth-child(2n) {
            .text1 {
                min-width: 98px;
            }
        }
    }
}

.text {
    font-size: 14px;
    color: #000000;
    line-height: 20px;
}

.btn {
    margin-top: 20px;
    text-align: center;
    .icon-button {
        line-height: 42px;
    }
}
</style>
