<template>
  <div class="units-content">
    <p>{{ units.title }}</p>
    <div class="units-content-intro" v-html="units.intro">
    </div>
    <ul v-if="units.children && units.children.length > 0">
      <li
        v-for="(item, index) in units.children"
        :key="index"
        :class="{ active: activeUnit === item.euId }"
        :style="`--i: ${1 / units.children.length}`"
        @click="showUnit(item.euId)"
      >
        <!-- <div class="unit-title">{{ item.title }}</div>

                <div class="unit-intro">{{ item.intro }}</div>
                <div
                  class="unit-imgs"
                  v-if="item.imagesVo && item.imagesVo.length > 0"
                >
                  <div
                    class="img-item"
                    v-for="(i, idx) in item.imagesVo"
                    :key="idx"
                  >
                    <img :src="$getFullUrl(i.url)" alt="" />
                  </div>
                </div> -->
        <div class="unit-node">
          <div class="unit-imgs">
            <div
              class="img-item"
              v-if="item.imagesVo && item.imagesVo.length > 0"
            >
              <img
                :src="
                  $getFullUrl(item.imagesVo[0].pressUrl || item.imagesVo[0].url)
                "
                alt=""
              />
            </div>
          </div>
          <div class="unit-content">
            <div class="unit-title">{{ item.title }}</div>

            <div class="unit-intro" v-html="item.intro"></div>
          </div>
        </div>
        <div class="units-title">
          <p>
            <!-- <span v-html="changeTitle(item.title)"></span> -->
            <span v-html="item.title" style="writing-mode: vertical-rl;"></span>
          </p>
          <span></span>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: {
    units: {
      type: Object,
    },
  },
  data() {
    return {
      activeUnit: "",
    };
  },
  methods: {
    changeTitle(str) {
      return str.split("").join("<br>");
    },
    showUnit(id) {
      if (id === this.activeUnit) {
        this.activeUnit = " ";
      } else {
        this.activeUnit = id;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.units-content {
  margin: 100px 0;
  > p {
    font-size: 32px;
    font-weight: 600;
    text-align: center;
    font-family: "KaiTi";
    margin-bottom: 60px;
  }
  .units-content-intro{
    font-size: 16px;
    color: #333;
    text-indent: 32px;
    line-height: 2.5;
  }
  ul {
    display: flex;
    flex-wrap: nowrap;
    overflow: auto;
    border: 3px solid rgb(139 123 90);
    box-shadow: 9px 20px 10px rgb(0 0 0 / 30%);
    height: 660px;
    
    li {
      // margin-bottom: 20px;
      width: calc(var(--i) * 100%);
      transition: 0.6s;
      overflow: hidden;
      // flex-shrink: 0;
      position: relative;
      height: 100%;
      &.active {
        width: 100%;
        flex-shrink: 0;

        > .unit-node {
          width: 100%;
          filter: none;
          /* > .unit-imgs {
                  width: 100%;
                  .img-item {
                    width: 100%;
                    height: auto;
                    img {
                      width: 100%;
                      height: auto;
                    }
                  }
                } */
        }
        > .units-title {
          opacity: 0;
        }
      }
      &:hover {
        cursor: pointer;
      }
      .unit-title {
        font-size: 36px;
        font-family: KaiTi;
        font-weight: 400;
        // color: #4e392c;
        color: #bb4343;
        line-height: 83px;
        display: flex;
        justify-content: center;
        width: 76%;
        line-height: 1.2;
      }
      .unit-intro {
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #333;
        // color: #e2e2e2;
        text-indent: 36px;
        // margin-bottom: 10px;
        // margin-top: 20px;
        line-height: 1.8;
      }
      .unit-imgs {
        // width: 100%;
        width: 50%;
        // width: 500px;
        height: 100%;
        flex-shrink: 0;
        overflow: hidden;
        .img-item {
          width: 100%;
          display: flex;
          justify-content: center;
          align-items: center;
          height: 100%;
          img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: 0.6s;
          }
        }
      }
      .unit-node {
        width: 1200px;
        // width: calc(100vw - 26%);
        // width: 100%;
        height: 100%;
        display: flex;
        overflow: hidden;
        transition: 0.6s;
        filter: sepia(0.6);
        position: relative;

        > .unit-content {
          padding: 10px 30px;
          flex: 1;
          flex-shrink: 0;
          // background-color: #fff;
          position: absolute;
          top: 0;
          right: 0;
          width: 50%;
          height: 100%;

          // background-image: linear-gradient(
          //   to right,
          //   rgba(0, 0, 0, 0) 0%,
          //   rgba(0, 0, 0, 0.7) 40%
          // );
          background-image: linear-gradient(
            to right,
            rgba(171, 147, 94, 0.3) 0%,
            rgba(171, 147, 94, 0.7) 40%
          );
          > .unit-title {
            position: absolute;
            top: 100px;
            left: 50%;
            transform: translateX(-50%);
          }
          > .unit-intro {
            position: absolute;
            top: 200px;
            height: 70%;
            padding: 0 80px;
          }
        }
      }
      .units-title {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transition: 0.6s;
        > p {
          // color: #6e4e06;
          color: #000;
          position: absolute;
          left: 0;
          top: 0;
          margin: 0;
          font-size: 28px;
          font-family: "楷体";
          padding: 46px 16px;
          height: calc(100% - 32px);
          // box-shadow: 40px 0px 40px 0 #9b7e3f inset;
          box-shadow: #9b7e3f 44px 24px 57px 10px inset;;
          // background-color: rgba(155, 126, 63, 0.8);
          background-color: #fff;
          display: flex;
          justify-content: center;
          align-items: center;
        }
      }
    }
  }
}
</style>
