<template>
  <div id="adviserList">
    <enterprisejb-detail
      :info="info"
      :form="form"
      @onSubmit="onSubmit"
      :liebiaoList="liebiaoList"
      @onsave="onsaveClick"
      :userinfo="userinfo"
    ></enterprisejb-detail>
  </div>
</template>

<script>
import enterprisejbDetail from '@/components/enterprise/enterprisejb.vue';
import { createNamespacedHelpers, mapGetters, mapState } from 'vuex';
const { mapActions: login } = createNamespacedHelpers('login');
const { mapActions: market } = createNamespacedHelpers('market');
export default {
  name: 'adviserList',
  props: {},
  components: {
    enterprisejbDetail,
  },
  data: () => ({
    form: {},
    info: {},
    liebiaoList: [
      { name: '基本信息' },
      { name: '消息管理' },
      { name: '我的发布' },
      { name: '事项管理' },
      { name: '展会管理' },
      // { name: '返回首页' },
      { name: '修改密码' },
      { name: '注销账号' },
    ],
    userinfo: {},
  }),
  created() {
    this.searchInfo();
  },
  computed: {
    ...mapState(['user']),
  },
  methods: {
    ...market(['fetch', 'update']),
    ...login({ logout: 'logout', transactiondtetle: 'delete' }),
    // 查询基本信息
    async searchInfo() {
      let res = await this.fetch(this.user.userid);
      if (res.errcode === 0) {
        this.$set(this, `form`, res.data);
      }
    },
    async onSubmit({ data }) {
      console.log(data);
      let res;
      let msg;
      res = await this.update(data);
    },
    async onsaveClick({ id }) {
      console.log(id);
      if (id === '基本信息') {
        this.$router.push({ path: '/enterprise/enterprisejb' });
      } else if (id === '消息管理') {
        this.$router.push({ path: '/enterprise/enterprisexx' });
      } else if (id === '我的发布') {
        this.$router.push({ path: '/enterprise/enterprisefabu' });
      } else if (id === '事项管理') {
        this.$router.push({ path: '/enterprise/enterprisedg' });
      } else if (id === '展会管理') {
        this.$router.push({ path: '/enterprise/appointment' });
      } else if (id === '修改密码') {
        this.$router.push({ path: '/enterprise/xiugai' });
      } else if (id === '返回首页') {
        this.$router.push({ path: '/' });
      } else if (id === '注销账号') {
        this.logout();
        this.$message({
          message: '注销成功',
          type: 'success',
        });
        this.toLogin();
      }
    },
    async toLogin() {
      this.$router.push({ path: '/platlive' });
    },
  },
};
</script>

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