quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<template>
  <!--
          作者:luoyiming
          时间:2019-10-24
          描述:后台系统头部
      -->
  <div class="common-header">
    <div class="breadcrumb">
      <!--一般的标题显示-->
      <div class="baseInfo-left-base d-s-c">
        <span class="name">{{ menu_title }}</span>
        <!--插件切换-->
        <div class="el-tabs-container">
          <el-tabs v-model="activeValue" @tab-click="tabClick">
            <el-tab-pane :label="item.value" :name="item.key" v-for="(item, index) in tabList" :key="index"></el-tab-pane>
          </el-tabs>
        </div>
      </div>
 
      <div class="header-navbar">
        <div class="header-navbar-icon">
          <span class="gray">当前版本:{{baseInfo.version}}</span>
        </div>
        <div class="header-navbar-icon">
          <span class="ml4 icon iconfont icon-geren9"></span>
          <span class="text ml4 blue">{{ baseInfo.user.user_name }},欢迎您!</span>
        </div>
        <div class="header-navbar-icon"><span class="gray">|</span></div>
        <div class="header-navbar-icon" @click="passwordFunc()"><span class="text">修改密码</span></div>
        <div class="header-navbar-icon login-out" @click="login_out()">
          <span class="icon iconfont icon-tuichu"></span>
          <span class="text ml4">退出</span>
        </div>
      </div>
    </div>
 
    <!--修改密码-->
    <UpdatePassword v-if="is_password" @close="closeFunc"></UpdatePassword>
  </div>
</template>
 
<script>
  import bus from '@/utils/eventBus.js';
  import AuthApi from '@/api/auth.js';
  import UserApi from '@/api/user.js';
  import {
    setCookie,
    delCookie,
    getCookie,
    deleteSessionStorage
  } from '@/utils/base.js';
  import store from '@/store';
  import UpdatePassword from './part/UpdatePassword.vue';
  export default {
    components: {
      UpdatePassword
    },
    data() {
      return {
        /*菜单名称*/
        menu_title: '菜单',
        /*切换菜单*/
        tabList: [],
        /*切换选中*/
        activeValue: 0,
        /*是否修改密码*/
        is_password: false,
        /*tab切换类别*/
        tab_type: ''
      };
    },
    inject: ['baseInfo'],
    created() {
      /*监听菜单传过来的值*/
      bus.$on('menuName', res => {
        this.menu_title = res;
      });
 
      /*监听传插件的值*/
      bus.$on('tabData', res => {
        this.tabList = res.list;
        this.activeValue = res.active;
        this.tab_type = res.tab_type;
      });
 
      //发送给其它组件头部加载完成
      bus.$emit('headLoad', true);
 
    },
    beforeDestroy() {
      bus.$off('menuName');
      bus.$off('tabData');
    },
    mounted() {},
    methods: {
 
      /*退出登录*/
      login_out() {
        this.$confirm('此操作将退出登录, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
          .then(() => {
            UserApi.loginOut({}, true)
              .then(data => {
                /*删除登录状态*/
                delCookie('isLogin');
                /*删除基本信息*/
                delCookie('baseInfo');
                /*删除用户菜单*/
                deleteSessionStorage('rolelist');
                /*删除用户权限*/
                deleteSessionStorage('authlist');
                /*返回登录页*/
                this.$router.replace({
                  path: '/login'
                });
                /*删除stores数据*/
                this.$store.commit('user/setState', {
                  key: 'roles',
                  val: null
                });
                /*刷新页面*/
                location.reload();
              })
              .catch(error => {});
          })
          .catch(() => {
            // this.$message({
            //   type: 'info',
            //   message: '已取消退出'
            // });
          });
      },
 
      /*点击跳转*/
      tabClick(e) {
        /*分销*/
        if (this.tab_type == 'agent') {
          this.$router.push({
            path: '/plus/agent/index',
            query: {
              type: e.name
            }
          });
        }
        /*供需发布*/
        if (this.tab_type == 'demandapply') {
          this.$router.push({
            path: '/plus/demandapply/index',
            query: {
              type: e.name
            }
          });
        }
        /*vip专区*/
        if (this.tab_type == 'vip') {
          this.$router.push({
            path: '/plus/vip/index',
            query: {
              type: e.name
            }
          });
        }
        /*优惠券*/
        if (this.tab_type == 'coupon') {
          this.$router.push({
            path: '/plus/coupon/index',
            query: {
              type: e.name
            }
          });
        }
        /*积分商城*/
        if (this.tab_type == 'points') {
          this.$router.push({
            path: '/plus/points/index',
            query: {
              type: e.name
            }
          });
        }
        /* 现时秒杀*/
        if (this.tab_type == 'seckill') {
          this.$router.push({
            path: '/plus/seckill/index',
            query: {
              type: e.name
            }
          });
        }
        /* 限时拼团*/
        if (this.tab_type == 'assemble') {
          this.$router.push({
            path: '/plus/assemble/index',
            query: {
              type: e.name
            }
          });
        }
        /* 砍价*/
        if (this.tab_type == 'bargain') {
          this.$router.push({
            path: '/plus/bargain/index',
            query: {
              type: e.name
            }
          });
        }
        /*门店*/
        if (this.tab_type == 'store') {
          this.$router.push({
            path: '/store/index',
            query: {
              type: e.name
            }
          });
        }
        /*app设置*/
        if (this.tab_type == 'appopen') {
          this.$router.push({
            path: '/appsetting/appopen/event',
            query: {
              type: e.name
            }
          });
        }
        bus.$emit('activeValue', this.activeValue);
      },
 
      /*修改密码*/
      passwordFunc() {
        this.is_password = true;
      },
 
      /*关闭修改密码*/
      closeFunc() {
        this.is_password = false;
      }
    }
  };
</script>
 
<style lang="scss">
  .common-header .el-tabs__nav-wrap::after {
    display: none;
  }
 
  .common-header .el-tabs-container {
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid #EEEEEE;
  }
 
  .common-header .el-tabs__header {
    margin-bottom: 0;
  }
 
  .login-out .icon-tuichu {
    color: red;
  }
 
  .header-navbar-icon .icon-geren9 {
    font-size: 20px;
  }
</style>