<template>
  <div class="display-detail">
    <div class="empty-space"></div>
    <div class="content" id="content">
      <div class="content-item sliders">
        <div class="center-box">
          <div class="slide-group" :style="{ width: contentWidth }">
            <div
              class="slide-item"
              v-for="(item, index) in displayDetail.imagesVo"
              :key="index"
            >
              <img :src="$getFullUrl(item.url)" alt="" />
              <div class="modal"></div>
            </div>
          </div>
          <div class="center-img">
            <img src="@/assets/imgs/display/slider-box.png" alt="" />
          </div>
        </div>
      </div>
      <div class="content-item intro">
        <div class="wrapper"></div>
      </div>
      <div class="content-item units">
        <div class="wrapper">
          <div class="custom-title">
            <div class="custom-title-prefix">
              <img src="@/assets/imgs/display/custom-title.png" alt="" />
            </div>
            <div class="custom-title-text">展览单元</div>
            <div class="custom-title-suffix">
              <img src="@/assets/imgs/display/custom-title.png" alt="" />
            </div>
          </div>
        </div>
        <div class="units-content"></div>
      </div>
      <div class="content-item lts">
        <div class="wrapper">
          <div class="custom-title">
            <div class="custom-title-prefix">
              <img src="@/assets/imgs/display/custom-title.png" alt="" />
            </div>
            <div class="custom-title-text">关联文献</div>
            <div class="custom-title-suffix">
              <img src="@/assets/imgs/display/custom-title.png" alt="" />
            </div>
          </div>
        </div>
        <div class="lts-content">
          <div class="lts-list">
            <div class="lts-item"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import SearchBar from "@/components/SearchBar";
import AudioPlayer from "@/components/AudioPlayer";
import CustomTitle from "@/components/CustomTitle";
import ReaderOperations from "@/components/ReaderOperations";
import Card from "@/views/personal/components/Card";
import Video from "@/components/Video";
import QRCode from "qrcodejs2";
import { getDisplayById } from "@/api/display";
import MenuList from "@/components/MenuList";
export default {
  components: {
    SearchBar,
    CustomTitle,
    AudioPlayer,
    ReaderOperations,
    MenuList,
    Video,
    Card,
    "el-image-viewer": () =>
      import("element-ui/packages/image/src/image-viewer"),
  },

  data() {
    return {
      options: [
        {
          value: "name",
          label: "文物名称",
        },
      ],
      selectValue: "",
      keyword: "",
      displayDetail: {},
      slideImageWidth: "",
      imgViewerVisible: false,
      relateRelics: [],
      curUnit: [],
      contentWidth: 0,
    };
  },
  mounted() {
    // this.creatQrCode();
    this.loadDetail();
    this.$nextTick(() => {
      this.loadContentWidth();
    });
  },
  methods: {
    async loadDetail() {
      let exhibitionId = this.$route.params.exhibitionId;
      if (exhibitionId) {
        let res = await getDisplayById({ exhibitionId });
        if (res.code == 0) {
          this.displayDetail = res.data;
          // debugger
          // 处理单元数据
          if (
            this.displayDetail.exhibitionUnits &&
            this.displayDetail.exhibitionUnits.length > 0
          ) {
            this.curUnit = this.displayDetail.exhibitionUnits[0];
          }
          processUnit(this.displayDetail.exhibitionUnits);
          // console.log(unit);
          function processUnit(list) {
            for (let o of list || []) {
              if (o.children) {
                if (o.children.length == 0) {
                  o.children = null;
                } else {
                  processUnit(o.children);
                }
              }
            }
          }
          // 获取关联文物
          // this.loadCrRecommend();
          this.$nextTick(() => {
            // this.$message.info("正在播放当前文物讲解音频，点击按钮可关闭");
            // this.$refs.AudioPlayer.play();
          });
        }
      }
    },

    loadContentWidth() {
      this.contentWidth = document.getElementById("content").clientWidth + "px";
    },
  },
};
</script>

<style lang="scss" scoped>
// 中国风主题样式
/**公共样式开始 */
.wrapper {
  width: 1200px;
}
.custom-title {
  display: flex;
  align-items: center;
  .custom-title-prefix,
  .custom-title-suffix {
    width: 27px;
    height: 27px;
    margin: 15px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .custom-title-text {
    font-size: 40px;
    font-family: KaiTi;
    font-weight: 400;
    color: #0f0f0f;
    line-height: 114px;
  }
}
/**公共样式结束 */

/**样式开始 */
.display-detail {
  overflow-x: hidden;
  .content {
    width: 100%;
    .content-item {
      width: 100%;
    }

    /**轮播图 */
    .sliders {
      height: 434px;
      margin: 52px 0 84px 0;
      // background-color: pink;
      display: flex;
      justify-content: center;
      .center-box {
        width: 1200px;
        height: 100%;
        position: relative;
        display: flex;
        justify-content: center;
        .slide-group {
          display: flex;
          position: relative;
          height: 100%;
          .slide-item {
            width: 300px;
            height: 100%;
            position: relative;
            img {
              width: 300px;
              height: 100%;
              object-fit: cover;
              filter: grayscale(14);
            }
            .modal {
              width: 100%;
              height: 100%;
              position: absolute;
              left: 0;
              top: 0;
              z-index: 10;
              background-color: rgba(#f8f8f8, 0.75);
            }
          }
        }
      }
      .center-img {
        position: absolute;
        left: 0;
        top: -25px;
        z-index: 99;
      }
    }

    /**展览信息 */
    .intro {
      margin-bottom: 96px;
      display: flex;
      justify-content: center;
      .wrapper {
        height: 706px;
        background-image: url("@/assets/imgs/display/intro-bg.png");
      }
    }

    /**展览单元 */
    .units {
      // background-color: blue;
      margin-bottom: 100px;
      display: flex;
      justify-content: center;
    }
    /**关联文献 */
    .lts {
      // background-color: aquamarine;
      display: flex;
      flex-direction: column;
      align-items: center;
      .lts-content {
        //   display: flex;
        //   justify-content: center;
        width: 100%;
        height: 569px;
        background-image: url("@/assets/imgs/display/lts-bg.png");
      }
    }
  }
}
</style>