<template>
  <div id="clickBtn">
    <el-row>
      <el-col :span="24" class="style">
        <span v-if="user.role == '2' || user.role == '3' || user.role == '6' || user.role == '7'">
          <van-cell is-link title="个人信息" @click="$router.push({ path: '/userCenter/user/index' })" />
          <van-cell is-link title="我的发布" @click="$router.push({ path: '/userCenter/myProduct/index' })" />
          <van-cell is-link title="事项管理" @click="$router.push({ path: '/userCenter/matter/index' })" />
          <van-cell is-link title="展会管理" @click="$router.push({ path: '/userCenter/dock/index' })" />
        </span>
        <span v-else>
          <span v-if="user.role == '1'">
            <van-cell is-link title="用户管理" @click="$router.push({ path: '/adminCenter/user/index' })" />
            <van-cell is-link title="对接会管理" @click="$router.push({ path: '/adminCenter/duijiehui/index' })" />
            <van-cell is-link title="产品供求审核管理" @click="$router.push({ path: '/adminCenter/enterpriseProduct/index' })" />
            <van-cell is-link title="产品供求交易状态审核管理" @click="$router.push({ path: '/adminCenter/transaction/index' })" />
          </span>
          <span v-else>
            <van-cell is-link title="用户管理" v-if="oneName == '用户管理'" @click="$router.push({ path: '/adminCenter/user/index' })" />
            <van-cell is-link title="对接会管理" v-if="twoName == '对接会'" @click="$router.push({ path: '/adminCenter/duijiehui/index' })" />
            <van-cell
              is-link
              title="产品供求审核管理"
              v-if="threeName == '产品供求审核管理'"
              @click="$router.push({ path: '/adminCenter/enterpriseProduct/index' })"
            />
            <van-cell
              is-link
              title="产品供求交易状态审核管理"
              v-if="fourName == '产品供求交易状态审核管理'"
              @click="$router.push({ path: '/adminCenter/transaction/index' })"
            />
          </span>
        </span>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: login } = createNamespacedHelpers('login');
export default {
  name: 'clickBtn',
  props: {},
  components: {},
  data: function() {
    return {
      oneName: '',
      twoName: '',
      threeName: '',
      fourName: '',
    };
  },
  created() {
    this.searchMenu();
  },
  methods: {
    ...login(['toGetMenu']),
    async searchMenu() {
      const res = await this.toGetMenu({ id: this.user.uid });
      for (const val of res.data.menus) {
        if (val.role_name == '用户管理') {
          this.$set(this, `oneName`, val.role_name);
        } else if (val.role_name == '对接会') {
          this.$set(this, `twoName`, val.role_name);
        } else if (val.role_name == '产品供求审核管理') {
          this.$set(this, `threeName`, val.role_name);
        } else if (val.role_name == '产品供求交易状态审核管理') {
          this.$set(this, `fourName`, val.role_name);
        }
      }
    },
  },
  computed: {
    ...mapState(['user']),
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

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