<template>
  <div>
    <Swiper :banner-array="carouselList" />
    <div id="hot">
      <div class="content">
        <HotNews  v-if="display" :list="hotnewsList"/>
        <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">
          <el-carousel :interval="4000" type="card" height="200px" arrow="always">
            <el-carousel-item v-for="(item, index) in carvideoList" :key="index">
              <div class="carvideo">
                <!-- <video :id="'davideo'+index" :src="item.video" @click="videoPlayer(`davideo${index}`, `daplay${index}`)"/> -->
                 <img class="videoImage" :src="item.image" />
                  <img class="play" src="@/assets/play.png" @click="videoPlayer(item)" :id="'daplay'+index">
              </div>
              <a>{{ item.title }}</a>
            </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">
      <div class="content">
        <div class="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 carList" :key="index"  @click="routerToarticleDetails(item.detail)">
            <img :src="item.image">
            <div class="txt">
              <a class="title">{{ item.title }}</a>
              <a class="subtitle">{{ item.detailText }}</a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <el-dialog title="" v-if="videoDialogVisible" :visible.sync="videoDialogVisible" width="50%">
        <VideoDialog :url="videoUrl" :lock-scroll="false" :append-to-body="true"></VideoDialog>
    </el-dialog>
  </div>
</template>
<script>
/* eslint-disable */
import Swiper from '@/components/swiper'
import { lunboList, hotNewsConfig, guanggao, hotlist, videoList, carArticle } from '@/api/car.js'
import VideoDialog from '@/components/video'
import HotNews from '@/components/hotNews'
export default {
  name: 'information',
  data () {
    return {
      carouselList: [
        // { src: '/car1.png', title: '吉利11月销量再刷新纪录，新能源转型成效凸显', subtitle: '国际汽车企业如果现在一旦脱离了中国市场，再想回来就不可能了。必须了解这个发展的趋势，只有参与才有机会。' },
        // { src: '/car2.png', title: '吉利11月销量再刷新纪录，新能源转型成效凸显', subtitle: '国际汽车企业如果现在一旦脱离了中国市场，再想回来就不可能了。必须了解这个发展的趋势，只有参与才有机会。' }
      ],
      hotnews: {
        title: '这两款产品也将采用“CHN”的模式进行研发',
        img: '/hotnew.png'
      },
      hotnewsList: [],
      carvideoList: [],
      carList: [],
      display: 1,
      gg1: {},
      gg2: {},
      activeIndex: null,
      videoDialogVisible: '',
      videoUrl: ''
    }
  },
  components: {
    Swiper,
    VideoDialog,
    HotNews
  },
  mounted () {
    this.gethotnewsConfig()
    this.getlunboList()
    this.getguanggao()
    this.gethotlist()
    this.getvideoList()
    this.getCarArticle()
  },
  methods: {
    routerToarticleDetails (value) {
      localStorage.setItem('article', value)
      this.$router.push({ path: '/articleDetails' })
    },
    routerTo () {
      this.$router.push({ path: '/articleList' })
    },
    async getlunboList () {
      const { data: { message, data } } = await lunboList()
      if (message === 'success') {
        this.carouselList = data.list
      }
    },
    async gethotnewsConfig () {
      const { data: { message, data: { display } } } = await hotNewsConfig()
      if (message === 'success') {
        this.display = display
      }
    },
    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 gethotlist () {
      const { data: { message, data } } = await hotlist()
      if (message === 'success') {
        this.hotnewsList = data.list
      }
    },
    async getvideoList () {
      const { data: { message, data } } = await videoList()
      if (message === 'success') {
        this.carvideoList = data.list
      }
    },
    videoPlayer (item) {
        this.videoUrl = item.link
        this.videoDialogVisible = true
    },
    async getCarArticle() {
        const { data: { message, data } } = await carArticle()
        if (message === 'success') {
            this.carList = data.list
        }
    }
  }
}
</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, #wk {
  width: 100%;
  background: #E3E5EA;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 30px;
  .content {
    width: 1200px;
    height: 90%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .top, .bottom {
      width: 100%;
    }
    .top {
      min-height: 470px;
      background-color: #FFFFFF;
      display: flex;
      #imgtxt {
        width: 560px;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        img {
          width: 560px;
        }
        .newsTitle{
          position: absolute;
          bottom: 5%;
          left: 5%;
          display: inline-block;
          font-size: 18px;
          font-weight: bold;
          color: #FFFFFF;
          line-height: 80px;
          width: 90%;
          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;
          }
        }
      }
    }
  }
}
#hot {
  min-height: 100px;
  .content {
    margin-top: 20px;
  }
}

#daliay {
  height: 625px;
  .top {
    // justify-content: space-between;
    background-color: #00000000 !important;
    .el-carousel {
      width: 100%;
      height: 100% !important;
      background-color: #00000000 !important;

      :deep .el-carousel__container {
        background-color: #00000000 !important;
        height: 100% !important;
      }
    }
    :deep .el-carousel__indicators--outside, .el-carousel__indicators--horizontal {
      display: none;
    }
    :deep .el-carousel__mask {
      background-color: #00000000 !important;
    }
    :deep .el-carousel__arrow--left {
      left: 280px;
    }
    :deep .el-carousel__arrow--right {
      right: 280px;
    }
    :deep .el-carousel__arrow {
      width: 40px;
      height: 40px;
      border-radius: 0%;
      background-color: #ffffffcc;
      color:#07CAAF;
      font-size: 20px;
      font-weight: bold;
      border-radius: 3px;
      top: 43%;
    }
     .el-carousel__item {
        display: flex;
        flex-direction: column;
        // justify-content: center;
        align-items: center;
        .carvideo {
        //   width: 660px;
        //   height: 90%;
          position: relative;
          .play {
            position: absolute;
            margin: 0 auto;
            top: 50%;
            margin-left: 45%;
            margin-top: -50px;
          }
          .videoImage {
            width: 100%;
            border-radius: 10px;
          }
        }
        a {
          font-size: 24px;
          font-weight: bold;
          color: #00161C;
          line-height: 48px;

        }
     }
  }
}

#wk {
    padding-bottom: 200px;
 .content {
  background-color: #FFFFFF;
  display: flex;
  align-items: center;
  position: relative;

  .htitle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 93%;
    margin-bottom: 20px;
    .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;
      z-index: 999;
    }
  }
  #hotList {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    .list {
      z-index: 999;
      display: flex;
      justify-content: center;
      width: 500px;
      margin: 0 40px 34px 33px;
      .txt {
        display: flex;
        flex-direction: column;
        margin-left: 22px;
        align-items: center;
        width: 60%;
        .title {
          text-align: left;
          width: 100%;
          font-size: 18px;
          font-weight: bold;
          color: #010101;
        }
        .subtitle{
          display: inline-block;
          text-align: left;
          width: 100%;
          font-size: 14px;
          font-weight: 400;
          color: #000000;
          line-height: 24px;
          margin-top: 10px;
          display: -webkit-box; /* Safari */
            -webkit-line-clamp: 3; /* Safari and Chrome */
            -webkit-box-orient: vertical; /* Safari and Chrome */
            overflow: hidden;
        }
      }
      img {
        width: 200px;
        height: 150px;
        border-radius: 10px;
      }
    }
  }
 }
 .content::after {
    content: '';
    width: 100%;
    height: 100%;
    position: absolute;
    background-image: url('../../assets/cartxt.png');
    background-position: 101% 0; /* 调整这些值来改变显示的部分 */
    background-size: 12% 50%; /* 使用 'cover' 或 'contain'，或者设置具体尺寸 */
    background-repeat: no-repeat;
  }
}
</style>
