<template>
  <div class="home-banner">
    <el-carousel arrow="never" class="banner-swiper">
      <el-carousel-item v-for="item in bannerList" :key="item.src"><img :src="item.src"/></el-carousel-item>
    </el-carousel>
    <router-link to="profession">
      <div class="cover">
        <img src="https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/new-marywood/banner_block.png" />
        <div class="cover-inner">
          <h1>玛丽伍德大学</h1>
          <h2>数字领导力方向MBA</h2>
          <p>
            赋能当今社会每位管理人，成就数字时代先锋领导者系统、实用、数字地赋能项目成长和企业转型升级
          </p>
        </div>
      </div>
    </router-link>
    <div class="video-box" v-show="isPlaying">
      <video
        ref="video"
        src="https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/new-marywood/videoplayback.mp4"
        preload="auto"
        playsinline
      ></video>
    </div>
    <div class="button-group">
      <!-- <div class="button-item"><router-link to="profession">了解更多</router-link></div> -->
      <div class="button-item button-play" :class="{ 'is-playing': isPlaying }" @click="togglePlay">学校视频</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'HomeBanner',
  data() {
    return {
      isPlaying: false,

      bannerList: [
        {
          src: 'https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/new-marywood/banner1.png'
        },
        {
          src: 'https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/new-marywood/banner2.png'
        },
        {
          src: 'https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/new-marywood/banner3.png'
        },
        {
          src: 'https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/new-marywood/banner4.png'
        }
      ]
    }
  },
  methods: {
    togglePlay() {
      this.isPlaying = !this.isPlaying
      this.$nextTick(() => {
        this.isPlaying ? this.$refs.video.play() : this.$refs.video.pause()
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.home-banner {
  position: relative;
  height: calc(100vh - 10px);
  min-height: 600px;
}
.banner-swiper {
  height: 100%;
  ::v-deep .el-carousel__container {
    height: 100%;
  }
  img {
    height: 100%;
    width: 100%;
    object-fit: cover;
  }
}
.video-box {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 11;
  background-color: #000;
  video {
    width: 100%;
    height: 100%;
    object-fit: fill;
  }
}
.button-group {
  z-index: 21;
  position: absolute;
  left: 100px;
  bottom: 30%;
  display: flex;
  .button-item {
    width: 132px;
    border: 1px solid;
    border-radius: 5px;
    font-size: 18px;
    font-family: PingFangSC-Regular, PingFang SC;
    color: #fff;
    line-height: 54px;
    text-align: center;
    cursor: pointer;
  }
  .button-item + .button-item {
    margin-left: 20px;
  }
  .button-play {
    width: 138px;
    padding-right: 20px;
    background: #faa634 url('@/assets/images/play.png') no-repeat right 20px center;
    border-color: #faa634;
    &.is-playing {
      background: url('@/assets/images/stop.png') no-repeat right 20px center;
      border-color: #fff;
    }
  }
}
.cover {
  position: absolute;
  top: 0;
  right: 200px;
  width: 434px;
  height: 100%;
  z-index: 10;
  box-sizing: border-box;
  overflow: hidden;
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.25s ease-in-out;
  }
  &:hover {
    .cover-inner {
      background-color: rgba(0, 0, 0, 0.4);
    }
    img {
      transform: scale(1.1);
    }
  }

  .cover-inner {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 11;
    padding: 0 30px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-bottom: 33%;
  }
  h1 {
    font-size: 36px;
    color: #fff;
    font-weight: 500;
    text-align: right;
  }
  h2 {
    margin-top: 16px;
    font-size: 26px;
    color: #faa634;
    font-weight: 400;
    text-align: right;
  }
  p {
    margin-top: 20px;
    font-size: 16px;
    color: #fff;
    line-height: 2;
    text-align: justify;
  }
}
</style>
