<template>
  <div id="login">
    <login-detail :info="info" :form="form" :forms="forms" @onsave="onsaveClick"></login-detail>
  </div>
</template>

<script>
import loginDetail from '@/components/login.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
import _ from 'loadsh';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: mapNews } = createNamespacedHelpers('market');

export default {
  name: 'login',
  props: {},
  components: {
    loginDetail,
  },
  data: () => ({
    form: {},
    info: {},
    forms: {},
    sch: {},
  }),

  created() {
    this.searchSite();
  },
  computed: {
    keyWord() {
      let meta = this.$route.meta;
      let main = meta.title || '';
      return main;
    },
  },
  methods: {
    ...mapSite(['showInfo']),
    ...mapNews({ newsList: 'query', newsInfo: 'fetch', corpReg: 'create' }),

    // 查询站点信息
    async searchSite() {
      let res = await this.showInfo();
      let object = JSON.parse(JSON.stringify(res.data));
      if (object) {
        this.$set(this, `info`, res.data);
      } else {
        this.$message.error(res.errmsg ? res.errmsg : 'error');
      }
    },
    async onsaveClick(data) {
      let form = JSON.parse(JSON.stringify(this.form));
      console.log(form);

      // console.log(data.name);
      //连接接口
      let result = await this.corpReg({ data: form });
      this.$message({
        message: `${result.errcode}` === '0' ? '注册成功' : result.errmag,
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
