<template>
<div class="bg-bottom">
    <div class="bg-top">
  <div class="content-1180">
    <div class="d-flex pt-4">
      <LeftNav :code="code" :list="list" class="mr-4" @chanegCode="chanegCode" />
      <div class="flex-1 flex-column">
        <Location />
        <div class="content-detail p-4" :style="{ 'min-height': list.children.length * 56 + 'px' }">
          <RichText :rich-obj="content" />
        </div>
      </div>
    </div>
  </div>
  </div>
  </div>
</template>
<script>
import { mapActions } from 'vuex';
import LeftNav from '@/components/LeftNav/LeftNav.vue';
import RichText from '@/components/RichText/RichText.vue';
import Location from '@/components/Location/Location.vue';

export default {
  components: { LeftNav, RichText, Location },
  data() {
    return {
      code: '0601',
      list: {
        title: '信息公开',
        url: '/information',
        children: [
          {
            title: '基本信息',
            code: '0601',
          },
          {
            title: '经营管理',
            code: '0602',
          },
          {
            title: '公司公告',
            code: '0603',
          },
          {
            title: '社会责任',
            code: '0604',
          },
          {
            title: '关于信息公开',
            code: '0605',
          },
        ],
      },
      content: {},
    };
  },
  watch: {
    '$route.query.code'(val) {
      if (this.$route.path === this.list.url) {
        this.code = val;
        this.getData(this.code);
      }
    },
  },
  created() {
    this.code = this.$route.query.code;
    this.getData(this.code);
  },
  methods: {
    ...mapActions('home', ['getDetail']),
    async getData(showPage) {
      try {
        const param = {
          showPage,
          introId: '',
        };
        const data = await this.getDetail(param);
        this.content = data;
      } catch (error) {}
    },
    chanegCode(code) {
      this.code = code;
    },
  },
};
</script>
<style scoped>
.content-detail {
  background: #fff;
}
</style>
