<template>
  <div class="wrap" v-if="modules.length >= 1">
    <el-carousel :interval="6000"
      :arrow="(modules[0] && modules[0].list.filter(e => e.isEnable).length > 1) ? 'hover' : 'never'"
      :indicator-position="modules[0].list.filter(e => e.isEnable).length > 1 ? '' : 'none'">
      <template v-for="(item, i) in modules[0].list">
        <el-carousel-item v-if="item.pic && item.isEnable" :key="i">
          <div :class="['banner-item', { 'cursor-pointer': isLink(item.link.linkName) }]" @click="openLink(item)">
            <img :src="item.pic" alt="">
            <p class="banner-name">{{ item.title }}</p>
          </div>
        </el-carousel-item>
      </template>
    </el-carousel>

    <div class="block history gray">
      <div class="inner">
        <h2 class="wow fadeInLeft" style="margin-left: 57px">{{ modules[1].form.title }}</h2>
        <div class="texts wow fadeInDown" data-wow-delay="0.5s">
          <div class="left">
            <h2>{{ modules[1].form.subTitle }}</h2>
            <!-- <div class="line"></div> -->
            <div class="des">{{ modules[1].form.des }}</div>
            <img v-if="modules[1].form.link" :class="{ 'arrow': isLink(modules[1].form.link.linkName) }"
              src="@/assets/images/arrow.png" alt="" @click="openLink(modules[1].form)">
          </div>
          <img class="bg" width="562" height="506" :src="modules[1].form.pic" alt="">
        </div>
      </div>
    </div>

    <div class="block">
      <div class="inner app-inner">
        <h2 class="b-title wow fadeInUp">{{ modules[2].form.title }}</h2>
        <p class="intro wow fadeInUp" data-wow-delay="0.5s">{{ modules[2].form.des }}</p>
        <ul class="app">
          <li v-for="(item, i) in modules[3].list" :key="i" class="wow fadeInDown"
            :data-wow-delay="(0.2 * i).toFixed(1) + 's'" :class="{ 'cursor-pointer': isLink(item.link.linkName) }"
            @click="openLink(item)">
            <img class="bg" :src="require('@/assets/images/application/app' + (i + 1) + '.png')" alt="">
            <img class="icon" :src="require('@/assets/images/application/app' + (i + 1) + '-1.png')" alt="">
            <p class="text">{{ item.title }}</p>
          </li>
        </ul>
      </div>
    </div>

    <div class="block gray">
      <div class="inner">
        <h2 class="b-title wow fadeInUp">{{ modules[4].form.title }}</h2>
        <p class="intro wow fadeInUp" data-wow-delay="0.5s">{{ modules[4].form.des }}</p>
        <ul class="group">
          <li v-for="(item, i) in modules[5].list" :key="i" class="wow fadeInDown"
            :data-wow-delay="(0.2 * i).toFixed(1) + 's'" :class="{ 'cursor-pointer': isLink(item.link.linkName) }"
            @click="openLink(item)">
            <img :src="item.pic" alt="">
            <p class="text">{{ item.title }}</p>
          </li>
        </ul>
      </div>
    </div>

    <div class="block news-block">
      <div class="inner">
        <h2 class="b-title wow fadeInUp">{{ modules[6].form.title }}</h2>
        <p class="intro wow fadeInUp" data-wow-delay="0.5s">{{ modules[6].form.des }}</p>
        <ul class="news">
          <li v-for="(item, i) in articles" :key="i" class="wow fadeInDown" :data-wow-delay="(0.2 * i).toFixed(1) + 's'"
            @click="toArtice(item, modules[7].form)">
            <img :src="item.titleImg" alt="">
            <div class="texts">
              <h6>{{ item.title }}</h6>
              <div class="des" v-html="item.mainBody"></div>
              <span class="meta">{{ item.releaseTime }}</span>
            </div>
          </li>
        </ul>
        <div class="all-link" @click="toAll(modules[7].form)">
          <span>{{ $t('column.all') }} <img class="icon" src="@/assets/images/arrow.png" alt=""></span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import mixins from '@/mixins/page'
import Setting from '@/setting'
import Util from '@/libs/util'
import WOW from 'wow.js'
export default {
  mixins: [mixins],
  data () {
    return {
      articles: []
    }
  },
  mounted () {
    new WOW().init()
  },
  methods: {
    // 获取文章详情
    getInfo () {
      // 预览/详情
      this.$post(`${this.api[this.preview ? 'getRedisCache' : 'findPage']}?columnId=${this.id}`).then(({ data }) => {
        if (data.length) {
          // state：已发布（1）则取theEditedJson，草稿（0）则取jsonBeforeEditing
          const json = JSON.parse(this.preview ?
            data :
            data[data.length - 1][data[data.length - 1].state ? 'theEditedJson' : 'jsonBeforeEditing'])
          this.modules = json
          console.log("🚀 ~ file: index.vue ~ line 180 ~ this.$post ~ json", json)

          // 获取文章列表
          const { column, site, articleNum } = json[7].form
          if (column.length) {
            this.$post(`${this.api.queryArticlesByColumnType}?columnId=${column[column.length - 1]}`).then(({ data }) => {
              this.articles = Util.removeTag(data.slice(0, articleNum || 6))
            }).catch(err => { })
          }
        }
      }).catch(err => { })
    },
  }
};
</script>

<style lang="scss" scoped>
@import url(../../plugins/wow/animate.css);
@import '../../styles/page/page.scss';

.wrap {
  /deep/ .el-carousel {
    height: 21.6rem;

    .el-carousel__container {
      height: 21.6rem;
    }

    img {
      height: 21.6rem;
    }
  }
}

.banner-item {
  .banner-name {
    font-size: 2.16rem;
  }
}

.block {
  padding: 3.15rem 0;

  .inner {
    .b-title {
      font-size: 2.25rem;
      margin-bottom: 2.25rem;
    }

    .intro {
      margin-bottom: 2.25rem;
    }
  }
}

.history {
  h2 {
    font-size: 1.35rem;
    color: #333;
  }

  .texts {
    display: flex;
    justify-content: space-between;
    padding: 2.7rem 2.56rem 2.7rem;
    margin-top: 20px;
    background-color: #fff;
    border-radius: 100px 0px 0px 0px;
    transition: 0.3s;
    position: relative;

    &:hover {
      transform: scale(1.05);
    }

    // .line {
    //   padding: 2.7rem 0;
    // }
    .des {
      margin: 2.7rem 0;
    }
  }

  .left {
    width: 50%;
  }

  .des {
    margin: 20px 0;
    font-size: 1.2rem;
    color: #181818;
    line-height: 31px;
  }

  .bg {
    width: 32.88rem;
    height: auto;
    position: absolute;
    right: -1rem;
    bottom: 2.9rem;
  }
}

.app-inner {
  width: 1558px;
}

.app {
  display: flex;
  flex-wrap: wrap;

  li {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 368px;
    height: 252px;
    margin: 0 14px 14px 0;
    transition: 0.3s;

    &:hover {
      transform: scale(1.05);

      .icon {
        transform: rotateY(180deg);
      }
    }

    &:first-child {
      width: 750px;
    }

    &:nth-child(3),
    &:nth-child(7),
    &:nth-child(10) {
      margin-right: 0;
    }

    &:nth-child(9) {
      width: 563px;
    }

    &:nth-child(10) {
      width: 555px;
    }
  }

  .bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }

  .icon {
    position: relative;
    transition: 0.3s;
  }

  .text {
    position: relative;
    margin-top: 20px;
    font-size: 2rem;
    color: #fff;
  }
}

.group {
  display: flex;
  flex-wrap: wrap;

  li {
    position: relative;
    width: calc((100% - 56px) / 3);
    margin: 0 28px 39px 0;
    transition: 0.3s;

    &:hover {
      transform: scale(1.05);

      .text {
        color: #fff;
        background-color: #394f6d;
      }
    }

    &:nth-child(3n) {
      margin-right: 0;
    }
  }

  img {
    width: 100%;
    height: auto;
  }

  .text {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 6.43rem;
    font-size: 1.44rem;
    font-family: SFProDisplay-Bold, SFProDisplay;
    font-weight: bold;
    line-height: 6.43rem;
    text-align: center;
    color: #272727;
    background-color: #f5f5f5;
    transition: 0.3s;
  }
}

.news-block {
  background: url(../../assets/images/info-bg.png) 0 0/100% 100% no-repeat;
}

.news {
  position: relative;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;

  li {
    display: inline-flex;
    width: calc((100% - 28px) / 2);
    padding: 1.53rem;
    margin-bottom: 1.26rem;
    background-color: #fff;
    cursor: pointer;
    transition: 0.3s;

    &:hover {
      transform: scale(1.05);
    }
  }

  img {
    width: 10.66rem;
    height: auto;
  }

  .texts {
    margin-left: 34px;
  }

  h6 {
    font-size: 1.1rem;
    color: #0648a8;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .des {
    margin: 2px 0;
    font-size: 0.9rem;
    color: #333;
    line-height: 22px;
    -webkit-line-clamp: 2;
  }

  .meta {
    font-size: 0.8rem;
    color: #999;
  }
}

@media (max-width: 1520px) {
  .app-inner {
    width: 1558px;
  }
}

@media (min-width: 280px) and (max-width: 1200px) {
  .wrap {
    /deep/ .el-carousel {
      height: 15rem;

      .el-carousel__container {
        height: 15rem;
      }

      img {
        height: 15rem;
      }
    }
  }

  .banner-item .banner-name {
    font-size: 1.5rem;
    bottom: 2.25rem;
    left: 16.125rem;
  }

  .block {
    padding: 50px 0;

    .inner {
      width: 95%;
      margin: 0 auto;

      .texts {
        flex-direction: column;

        .left {
          width: 100%;
        }

        .bg {
          margin: 0;
          width: 100%;
          height: 20rem !important;
        }
      }
    }

    .app {
      li {
        width: 100%;
      }
    }

    .intro {
      margin-bottom: 30px;
    }

    .group {
      flex-direction: column;

      li {
        width: 100%;

        img {
          height: 20rem;
        }
      }
    }

    .news {
      flex-direction: column;

      li {
        width: 95%;
        margin: 0 auto;
        flex-direction: column;

        img {
          width: 100%;
          height: 12rem;
        }

        .texts {
          margin-left: 0;
          margin-top: 20px;
        }
      }
    }
  }
}

@media (max-width: 1200px) {
  .block {
    padding: 50px 0;

    .inner {
      width: 95%;
      margin: 0 auto;

      .texts {
        flex-direction: column;

        .left {
          width: 100%;
        }

        .bg {
          margin: 0;
          width: 100%;
          height: 450px;
        }
      }
    }

    .app {
      li {
        width: 100%;
      }
    }

    .intro {
      margin-bottom: 30px;
    }

    .group {
      flex-direction: column;

      li {
        width: 100%;
      }
    }

    .news {
      flex-direction: column;

      li {
        width: 95%;
        margin: 0 auto;
        flex-direction: column;

        img {
          width: 100%;
          height: 200px;
        }

        .texts {
          margin-left: 0;
          margin-top: 20px;
        }
      }
    }
  }
}

@media (max-width: 320px) {
  .wrap {
    /deep/ .el-carousel {
      height: 12rem !important;
    }

    /deep/ .el-carousel__container {
      height: 12rem !important;
    }

    /deep/ .el-carousel__item {
      height: 12rem !important;
    }
  }

  .banner-item {
    img {
      height: 12rem !important;
    }

    .banner-name {
      font-size: 1.5rem;
      line-height: 1rem;
      left: 2rem;
      bottom: 2rem;
    }
  }

  .block {
    padding: 1.25rem 0;

    .inner {
      h2 {
        margin-left: 1.5rem !important;
      }

      .b-title {
        font-size: 1.5rem;
      }

      .texts {
        padding: 5rem 1.25rem;

        h2 {
          margin-left: 0 !important;
        }

        .bg {
          height: auto !important;
        }
      }

      .group {
        li {
          img {
            height: auto;
          }
        }
      }

      .news {
        li {
          padding: 1.25rem;

          img {
            height: auto;
          }

          .texts {
            padding: 1.25rem;
          }
        }
      }
    }
  }
}

@media (min-width: 320px) and (max-width: 375px) {
  .wrap {
    /deep/ .el-carousel {
      height: 12rem !important;
    }

    /deep/ .el-carousel__container {
      height: 12rem !important;
    }

    /deep/ .el-carousel__item {
      height: 12rem !important;
    }
  }

  .banner-item {
    img {
      height: 12rem !important;
    }

    .banner-name {
      font-size: 1.5rem;
      line-height: 1rem;
      left: 2rem;
      bottom: 2rem;
    }
  }

  .block {
    padding: 1.25rem 0;

    .inner {
      h2 {
        margin-left: 1.5rem !important;
      }

      .b-title {
        font-size: 1.5rem;
      }

      .texts {
        padding: 5rem 1.25rem;

        h2 {
          margin-left: 0 !important;
        }

        .bg {
          height: auto !important;
        }
      }

      .group {
        li {
          img {
            height: auto;
          }
        }
      }

      .news {
        li {
          padding: 1.25rem;

          img {
            height: auto;
          }

          .texts {
            padding: 1.25rem;
          }
        }
      }
    }
  }
}

@media (min-width: 375px) and (max-width: 480px) {
  .wrap {
    /deep/ .el-carousel {
      height: 12rem !important;
    }

    /deep/ .el-carousel__container {
      height: 12rem !important;
    }

    /deep/ .el-carousel__item {
      height: 12rem !important;
    }
  }

  .banner-item {
    img {
      height: 12rem !important;
    }

    .banner-name {
      font-size: 1.5rem;
      line-height: 1rem;
      left: 2rem;
      bottom: 2rem;
    }
  }

  .block {
    padding: 1.25rem 0;

    .inner {
      h2 {
        margin-left: 1.5rem !important;
      }

      .b-title {
        font-size: 1.5rem;
      }

      .texts {
        padding: 5rem 1.25rem;

        h2 {
          margin-left: 0 !important;
        }

        .bg {
          height: auto !important;
        }
      }

      .group {
        li {
          img {
            height: auto;
          }
        }
      }

      .news {
        li {
          padding: 1.25rem;

          img {
            height: auto;
          }

          .texts {
            padding: 1.25rem;
          }
        }
      }
    }
  }
}

@media (min-width: 480px) and (max-width: 640px) {
  .wrap {
    /deep/ .el-carousel {
      height: 12rem !important;
    }

    /deep/ .el-carousel__container {
      height: 12rem !important;
    }

    /deep/ .el-carousel__item {
      height: 12rem !important;
    }
  }

  .banner-item {
    img {
      height: 12rem !important;
    }

    .banner-name {
      font-size: 1.5rem;
      line-height: 1rem;
      left: 2rem;
      bottom: 2rem;
    }
  }

  .block {
    padding: 1.25rem 0;

    .inner {
      h2 {
        margin-left: 1.5rem !important;
      }

      .b-title {
        font-size: 1.5rem;
      }

      .texts {
        padding: 5rem 1.25rem;

        h2 {
          margin-left: 0 !important;
        }

        .bg {
          height: auto !important;
        }
      }

      .group {
        li {
          img {
            height: auto;
          }
        }
      }

      .news {
        li {
          padding: 1.25rem;

          img {
            height: auto;
          }

          .texts {
            padding: 1.25rem;
          }
        }
      }
    }
  }
}

@media (min-width: 640px) and (max-width: 768px) {
  .wrap {
    /deep/ .el-carousel {
      height: 12rem !important;
    }

    /deep/ .el-carousel__container {
      height: 12rem !important;
    }

    /deep/ .el-carousel__item {
      height: 12rem !important;
    }
  }

  .banner-item {
    img {
      height: 12rem !important;
    }

    .banner-name {
      font-size: 1.5rem;
      line-height: 1rem;
      left: 2rem;
      bottom: 2rem;
    }
  }

  .block {
    padding: 1.25rem 0;

    .inner {
      h2 {
        margin-left: 1.5rem !important;
      }

      .b-title {
        font-size: 1.5rem;
      }

      .texts {
        padding: 5rem 1.25rem;

        h2 {
          margin-left: 0 !important;
        }

        .bg {
          height: auto !important;
        }
      }

      .group {
        li {
          img {
            height: auto;
          }
        }
      }

      .news {
        li {
          padding: 1.25rem;

          img {
            height: auto;
          }

          .texts {
            padding: 1.25rem;
          }
        }
      }
    }
  }
}

@media (min-width: 768px) and (max-width: 980px) {
  .wrap {
    /deep/ .el-carousel {
      height: 12rem !important;
    }

    /deep/ .el-carousel__container {
      height: 12rem !important;
    }

    /deep/ .el-carousel__item {
      height: 12rem !important;
    }
  }

  .banner-item {
    img {
      height: 12rem !important;
    }

    .banner-name {
      font-size: 1.5rem;
      line-height: 1rem;
      left: 2rem;
      bottom: 2rem;
    }
  }

  .block {
    padding: 1.25rem 0;

    .inner {
      h2 {
        margin-left: 1.5rem !important;
      }

      .b-title {
        font-size: 1.5rem;
      }

      .texts {
        flex-direction: row;
        padding: 3rem 1.25rem;

        .left {
          width: 50%;
        }

        h2 {
          margin-left: 0 !important;
        }

        .bg {
          width: 50%;
          margin: -3rem 0 0 0;
          height: auto !important;
        }
      }

      .group {
        flex-direction: row;

        li {
          width: calc((100% - 56px) / 3);

          img {
            height: auto;
          }

          .text {
            line-height: 1.5rem;
          }
        }
      }

      .news {
        flex-direction: row;

        li {
          width: calc((100% - 28px) / 2);
          padding: 1.25rem;

          img {
            height: auto;
          }

          .texts {
            padding: 1.25rem;
          }
        }
      }

      .app {
        flex-direction: row;

        li {
          width: 45%;

          &:nth-child(2n + 1) {
            margin-right: 1rem;
          }
        }
      }
    }
  }
}

@media (min-width: 980px) and (max-width: 1200px) {
  .wrap {
    /deep/ .el-carousel {
      height: 12rem !important;
    }

    /deep/ .el-carousel__container {
      height: 12rem !important;
    }

    /deep/ .el-carousel__item {
      height: 12rem !important;
    }
  }

  .banner-item {
    img {
      height: 12rem !important;
    }

    .banner-name {
      font-size: 1.5rem;
      line-height: 1rem;
      left: 2rem;
      bottom: 2rem;
    }
  }

  .block {
    padding: 1.25rem 0;

    .inner {
      h2 {
        margin-left: 1.5rem !important;
      }

      .b-title {
        font-size: 1.5rem;
      }

      .texts {
        flex-direction: row;
        padding: 3rem 1.25rem;

        .left {
          width: 50%;
        }

        h2 {
          margin-left: 0 !important;
        }

        .bg {
          width: 50%;
          margin: -3rem 0 0 0;
          height: auto !important;
        }
      }

      .group {
        flex-direction: row;

        li {
          width: calc((100% - 56px) / 3);

          img {
            height: auto;
          }

          .text {
            line-height: 1.5rem;
          }
        }
      }

      .news {
        flex-direction: row;

        li {
          width: calc((100% - 28px) / 2);
          padding: 1.25rem;

          img {
            height: auto;
          }

          .texts {
            padding: 1.25rem;
          }
        }
      }

      .app {
        flex-direction: row;

        li {
          width: 45%;

          &:nth-child(2n + 1) {
            margin-right: 1rem;
          }
        }
      }
    }
  }
}
</style>