<template>
  <div class="wrap">
    <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 gray">
      <div class="inner">
        <h2 class="b-title wow fadeInUp">{{ modules[1].form.title }}</h2>
        <p class="intro wow fadeInUp" data-wow-delay="0.8s">{{ modules[1].form.des }}</p>
        <img class="block-pic br wow fadeInLeft" data-wow-delay="0.8s" :class="{'cursor-pointer': isLink(modules[1].form.link.linkName)}" width="100%" height="536" :src="modules[1].form.pic" alt="" @click="openLink(modules[1].form)">
      </div>
    </div>
    
    <div class="block">
      <div class="inner">
        <h2 class="b-title wow fadeInUp">{{ modules[2].form.title }}</h2>
        <p class="intro wow fadeInUp" data-wow-delay="0.8s">{{ modules[2].form.des }}</p>
        <img class="block-pic wow fadeInRight" data-wow-delay="0.8s" :class="{'cursor-pointer': isLink(modules[2].form.link.linkName)}" width="100%" height="536" :src="modules[2].form.pic" alt="" @click="openLink(modules[2].form)">
      </div>
    </div>
    
    <div class="block gray">
      <div class="inner">
        <h2 class="b-title wow fadeInUp">{{ modules[3].form.title }}</h2>
        <p class="intro wow fadeInUp" data-wow-delay="0.5s">{{ modules[3].form.des }}</p>
        <ul class="list">
          <template v-for="(item, i) in modules[4].list">
            <li v-if="item.isEnable" :key="i" class="wow fadeInUp" data-wow-delay="0.5s">
              <img class="pic" :src="item.pic" alt="" :class="{'cursor-pointer': isLink(item.link.linkName)}" @click="openLink(item)">
              <div class="texts">
                <h6>{{ item.title }}</h6>
                <p class="sub">{{ item.subTitle }}</p>
                <div class="des">{{ item.des }}</div>
              </div>
            </li>
          </template>
        </ul>
      </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 {
      
    }
  },
  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)
        }
      }).catch(err => {})
    },
  }
};
</script>

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

.wrap{
  /deep/ .el-carousel {
    height: 30rem;
    .el-carousel__container{
      height: 30rem;
    }
    img{
      height: 30rem;
    }
  }
}
.block-pic {
  transition: .3s;
  &.br {
    border-radius: 270px;
  }
  &:hover {
    transform: scale(1.05);
  }
}
.list {
  li {
    position: relative;
    &:nth-child(even) {
      text-align: right;
      .texts {
        left: 0;
        text-align: left;
      }
    }
  }
  .pic {
    width: 662px;
    height: 753px;
  }
  .texts {
    position: absolute;
    top: 120px;
    left: 44%;
    width: 60%;
    height: 455px;
    padding: 60px 30px 30px 100px;
    background-color: #fff;
    overflow: hidden;
    transition: .3s;
    &:hover {
      transform: scale(1.05);
    }
  }
  h6 {
    font-size: 2.4rem;
    color: #3C3C3C;
  }
  .sub {
    font-size: 1.2rem;
    color: #1C1C1C;
    line-height: 33px;
  }
  .des {
    font-size: 1rem;
    color: #3C3C3C;
    line-height: 32px;
  }
}
@media (max-width: 1520px) {
  .list {
    .pic {
      width: 45%;
    }
    li:nth-child(odd) {
      .texts {
        width: 50%;
      }
    }
  }
}
@media (min-width: 280px) and (max-width: 750px) {
  .wrap{
  /deep/ .el-carousel {
    height: 18rem;
    .el-carousel__container{
      height: 18rem;
    }
    img{
      height: 18rem;
    }
  }
}
.banner-item .banner-name {
  font-size: 1.5rem;
  bottom: 5.25rem;
  left: 14.125rem;
  line-height: 2rem
}
 .block{ 
  padding: 50px 0;
  .inner {
    width: 95%;margin: 0 auto;
    .b-title{
      margin-bottom: 30px;
    }
    .intro {
      margin-bottom: 30px;
    }
    .block-pic{
      height: 15rem;
    }
  }
  .list{
    li {
      margin-top: 20px;
      .pic{
        width: 100%;height: 25rem;
      }
      .texts{
        padding: 10px;
        width: 70%;
        top: 2rem;
        height: auto;
        left: 24%;
      }
    }
  }
 }
}
</style>