zhangzengfei
2022-12-07 0dbf19e9f92f5cb1d5ca9a06fd268d3b16e466e3
src/views/personalCenter/components/LeftMenu.vue
@@ -1,17 +1,17 @@
<template>
  <div class="left-menu">
    <div class="user-img">
      <img src="/images/hashrate/独立场景空页面.png" alt="" />
      <img src="/images/hashrate/s_empty.png" alt="" />
    </div>
    <div class="user-name">{{ userInfo.username }}</div>
    <div class="menu-list">
      <div
        class="item"
        @click="pickMenu(index)"
        v-for="(item, index) in menuList"
        :key="index"
        :class="index == activeIndex ? 'active-item' : ''"
        @click="pickMenu(index, item.tab)"
      >
        <span class="iconfont">&#xe614;</span>
        <span class="item-name"> {{ item.name }}</span>
@@ -23,28 +23,42 @@
<script>
export default {
  created() {
    this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
    this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
    if (this.$route.query && this.$route.query.id) {
      this.activeIndex = this.$route.query.id
    }
  },
  computed:{
    menuList() {
      let menu =
      [
        // { name: "账户总览" },
        // { name: "订单管理" },
        // { name: "消息中心" },
        { name: "基本资料", tab: "baseInfo" },
      ]
      let userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
      if (userInfo.username == "Administrator") {
        menu.push({ name: "子账户管理", tab: "subAccount" })
      }
      return menu
    }
  },
  data() {
    return {
      menuList: [
        { name: "账户总览" },
        { name: "订单管理" },
        { name: "消息中心" },
        { name: "基本资料" },
        { name: "子账户管理" },
      ],
    return {
      userInfo: null,
      activeIndex: 0,
    };
      activeIndex: 0
    }
  },
  methods: {
    pickMenu(i) {
      this.activeIndex = i;
      this.$emit("mChange", i);
    },
  },
};
    pickMenu(idx, tab) {
      this.activeIndex = idx
      this.$emit("mChange", tab)
    }
  }
}
</script>
<style scoped lang="scss">
@@ -91,4 +105,4 @@
    }
  }
}
</style>
</style>