【制作侧部导航栏,并添加消息提示】

在这里插入图片描述

整体:

提示:这里简述项目相关背景:

<template>
  <el-aside width="auto" :class="isCollapse?'menu-collapsed':'menu-expanded'">
  顶部头像/图片
  导航栏
  </el-aside>
</template>

顶部图片/头像:

提示:放置两个大小不同的图片,展开侧部导航栏时切换成大图片展示,否则显示小的,绑定changeCollapse点击事件
在这里插入图片描述

<div class="manager_name">
  <img v-if="!isCollapse" src="@/assets/images/130x52.png" class="home_img" @click="changeCollapse"/>
  <img v-else src="@/assets/images/52x52.png" style="width: 36px; height: 36px" class="home_img" @click="changeCollapse"/>
</div>
return中定义  isCollapse: false,
...
changeCollapse() {
      this.isCollapse = !this.isCollapse;
    },

导航栏部分:

在这里插入图片描述
提示:
在这里插入图片描述

<!--导航菜单-->
    <el-menu background-color="#304156"
             text-color="rgb(230, 230, 230)"
             active-text-color="rgb(64, 158, 255)"
             :default-active="activeIndex" unique-opened @select="handleSelect" router 	:collapse="isCollapse">
      <template v-for="item of $router.options.routes" v-if="!item.meta.hidden && (item.meta.accessType&userType)>0">
        <el-submenu :index="item.name" v-if="item.children">
          <template slot="title">
            <i :class="item.iconCls"/>
            {{ item.name }}
             </template>
          <el-menu-item v-for="child of item.children" :index="child.path" :key="child.path" :route="child"
                        v-if="!child.meta.hidden && (child.meta.accessType&userType)>0">
            {{ child.name }}
            </el-menu-item>
        </el-submenu>

添加提示功能

在return中定义变量等

return{
 isCollapse: false,
      activeIndex: '',
      userType: 0,
      lastReqTime: new Date(),
      msgCount: {}
      }

提示:
1.给下拉框(一级)右上角添加红色消息提示(统计管理、设备管理、个人中心)
2.没有消息时不显示红点is-dot
msgCount:消息数量
abnormalOrderCount:“异常订单”字段
item:[统计管理、设备管理、商品管理、账户管理、扶贫服务、消息管理、个人中心]
v-if=“msgCount.abnormalOrderCount>0&&item.name==‘统计管理’”:如果异常订单数大于0,且一级下拉列表为统计管理,则显示消息提示红点
在这里插入图片描述
在这里插入图片描述

<el-badge is-dot class="badge_first" v-if="msgCount.abnormalOrderCount>0&&item.name=='统计管理'"></el-badge>
<el-badge is-dot class="badge_first" v-if="(msgCount.faultDeviceCount>0||msgCount.offlineDeviceCount>0)&&item.name=='设备管理'"></el-badge>
<el-badge is-dot class="badge_first" v-if="msgCount.withdrawAccountApplyCount>0&&item.name=='个人中心'"></el-badge>

1.给二级添加带数字加的红色消息提示(统计管理【订单统计】、设备管理【设备列表、设备故障】、个人中心【商户资金】)
在这里插入图片描述
在这里插入图片描述

<el-badge class="badge_second" :value="msgCount.abnormalOrderCount" :max="99"
                      v-if="msgCount.abnormalOrderCount>0&&child.name=='订单统计'">
            </el-badge>
            <el-badge class="badge_second" :value="msgCount.faultDeviceCount" :max="99"
                      v-if="msgCount.faultDeviceCount>0&&child.name=='设备故障'">
            </el-badge>
            <el-badge class="badge_second" :value="msgCount.offlineDeviceCount" :max="99"
                      v-if="msgCount.offlineDeviceCount>0&&child.name=='设备列表'">
            </el-badge>
            <el-badge class="badge_second" :value="msgCount.withdrawAccountApplyCount" :max="99"
                      v-if="msgCount.withdrawAccountApplyCount>0&&child.name=='商户资金'">
            </el-badge>
methods{
 handleSelect: function (index) {
      this.activeIndex = index;
    },
    changeCollapse() {
      this.isCollapse = !this.isCollapse;
    },
     getNewMsgOnce() {
      this.lastReqTime = new Date();
      const that = this;
      this.get('franchiseeMessages/statistics').then((res) => {
        console.log(res)
        if (res.errorCode == 0) {
          that.msgCount = res.data;
        } else {
          that.$message.error(res.message);
        }
      });
    },
    getNewMsg() {
      const seconds = ((new Date()) - this.lastReqTime) / 1000;
      if (seconds < 120) {
        return false;
      }
      this.getNewMsgOnce();
    },
mounted() {
    this.getNewMsgOnce();
    EventBus.$on('getNewMsg', () => {
      this.getNewMsgOnce();
    });
 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

礼礼。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值