user-info.vue
2.1 KB
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
<template>
<Row class="layout-header">
<Col :span="12" class="brand-title">
<i class="fa fa-bars" aria-hidden="true" @click="$emit('menu-trigger')"></i>
{{userInfo.name}}
</Col>
<Col :span="12" class="shop-info">
<span class="name">{{userInfo.currentShop.shopName}}</span>
<span>|</span>
<Dropdown @on-click="switchShop" trigger="click">
<a class="swtich-shop" href="javascript:void(0)">
[切换店铺]
</a>
<Dropdown-menu slot="list">
<Dropdown-item v-for="shop in userInfo.shops" :key="shop.id" :name="shop.id" :selected="userInfo.currentShop.id === shop.id">{{shop.shopName}}</Dropdown-item>
</Dropdown-menu>
</Dropdown>
<a class="logout" href="javascript:;" @click="logout">[退出]</a>
</Col>
</Row>
</template>
<script>
import Vue from 'vue';
export default {
name: 'UserInfo',
data() {
return {
userInfo: this.$user
};
},
created() {
},
methods: {
logout() {
Vue.logout();
},
switchShop(id) {
this.userInfo.currentShop = this.userInfo.shops.find(shop => shop.id === id);
Vue.switchShop(id);
this.$emit('shop-change', this.userInfo.currentShop);
}
}
};
</script>
<style lang="scss">
.layout-header {
height: 60px !important;
background: #fff;
box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
font-size: 14px;
line-height: 20px;
padding: 20px;
.fa-bars {
font-size: 20px;
vertical-align: middle;
margin-right: 10px;
cursor: pointer;
}
.shop-info {
text-align: right;
padding-right: 20px;
.name {
margin-right: 5px;
}
.swtich-shop {
margin-left: 5px;
font-size: 12px;
color: #444;
}
.logout {
color: #F44545;
font-size: 12px;
margin-left: 5px;
}
}
}
</style>