admin.vue 2.32 KB
<template>
  <div class="admin-conatiner">
    <Header title="管理员信息" />
    <ul>
      <li v-for="(item, index) in list" :key="index" @click="goDetail(item)">
        <span>{{ item.userName }}</span>
        <img
          v-if="item.id === currentUserId"
          src="@/assets/images/applets/edit.png"
          alt
        />
        <img
          v-if="item.id !== currentUserId"
          src="@/assets/images/applets/detail.png"
          alt
        />
      </li>
    </ul>
    <my-tabbar active="2"></my-tabbar>
  </div>
</template>

<script>
import Header from "@/components/Header/index.vue";
export default {
  components: { Header },
  data() {
    return {
      list: [],
      currentUserId: JSON.parse(localStorage.getItem("userInfo")).id,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    // 获取管理员列表
    getList() {
      let vm = this;
      let param = {
        _index: 1,
        _size: 10,
        type: JSON.parse(localStorage.getItem("userInfo")).type,
      };
      vm.$https(
        {
          url: "tUser/getPageList",
          method: "get",
          authType: this.backToken,
        },
        param
      )
        .then((res) => {
          if (res.data.resultCode === "200") {
            let data = res.data.data;
            vm.list = data.records;
          } else {
            this.$toast(res.data.message);
          }
        })
        .catch(function (err) {
          console.log(err);
        });
    },
    goDetail(item) {
      if (item.id === this.currentUserId) {
        // 修改页面
        this.$router.push({
          path: "/adminInfo",
          query: { id: item.id, disabled: false },
        });
      } else {
        // 详情页面
        this.$router.push({
          path: "/adminInfo",
          query: { id: item.id, disabled: true },
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.admin-conatiner {
  width: 100%;
  height: 100vh;
  padding: 50px 24px 60px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  ul {
    list-style: none;
  }
  li {
    display: flex;
    justify-content: space-between;
    background: #f8f8f8;
    border-radius: 33px;
    font-size: 16px;
    padding: 12px;
    color: #333333;
    margin-top: 20px;
    img {
      width: 24px;
      height: 24px;
    }
  }
}
</style>