<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="main animate__animated animate__zoomInDown">
        <el-col :span="24" class="one">
          <span>{{ $route.meta.title }}</span>
        </el-col>
        <el-col :span="24" class="two">
          <info-1 :info="info"></info-1>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: banner } = createNamespacedHelpers('banner');
const { mapActions: news } = createNamespacedHelpers('news');
const { mapActions: cases } = createNamespacedHelpers('cases');

export default {
  name: 'index',
  props: {},
  components: {
    info1: () => import('@c/common/info-1.vue'),
  },
  data: function () {
    return {
      info: {},
    };
  },
  created() {
    this.search();
  },
  methods: {
    ...banner({ bFetch: 'fetch' }),
    ...news({ nFetch: 'fetch' }),
    ...cases({ cFetch: 'fetch' }),
    async search() {
      let res;
      if (this.type == 'banner') res = await this.bFetch(this.id);
      else if (this.type == 'news') res = await this.nFetch(this.id);
      else if (this.type == 'cases') res = await this.cFetch(this.id);
      if (this.$checkRes(res)) {
        this.$set(this, `info`, res.data);
      }
    },
  },
  computed: {
    ...mapState(['user']),
    id() {
      return this.$route.query.id;
    },
    type() {
      return this.$route.query.type;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .one {
    border-bottom: 1px solid #f1f1f1;
    margin: 0 0 20px 0;
    span {
      display: inline-block;
      padding: 8px 10px;
      border-bottom: 1px solid #ffc001;
      color: #ffc001;
      font-size: 20px;
      font-family: monospace;
      font-weight: bold;
    }
  }
}
</style>
