<template>
  <div id="adviserList">
    <enterprisedg-detail
      :info="info"
      :liebiaoList="liebiaoList"
      :dinggou1="dinggou1"
      :dinggou2="dinggou2"
      :dinggou3="dinggou3"
      @onsave="onsaveClick"
      :total1="total1"
      :total2="total2"
      :total3="total3"
      @handleCurrentChange="change1"
      @handleCurrentChange1="change2"
      @handleCurrentChange2="change3"
      @deletes="deleteData"
    ></enterprisedg-detail>
  </div>
</template>

<script>
import enterprisedgDetail from '@/components/enterprise/enterpisedg.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: transaction } = createNamespacedHelpers('transaction');
export default {
  name: 'adviserList',
  props: {},
  components: {
    enterprisedgDetail,
  },
  data: () => ({
    info: {},
    liebiaoList: [{ name: '基本信息' }, { name: '消息管理' }, { name: '我的发布' }, { name: '我的订购' }, { name: '注销账号' }],
    total1: 1,
    total2: 1,
    total3: 1,
    dinggou1: [],
    dinggou2: [],
    dinggou3: [],
  }),
  created() {
    this.searchSite();

    this.jiaoyi1();
    this.jiaoyi2();
    this.jiaoyi3();
  },
  computed: {},
  methods: {
    ...mapSite(['showInfo']),
    ...transaction({ transactionList: 'query', transactiondtetle: 'delete' }),
    // 查询站点信息
    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 jiaoyi1({ skip = 0, limit = 3, ...info } = {}) {
      let status = 1;
      skip = this.skip;
      console.log();
      const res = await this.transactionList({ skip, limit, status, ...info });
      console.log(res);
      if (this.$checkRes(res)) {
        this.$set(this, `dinggou1`, res.data);
        this.$set(this, `total1`, res.total);
      }
    },

    async jiaoyi2({ skip = 0, limit = 3, ...info } = {}) {
      let status = 2;
      skip = this.skip;
      console.log();
      const res = await this.transactionList({ skip, limit, status, ...info });
      console.log(res);
      if (this.$checkRes(res)) {
        this.$set(this, `dinggou2`, res.data);
        this.$set(this, `total2`, res.total);
      }
    },

    async jiaoyi3({ skip = 0, limit = 3, ...info } = {}) {
      let status = 3;
      skip = this.skip;
      console.log();
      const res = await this.transactionList({ skip, limit, status, ...info });
      console.log(res);
      if (this.$checkRes(res)) {
        this.$set(this, `dinggou3`, res.data);
        this.$set(this, `total3`, res.total);
      }
    },

    async change1({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.jiaoyi1();
    },
    async change2({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.jiaoyi2();
    },
    async change3({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      this.jiaoyi3();
    },

    async deleteData({ item }) {
      const res = await this.transactiondtetle(item.id);
      this.$checkRes(res, '删除成功', '删除失败');
    },

    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' });
      }
    },
  },
};
</script>

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