<!--  -->
<template>
  <div class="survey-type">
    <div class="wrapper">
      <div class="top">
        <img
          class="bg"
          :src="require('@/assets/images/survey-type-top-bg.png')"
          alt=""
        />
      </div>
      <div class="bottom">
        <img
          class="bg"
          :src="require('@/assets/images/survey-type-bottom-bg.png')"
          alt=""
        />

        <div class="content">
          <div class="nav">
            <img
              class="bg"
              :src="require('@/assets/images/survey-type-nav-bg.png')"
              alt=""
            />
            <div class="nav-con">
              <div class="nav-con-title">概况</div>
              <div class="nav-con-type">
                <ul>
                  <li
                    :class="{ cur: surveyType === 'introduction' }"
                    @click="switchType('introduction')"
                  >
                    <a>本馆介绍</a>
                    <div class="arrow" v-if="surveyType === 'introduction'">
                      <img :src="require('@/assets/images/arrow.png')" alt="" />
                    </div>
                  </li>
                  <li
                    :class="{ cur: surveyType === 'history' }"
                    @click="switchType('history')"
                  >
                    <a>历史沿革</a>
                    <div class="arrow" v-if="surveyType === 'history'">
                      <img :src="require('@/assets/images/arrow.png')" alt="" />
                    </div>
                  </li>
                  <li
                    :class="{ cur: surveyType === 'mechanism' }"
                    @click="switchType('mechanism')"
                  >
                    <a>机构职能</a>
                    <div class="arrow" v-if="surveyType === 'mechanism'">
                      <img :src="require('@/assets/images/arrow.png')" alt="" />
                    </div>
                  </li>
                </ul>
              </div>
            </div>
          </div>
          <div class="con">
            <!-- <div class="back" @click="back" ><img :src="require('@/assets/images/back.png')" alt=""></div> -->
            <img
              class="bg"
              :src="require('@/assets/images/survey-type-con-bg.png')"
              alt=""
            />
            <div class="title">
              <span></span
              >{{
                item.type === "introduce"
                  ? "本馆介绍"
                  : item.type === "history"
                  ? "历史沿革"
                  : item.type === "organ"
                  ? "机构职能"
                  : ""
              }}
            </div>
            <!-- <div class="pic">
              <img v-if="!!item.imgUrl" :src="require(`@/assets/images/${item.imgUrl}`)" alt="" />
            </div> -->
            <div class="des" v-html="item.content"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';

export default {
  name: 'survey',
  // import引入的组件需要注入到对象中才能使用
  components: {},
  data () {
    // 这里存放数据
    return {
      surveyType: 'introduction',
      list: [],
      item: {},
      switchTypeObj: {
        introduction: 'introduce',
        history: 'history',
        mechanism: 'organ'
      }
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    switchType (type) {
      this.surveyType = type
      this.item = this.list.filter((e) => {
        return e.type === this.switchTypeObj[this.surveyType]
      })[0]
    },
    back () {
      this.$router.push({ path: '/survey' })
    },
    async getDetail () {
      let result = await this.$http({
        method: 'post',
        url: '/api/web/profile/list'
      })
      this.list = (result && result['code'] === 0 && result['data']) || []
      this.item = this.list.filter((e) => {
        return e.type === this.switchTypeObj[this.surveyType]
      })[0]
    }
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created () {
    this.surveyType =
      (this.$route.query && this.$route.query['type']) || 'introduction'
    this.getDetail()
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted () {},
  beforeCreate () {}, // 生命周期 - 创建之前
  beforeMount () {}, // 生命周期 - 挂载之前
  beforeUpdate () {}, // 生命周期 - 更新之前
  updated () {}, // 生命周期 - 更新之后
  beforeDestroy () {}, // 生命周期 - 销毁之前
  destroyed () {}, // 生命周期 - 销毁完成
  activated () {} // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style lang='less' scoped>
.bg {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
}
.survey-type {
  width: 100%;
  margin-bottom: 98px;
  .wrapper {
    width: 100%;
    .top {
      width: 100%;
      height: 278px;
      position: relative;
    }
    .bottom {
      width: 100%;
      position: relative;
      .content {
        min-width: 1090px;
        margin: 0 auto;
        width: 57%;
        display: flex;
        justify-content: center;
        .nav {
          flex: 1;
          margin-right: 1%;
          margin-top: -68px;
          position: relative;
          .nav-con {
            width: 85%;
            margin: 94px auto 0;
            .nav-con-title {
              background: #945335;
              padding: 14.5px 0 14.5px 46px;
              font-size: 20px;
              font-family: Microsoft YaHei;
              font-weight: bold;
              line-height: 26px;
              color: #ffffff;
              opacity: 1;
            }
            .nav-con-type {
              margin-top: 3px;
              background: rgba(148, 83, 53, .6);
              overflow: hidden;
              > ul {
                width: 100%;
                margin-top: 21px;
                margin-bottom: 105px;
                > li {
                  width: 100%;
                  padding: 8px 0 8px 51px;
                  font-size: 16px;
                  font-family: Microsoft YaHei;
                  font-weight: 400;
                  color: #000000;
                  position: relative;
                  cursor: pointer;
                  .arrow {
                    position: absolute;
                    top: 10px;
                    right: 11.5px;
                    width: 10.5px;
                    height: 18px;
                    > img {
                      width: 100%;
                      height: 100%;
                    }
                  }
                }
                .cur {
                  background: linear-gradient(180deg, #585a5a 0%, #949198 100%);
                  color: #ffffff;
                }
              }
            }
          }
        }
        .con {
          flex: 3;
          margin-top: -68px;
          position: relative;
          .back {
            width: 19px;
            position: absolute;
            left: 26px;
            top: 97px;
            cursor: pointer;
            > img {
              width: 100%;
            }
          }
          .title,
          .pic,
          .des {
            width: 83%;
            margin: 0 auto;
            text-align: center;
          }
          .title {
            margin-top: 94px;
            margin-bottom: 23px;
            font-size: 18px;
            font-family: Arial;
            font-weight: bold;
            line-height: 24px;
            color: #202020;
            padding: 14.5px 0;
            border-bottom: 1px solid rgba(112, 112, 112, 1);
          }
          .pic {
            > img {
              width: 100%;
            }
          }
          .des {
            margin-top: 60px;
            margin-bottom: 72px;
            font-size: 16px;
            font-family: Microsoft YaHei;
            font-weight: 300;
            line-height: 30px;
            color: #000000;
            opacity: 1;
            text-align: left;
            /deep/img {
              width: 682px;
              // height: 453px;
            }
          }
          .title {
            text-align: left;
            > span {
              display: inline-block;
              width: 8px;
              height: 20px;
              background: #945335;
              vertical-align: middle;
              margin-right: 10px;
            }
          }
        }
      }
    }
  }
}
</style>
