<template>
  <div class="autoBox container-box">
    <div class="bread-crumb">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: 'home' }">{{lang=='en'? 'Home': '首页'}}</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: 'ConferenceServices'}">{{lang=='en'? 'Conferences': '会议'}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{lang=='en'? detailData.meetingNameEn: detailData.meetingName}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="content-box">
        <div style="display: flex; padding-bottom: 30px">
            <div class="section-left">
                <div class="conference-detail-info">
                    <div>
                        <p class="title">{{lang=='en'? detailData.meetingNameEn: detailData.meetingName}}</p>
                        <!-- <p>
                            <span>{{lang=='en'? 'Sponsor': '主办方'}}：</span><span class="sponsor">{{lang=='en'? detailData.meetingSponsorEn: detailData.meetingSponsor}}</span>
                        </p> -->
                        <div style="display: flex; justify-content: space-between;margin-top: 50px">
                            <div>
                                <span
                                class="time"
                                v-if="detailData.meetingStartDate"
                                >{{formatDate(detailData.meetingStartDate)}}-{{formatDate(detailData.meetingEndDate)}}</span>
                                <span class="place">{{lang=='en'?detailData.meetingPlaceEn: detailData.meetingPlace}}</span>
                            </div>
                            <!-- <div class="share">
                                <span><i class="el-icon-star-off"></i> {{lang=='en'? 'Attention': '关注'}}</span>
                                <span><i class="el-icon-share"></i> {{lang=='en'? 'Share': '分享'}}</span>
                            </div> -->
                        </div>
                        <p class="introduction">{{lang=='en'? detailData.meetingIntroductionEn: detailData.meetingIntroduction}}</p>
                    </div>
                </div>
                <div class="conference-detail-other">
                    <div class="confrence-item" v-if="detailData.meetingYichengEn || detailData.meetingYicheng">
                        <!-- <div class="confrence-item-header" >{{lang=='en'? 'Agenda': '议程'}}</div> -->
                        <div class="confrence-item-body">
                            <div v-html="lang=='en'? detailData.meetingYichengEn: detailData.meetingYicheng"></div>
                        </div>
                    </div>
                    <div class="confrence-item" style="display: flex; justify-content: space-between;margin-top: 30px">
                    <!-- <div class="confrence-item"> -->
                        <div>
                            <a :href="'./api/file/pub/'+agendaData" target="_blank" class="agenda-title" v-if="agendaData">{{lang=='en'? 'View the Meeting agenda': '查看会议议程'}} <i class="el-icon-view"></i></a>
                        </div>
                    </div>
                    <div class="confrence-item" style="display: flex; justify-content: space-around;">
                        <div style="width: 100%" v-if="detailData.meetingIsShow=='01' && !isMeetingOver(detailData.meetingEndDate)">
                            <div class="sign-up-btn" v-if="detailData.meetingMainFormDict=='01'">
                                <p v-if="lang=='zh' && detailData.isShowZhOnsite=='Yes'">如您希望到现场（{{detailData.meetingPlace}}）参加我们的大会，<span class="link" @click="enroll('MeetingApplyForm', detailData.id)">请点击此处报名</span>。</p>
                                <p v-if="lang=='en' && detailData.isShowEnOnsite=='Yes'">If you want to attend the conference on-site in {{detailData.meetingPlaceEn}}, <span class="link" @click="enroll('MeetingApplyForm', detailData.id)">please click here to register</span>.</p>
                            </div>
                            <div class="sign-up-btn" v-else-if="detailData.meetingMainFormDict=='02'">
                                <p v-if="lang=='zh' && detailData.isShowZhOnline=='Yes'">如您希望通过网络会议系统参加我们的大会，<span class="link" @click="enroll('ConferenceNetwork', detailData.id)">请点击此处报名</span>。</p>
                                <p v-if="lang=='en' && detailData.isShowEnOnline=='Yes'">If you want to attend our conference online, <span class="link" @click="enroll('ConferenceNetwork', detailData.id)">please click here to register</span>.</p>
                            </div>
                            <div v-else-if="detailData.meetingMainFormDict=='03'">
                                <div v-if="lang=='zh'" class="sign-up-btn">
                                    <p v-if="detailData.isShowZhOnline=='Yes'">如您希望通过网络会议系统参加我们的大会，<span class="link" @click="enroll('ConferenceNetwork', detailData.id)">请点击此处报名</span>。</p>
                                    <p v-if="detailData.isShowZhOnsite=='Yes'">如您希望到现场（{{detailData.meetingPlace}}）参加我们的大会，<span class="link" @click="enroll('MeetingApplyForm', detailData.id)">请点击此处报名</span>。</p>
                                </div>
                                <div v-else class="sign-up-btn">
                                    <p v-if="detailData.isShowEnOnline=='Yes'">If you want to attend our conference online, <span class="link" @click="enroll('ConferenceNetwork', detailData.id)">please click here to register</span>.</p>
                                    <p v-if="detailData.isShowEnOnsite=='Yes'">If you want to attend the conference on-site in {{detailData.meetingPlaceEn}}, <span class="link" @click="enroll('MeetingApplyForm', detailData.id)">please click here to register</span>.</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="section-right">
                <div class="conference-recommend" v-if="recommendData.length">
                    <p class="title">{{lang=='en'? 'Upcoming Events': '近期会议'}}</p>
                    <ul class="conference-recommend-list">
                        <li v-for="(item, i) in recommendData" :key="i" @click="toView('ConferenceDetail', item.id)">
                        <!-- <li v-for="(item, i) in recommendData" :key="i" @click="toView('ConferenceBlank', item.id)"> -->
                            <div class="conference-recommend-top">
                            <span class="time">{{formatDate(item.meetingStartDate)}}</span>
                            <span class="step"></span>
                            <span class="title">{{lang=='en'?item.meetingNameEn: item.meetingName}}</span>
                            </div>
                            <div class="conference-recommend-body">
                            <span class="place">{{lang=='en'? item.meetingPlaceEn: item.meetingPlace}}</span>
                            <p class="introduction plate">{{lang=='en'? item.meetingIntroductionEn: item.meetingIntroduction}}</p>
                            <!-- <p class="sponsor">{{lang=='en'? item.meetingSponsorEn: item.meetingSponsor}}</p> -->
                            </div>
                        </li>
                    </ul>
                    <div class="no-data" v-if="recommendData.length < 4">{{lang=='en'? 'Coming Soon': '敬请期待'}}</div>
                    <!-- <span class="more">{{lang=='en'? 'MORE': '更多'}}</span> -->
                </div>
                <div v-else class="recommend-no-data">
                    <img v-if="lang=='en'" width="150" height="150" src="@/assets/img/conference/no-data-en.png" alt="">
                    <img v-else width="150" height="150" src="@/assets/img/conference/no-data-zh.png" alt="">
                </div>
            </div>
        </div>
    </div>
    <LoginReminder ref="loginReminder"></LoginReminder>
  </div>
</template>

<script>
import { getConfrences, getAllNews, meetingParamConfigs} from "@/api/meeting/meetingOutInfo";
import LoginReminder from './LoginReminder'
export default {
    components:{
        LoginReminder
    },
    inject:['reload'],
    data(){
        return {
            recommendData: [],
            detailData: {},
            agendaData: '',
            newsData: [],
            lang: '',
            currentMeeting: '',
            postData: {
                id: this.$route.query.key,
                // id: window.localStorage.getItem('conferenceId'),
                page: 1,
                size: 5,
            },
            // 参会意向配置
            intentions: {},
            //meetingConfigs:{},
        }
    },
    created(){
        this.lang = this.$i18n.locale;
    },
    watch: {
        '$i18n.locale'(val){
            this.lang = val;
        },
        '$route.query.key'(val){
            this.reload();
        }
    },
    mounted(){
        this.getData();
    },
    methods: {
        getData(){
            getAllNews(this.postData).then(res=>{
                console.log('全部数据', res)
                this.detailData = res.data.basicInfo;
                this.intentions = {
                    isShowZhOnsiteIntention: this.detailData.isShowZhOnsiteIntention,//是否显示中文(现场)参会意向入口
                    isShowZhOnlineIntention: this.detailData.isShowZhOnlineIntention,//是否显示中文(网络)参会意向入口
                    isShowEnOnsiteIntention: this.detailData.isShowEnOnsiteIntention,//是否显示英文(现场)参会意向入口
                    isShowEnOnlineIntention: this.detailData.isShowEnOnlineIntention,//是否显示英文(网络)参会意向入口
                };
                console.log('this.intentions',this.intentions);
                if(res.data.meetingOutInfo.image.length){
                    let filterdFile = [];
                    res.data.meetingOutInfo.image.forEach((item) => {
                        if(item.photoType == "meeting_yicheng"){
                            filterdFile.push(item);
                        }
                    });
                    this.agendaData = filterdFile[0].list[0].attachmentSavePath;
                }else{
                    this.agendaData = '';
                }
                this.currentMeeting = res.data.basicInfo.id;
                // this.newsData = res.data.meetingOutInfo.news;
                // console.log('全部数据', this.detailData)
                // console.log('新闻数据', this.newsData)
                getConfrences().then(res=>{
                    this.recommendData = [];
                    res.data.meetingBasicInfos.forEach(item=>{
                        if(!this.isMeetingOver(item.meetingEndDate) && item.meetingIsShow=="01" && item.meetingIsEnroll=="01" && item.id != this.currentMeeting){
                            this.recommendData.push(item)
                        }
                    })
                    // console.log('会议', this.recommendData)
                })
            })

            /**
             * 会议参数配置
             */
            // meetingParamConfigs('apply_online_link_en,apply_onsite_link_en,apply_onsite_link_zh,apply_online_link_zh').then(res=>{
            //     console.log('res:', res)
            //     this.meetingConfigs = res.data.meetingParamConfigs
            // })
        },
        toView(path, id){
            // localStorage.setItem('conferenceId', id);
            this.$router.push({ path: path, query: { key: id} });
        },
        enroll(path, id){
            let rpath = { path: path, query: { key: id, intentions: this.intentions}};
            sessionStorage.setItem('pathReminder', JSON.stringify(rpath));
            this.$refs.loginReminder.activeChange(path, id);
        },
        formatDate(t) {
            if(!t){
                return ''
            }else{
                var original = new Date(t);
                var year=original.getFullYear();
                var month=original.getMonth()+1;
                var date=original.getDate();
                var hour=original.getHours();
                var minute=original.getMinutes();
                var second=original.getSeconds();
                // return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
                return year+"/"+month+"/"+date;
            }
        },
        isMeetingOver(t){
            var ct = Date.parse(new Date());
            if(ct-t > 0){
                return true;
            }else{
                return false;
            }
        },
    }
}
</script>

<style scoped>
* {
  box-sizing: border-box;
}
.container-box {
  margin: 10px auto;
  min-height: calc( 100vh - 420px );
  background: #fff;
}
.bread-crumb {
  background: #fff;
  padding: 10px 20px;
}
.content-box{
    position: relative;
    padding: 0 20px;
    padding-bottom: 40px;
}
.section-left{
  width: 70%;
  padding-right: 40px;
  border-right: 4px solid #f2f2f2;
}
.section-right{
  width: 30%;
}
.conference-detail-info{

}
.conference-detail-info p{
    margin: 0;
    font-size: 16px;
}
.conference-detail-info p span{
    line-height: 48px;
    color: #797979;
}
.conference-detail-info .title{
    font-size: 36px;
    margin: 20px 0;
}
.conference-detail-info .sponsor{
    line-height: 48px;
    color: #797979;
}
.conference-detail-info .introduction{
    line-height: 35px;
    margin-top: 20px;
    color: #2c3e50;
}
.share span{
    cursor: pointer;
    margin-left: 30px;
}
.share span:hover{
    color: #168dbf;
}
.conference-recommend{
  position: relative;
  padding-bottom: 40px;
  padding-left: 20px;
}
.conference-recommend .no-data{
  color: #555;
  line-height: 26px;
  background: #f2f2f2;
  padding: 0 6px;
  font-size: 14px;
  text-align: center;
}
.conference-recommend .more{
  font-size: 20px;
  position: absolute;
  line-height: 27px;
  bottom: 10px;
  right: 10px;
}
.conference-recommend > .title{
    font-size: 18px;
    line-height: 18px;
    font-weight: bold;
    margin-top: 20px;
    margin-bottom: 20px;
    border-left: 8px solid #02a7f0;
    padding-left: 10px;
}
.conference-recommend-list{
    background: #fff;
}
.conference-recommend-top{
  background: #f2f2f2;
  line-height: 20px;
  font-size: 14px;
  display: flex;
  padding: 3px 6px;
}
.conference-recommend-top .step{
  display: block;
  width: 10px;
  position: relative;
  margin: 0 14px;
}
.conference-recommend-top .step::after{
  content: '';
  display: block;
  width: 9px;
  height: 9px;
  border: 1px solid #02a7f0;
  border-radius: 50%;
  position: absolute;
  top: 5px;
  left: 0px;
}
.conference-recommend-top .title{
  flex: 1;
  color: #02a7f0;
}
.time{
  width: 76px;
  color: #555;
  position: relative;
  padding-right: 15px;
  margin-right: 15px;
}
.time::after{
  width: 1px;
  height: 12px;
  background: #555;
  content: '';
  display: block;
  position: absolute;
  top: 5px;
  right: 0;
}
.conference-recommend .time{
    margin-right: 0;
}
.conference-recommend .time::after{
    width: 0px;
}
.conference-recommend-body{
  display: flex;
  color: #aaa;
  padding: 12px 0;
}
.conference-recommend-body .place{
  font-size: 12px;
  width: 100px;
  border-right: 1px dotted #f2f2f2;
  text-align: right;
  line-height: 24px;
  padding: 0 12px;
}
.conference-recommend .introduction{
    font-size: 12px;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    margin: 0 10px;
    position: relative;
    line-height: 20px;
    overflow: hidden;
    height: 84px;
}
.conference-recommend-list li{
    margin-bottom: 30px;
    cursor: pointer;
}
.conference-recommend-list li img{
    width: 100%;
}
.conference-recommend-list li p{
    margin: 20px 0;
}
.conference-recommend-list li:hover p{
    color: #2c558a;
}
.conference-detail-other{
    margin-top: 40px;
    position: relative;
}
.el-button{
    font-size: 24px;
}
.confrence-item-header{
    font-size: 18px;
    line-height: 18px;
    font-weight: bold;
    margin-top: 20px;
    margin-bottom: 20px;
    border-left: 8px solid #02a7f0;
    padding-left: 10px;
}
.conference-news-box{
    padding: 0 50px;
}
.conference-news-list li{
    display: flex;
    padding: 20px 0;
    color: #666;
    cursor: pointer;
    border-bottom: 1px solid #999;
}
.conference-news-list li p{
    flex: 1;
    margin: 0;
    /* width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; */
    font-size: 16px;
}
.conference-news-list li:hover p{
    color: #dd511b;
}
.conference-news-list li span{
    width: 100px;
    text-align: right;
    font-size: 16px;
}
/deep/ .el-carousel{
    height: 800px;
    width: 600px;
    margin: 0 auto;
}
/deep/ .el-carousel__container{
    height: 800px;
}
/deep/ .el-carousel__item{
    height: 800px;
}
/deep/ .el-carousel__item img{
    max-width: 100%;
    max-height: 100%;
}
/deep/ .el-carousel__indicator--horizontal {
    padding: 0 3px;
}
/deep/ .el-carousel__button {
    width: 8px;
    height: 8px;
    background-color: #999;
    border-radius: 100%;
}
/deep/ .is-active .el-carousel__button{
    background: #3a8ee6;
}
.agenda-title{
  font-size: 20px;
  line-height: 42px;
  height: 42px;
  cursor: pointer;
  color: #02a7f0;
  font-weight: bold;
  text-decoration: none;
  border-bottom: 2px solid #02a7f0;
  font-style: italic;

}
.agenda-title:hover{
  color: #d55421;
  border-bottom-color: #d55421;
}
.recommend-no-data{
    width: 100%;
    height: 100%;
}
.recommend-no-data img{
    margin-top: 50%;
    margin-left: 50%;
    transform: translate(-50%, -50%);
}
.sign-up-btn /deep/ .el-button{
    background-color: #1b3c85;
    border-color: #1b3c85;
    color: #fff;
}
.sign-up-btn /deep/ .el-button:hover{
    opacity: 0.9;
}
.sign-up-btn .link{
    color: #209bd3;
    border-bottom: 1px solid #209bd3;
    cursor: pointer;
}
.sign-up-btn .link:hover{
    color: #d85221;
    border-color: #d85221;
}
</style>
