<template>
  <div>
    <Swiper :banner-array="carouselList" />
    <div id="hot">
      <div class="content">
        <div class="top">
          <el-carousel :interval="5000" arrow="always" height="470px">
              <el-carousel-item v-for="(item, index) in hotList"  :key="index">
                <div class="lr videocar">
                  <img class="videoImage" :src="item.news.videoImage" />
                  <img class="play" src="@/assets/play.png" @click="videoPlayer(item)" :id="'play'+index">
                </div>
                <div id="hottxt" class="lr">
                  <div class="txtcontent">
                    <div class="title">
                      <img src="@/assets/tt.png">
                      {{ item.news.title }}
                    </div>
                    <p class="content">{{ item.news.detailText }}</p>
                  </div>
                  <div class="btn">
                    <el-button plain class="more" size="small" @click="routerToCar">MORE</el-button>
                  </div>
                </div>
              </el-carousel-item>
          </el-carousel>
        </div>
        <div class="hotnews"  v-if="display">
          <div id="imgtxt" @click="routerToarticleDetails(hotnews.detail)">
            <img :src="hotnews.img">
            <a class="newsTitle">{{ hotnews.title }}</a>
          </div>
          <div id="hottxt">
            <div id="htitle">
              <a class="tle">热点新闻</a>
              <el-button type="text" @click="routerTo">MORE+</el-button>
            </div>
            <div id="hotList">
              <div class="list" v-for="(item, index) in hotnewsList" :key="index" @click="routerToarticleDetails(item.detail)">
                <img :src="item.img">
                <a>{{ item.title }}</a>
              </div>
            </div>
          </div>
        </div>
        <a :href="gg1.link" v-if="gg1.img" target="_blank">
          <img class="bottom" :src="gg1.img" alt="">
        </a>
        </div>
    </div>
    <div id="daliay">
      <div class="content">
        <div class="top">
          <img src="@/assets/rblogo.png" class="logo">
          <el-carousel :interval="5000" arrow="always" height="470px">
              <el-carousel-item  v-for="(item, index) in daliay"  :key="index">
                <div class="yyzrbtxt lr">
                  <div class="txtcontent">
                    <div class="title">
                      {{ item.news.title }}
                    </div>
                    <p class="content">{{ item.news.detailText }}</p>
                  </div>
                  <div class="btn">
                    <el-button plain class="more" size="small" @click="routerToMate">MORE</el-button>
                  </div>
                </div>
                <div class="yyzrbimg lr" >
                    <img class="videoImage" :src="item.news.videoImage" />
                  <img class="play" src="@/assets/play.png" @click="videoPlayer(item)" :id="'daplay'+index">
                </div>
              </el-carousel-item>
          </el-carousel>
        </div>
        <a :href="gg2.link" v-if="gg2.img" target="_blank">
            <img class="bottom" :src="gg2.img" alt="">
        </a>
      </div>
    </div>
    <div id="wk">
        <a :href="alink" target="_blank">
             <img src="@/assets/wk.png" alt="">
            <el-button type="primary" class="wkbtn" size="medium">点击进入</el-button>
        </a>
    </div>
    <el-dialog title="" v-if="videoDialogVisible" :visible.sync="videoDialogVisible" width="50%">
        <VideoDialog :url="videoUrl"></VideoDialog>
    </el-dialog>
  </div>
</template>
<script>
/* eslint-disable */
import { lunboList, carNewsHotList, guanggao, link, yuanyuzhouHotList, hotnewsConfig, hotnews } from '@/api/home.js'
import Swiper from '@/components/swiper'
import VideoDialog from '@/components/video'

export default {
  name: 'home',
  data () {
    return {
      videoDialogVisible: false,
      videoUrl: '',
      carouselList: [],
      hotList: [],
      gg1: {},
      gg2: {},
      alink: '',
      daliay: [],
      display: 0,
      hotnews: {
        title: '这两款产品也将采用“CHN”的模式进行研发',
        img: '/hotnew.png'
      },
      hotnewsList: []
    }
  },
  components: { Swiper, VideoDialog },
  mounted () {
    this.gethotnewsConfig()
    this.getlunboList()
    this.getcarNewsHotList()
    this.getguanggao()
    this.getLink()
    this.getyuanyuzhouHotList()
    this.gethotlist()
  },
  methods: {
    routerToarticleDetails (value) {
      localStorage.setItem('article', value)
      this.$router.push({ path: '/articleDetails' })
    },
    routerTo () {
      this.$router.push({ path: '/articleList' })
    },
    routerToCar () {
      this.$router.push({ path: '/information' })
    },
    routerToMate () {
      this.$router.push({ path: '/metadaily' })
    },
    async getlunboList () {
      const { data: { message, data } } = await lunboList()
      if (message === 'success') {
        this.carouselList = data.list
      }
    },
    async getcarNewsHotList () {
      const { data: { message, data } } = await carNewsHotList()
      if (message === 'success') {
        this.hotList = data.list
      }
    },
    async getguanggao () {
      const { data: { message: ggm1, data: gg1 } } = await guanggao(1)
      const { data: { message: ggm2, data: gg2 } } = await guanggao(2)
      if (ggm1 === 'success' && ggm2 === 'success') {
        this.gg1 = {
          img: gg1.image,
          link: gg1.link
        }
        this.gg2 = {
          img: gg2.image,
          link: gg2.link
        }
      }
    },
    async getLink () {
      const { data: { message, data: { link: alink } } } = await link()
      if (message === 'success') {
        this.alink = alink
      }
    },
    async getyuanyuzhouHotList () {
      const { data: { message, data: { list } } } = await yuanyuzhouHotList()
      if (message === 'success') {
        this.daliay = list
        // for (const iter of list) {
        //   this.daliay.left.push({
        //     title: iter.news.title,
        //     content: iter.news.detail
        //   })
        //   this.daliay.right.push({
        //     img: iter.news.image,
        //     video: iter.news.video
        //   })
        // }
      }
    },
    async gethotnewsConfig () {
      const { data: { message, data: { display } } } = await hotnewsConfig()
      if (message === 'success') {
        this.display = display
      }
    },
    videoPlayer (item) {
        this.videoUrl = item.news.video
        this.videoDialogVisible = true
    //   const id = document.getElementById(value)
    //   const playid = document.getElementById(play)
    //   if (id.paused) {
    //     id.play()
    //     playid.style.display = 'none'
    //   } else {
    //     id.pause()
    //     playid.style.display = 'block'
    //   }
    },
    async gethotlist () {
      const { data: { message, data } } = await hotnews()
      console.log(data)
      if (message === 'success') {
        this.hotnews.title = data.list[0].title
        this.hotnews.img = data.list[0].image
        this.hotnews.detail = data.list[0].detail
        for (let index = 1; index < data.list.length; index++) {
          this.hotnewsList.push({
            title: data.list[index].title,
            img: data.list[index].image,
            subtitle: data.list[index].subTitle,
            detail: data.list[index].detail
          })
        }
      }
    },
  }
}
</script>
<style lang="scss" scoped>
.el-carousel__item{
  background-size: 100%;
  background-repeat: no-repeat;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  #txt {
    display: flex;
    flex-direction: column;
    margin-bottom: 50px;
    color: #FFFFFF;
    .title {
      font-size: 36px;
      font-weight: bold;
      text-align: center;
      margin-bottom: 15px;

    }
    .subtitle {
      font-size: 16px;
      font-weight: 400;
      opacity: 0.5;
      text-align: center;
    }
  }
}
#hot, #daliay {
  width: 100%;
  background: #E3E5EA;
//   display: flex;
//   align-items: center;
//   justify-content: center;
  padding: 25px 0;
  .content {
    width: 1200px;
    margin: 0 auto;
    .top, .bottom {
      width: 100%;
    }
    .hotnews {
      min-height: 100px;
      margin-top: 20px;
      min-height: 470px;
      background-color: #FFFFFF;
      display: flex;
      margin-bottom: 30px;
      background-image: url('../../assets/hotTopLeft.png');
      background-position: 101% 0; /* 调整这些值来改变显示的部分 */
      background-size: 30% 50%; /* 使用 'cover' 或 'contain'，或者设置具体尺寸 */
      background-repeat: no-repeat;
      #imgtxt {
        width: 560px;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-left: 20px;
        img {
          width: 560px;
        }
        .newsTitle{
          position: absolute;
          bottom: 5%;
          left: 0;
          display: inline-block;
          font-size: 18px;
          font-weight: bold;
          color: #FFFFFF;
          line-height: 48px;
          width: 100%;
          background-color: #0000007e;
        }
      }

      #hottxt {
        display: flex;
        justify-content: space-around;
        flex-direction: column;
        align-items: center;
        flex: 1;
        margin-left: 35px;
        #htitle {
          display: flex;
          justify-content: space-between;
          align-items: center;
          width: 95%;
          .tle {
            z-index: 9;
            font-size: 26px;
            font-weight: bold;
            color: #00161C;
            line-height: 48px;
            display: inline-block;
            position: relative;
            text-decoration: none; /* 移除默认的下划线 */
          }
          .tle::after {
            content: '';
            position: absolute;
            left: -15px;
            bottom: 10px;
            width: 65%;
            height: 6px; /* 横线高度为文字高度的一半 */
            background-color: #07CAAF;; /* 横线颜色与文字颜色相同 */
            z-index: -1;
          }
          .el-button {
            font-size: 16px;
            font-weight: bold;
            color: #07CAAF;
            line-height: 48px;
            cursor: pointer;
            z-index: 9999;
          }
        }
      }
      #hotList {
        height: 76%;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        .list {
          z-index: 999;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          width: 150px;
          margin-right: 39px;
          img {
            width: 150px;
            height: 112px;
            border-radius: 10px;
          }
          a {
            font-size: 14px;
            font-weight: 400;
            color: #010101;
            margin-top: 14px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 150px;
            // line-height: 48px;
          }
        }
      }
      .top {
          margin-bottom: 30px;
          background-color: #FFFFFF;
          display: flex;
          background-image: url('../../assets/hotTopLeft.png');
          background-position: 101% 0; /* 调整这些值来改变显示的部分 */
          background-size: 30% 50%; /* 使用 'cover' 或 'contain'，或者设置具体尺寸 */
          background-repeat: no-repeat;
          #imgtxt {
            width: 560px;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-left: 20px;
            img {
              width: 560px;
            }
            .newsTitle{
              position: absolute;
              bottom: 5%;
              left: 0;
              display: inline-block;
              font-size: 18px;
              font-weight: bold;
              color: #FFFFFF;
              line-height: 48px;
              width: 100%;
              background-color: #0000007e;
            }
          }
        }
    }
    .top {
    //   min-height: 470px;
      // background: black;
    //   display: flex;
    //   padding-bottom: 30px;
    :deep .el-carousel__button {
      width: 5px;
      border-radius: 50%;
      height: 5px;
    }
    .lr {
        // width: 50%;
        width: 650px;
        height: 100%;
        video {
          width: 100%;
          height: 100%;
        }

      }
      .videocar {
        position: relative;
        .videoImage{
            width: 650px;
        }
        .play {
          position: absolute;
          margin: 0 auto;
          top: 50%;
          margin-left: 45%;
          margin-top: -50px;
        }
      }

      .el-carousel {
        width: 100% !important;
      }

      #hottxt {
        background: #000000e6;
        background-image: url('../../assets/footer_left.png');
        background-position: 140% -165px; /* 调整这些值来改变显示的部分 */
        background-size: 140% 130%; /* 使用 'cover' 或 'contain'，或者设置具体尺寸 */
        background-repeat: no-repeat;
        display: flex;
        align-items: center;
        flex-direction: column;
        width: 550px;
        padding: 0 40px;
        :deep .el-carousel__indicators--horizontal {
          left: 90%;
        }
          .txtcontent {
            // height: 50% !important;
            width:100%;
            padding-top: 20px;

            .title {
              height: 26px;
              font-size: 24px;
              font-weight: bold;
              color: #FFFFFF;
              width: 100%;
              display: flex;
              text-align: left;
              margin-top: 30px;
              img {
                width: 60px;
                height: 28px;
                margin-right: 10px;
                vertical-align: middle;
                float: left;
                margin-top: 5px;
              }
            }
            p {
              text-align: left;
              width: auto;
              font-size: 16px;
              font-weight: 400;
              line-height: 30px;
              color: #ffffff83;
              margin-top: 25px;
              word-wrap: break-word;
            }
          }
          .btn {
            // height: 20%;
            width:100%;
            position: relative;
            text-align: left;
            .more {
            //   position: absolute;
            //   left: 0px;
              background: none !important;
              border: 1px solid #00F6BD;
              opacity: 0.8;
              border-radius: 4px;
              color: #00F6BD;
              margin-top: 30px;
            }
          }
      }
    }
    .bottom {
      margin-top: 30px;
    }
  }
}
#hot :deep .el-carousel__indicators--horizontal , #daliay :deep .el-carousel__indicators--horizontal {
    right: 50px;
    left: auto;
    bottom: 20px;
}
#daliay {
  background: #F2F4F8;
  padding-top: 60px;
  .logo {
    width: 165px;
  }
  .content {
    .top {
      flex-direction:column;
    }
  }
  .top {
    justify-content: space-between;
    position: relative;

    .yyzrbtxt, .yyzrbimg{
      height: 100%;
      width: 47%;
      .videoImage{
        width: 640px;
      }
      .txtcontent {
        height: 80% !important;
        text-align: left;
        margin-right: 50px;
        width: 90%;
        margin-top: 35px;
        .title {
          border-left: 7px solid #07CAAF;
          font-size: 36px;
          font-weight: bold;
          color: #0D1114;
          width: 90%;
          text-align: left;
          padding-left:15px;

        }
        .content {
          font-size: 16px;
          font-weight: 400;
          color: #0D1114;
          line-height: 30px;
          width: 100%;
          text-align: left;
          margin-top: 30px;
        }
      }
      .btn {
        width:100%;
        position: absolute;
        bottom: 90px;
        .more {
          position: absolute;
          left: 0px;
          background: none !important;
          border: 1px solid #000000;
          color: #0D1114;
          opacity: 0.8;
          border-radius: 4px;
          width: 80px;
        }
      }
    }
    .yyzrbimg {
    //   width: 50% !important;
      position: relative;
      .play {
        position: absolute;
        margin: 0 auto;
        top: 50%;
        margin-left: 45%;
        margin-top: -50px;
      }
    }
  }
}
#wk {
  width: 100%;
  position: relative;
  img {
    width: 100%;
  }
  .el-button--primary {
    width: 200px;
    height: 60px;
    background: #07CAAF;
    border-radius: 12px;
    border: none;
    font-size: 18px;
    font-weight: 400;
    color: #FFFFFF;
    position: absolute;
    bottom: 10%;
    left: 50%;
    margin-left: -100px;
  }
}

</style>
