layout-user-info.vue
4.39 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
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
<template>
<Row class="layout-header">
<Col :span="12" class="layout-header-left">
<div class="title">
<i class="iconfont icon-alignjustify" aria-hidden="true" @click="$emit('menu-trigger')"></i>
<span v-if="!showLoading" class="name">{{userInfo.currentShop.shopName}}</span>
</div>
<ul class="notice">
<li><span>|<a href="/rules.VOL.04.pdf" target="_blank">平台规则</a></span></li>
<li><span>|<a href="/user-guide.pdf" target="_blank">使用手册</a></span></li>
<li><span>|<a href="/kpgg.docx" target="_blank">开票公告(重要)</a></span></li>
<li><span>|</span></li>
</ul>
</Col>
<Col :span="12" class="layout-header-right">
<span>你好,{{userInfo.name}}</span>
<router-link to="/user/password.html" class="update-pwd">[修改密码]</router-link>
<span v-if="showLoading" class="loading">切换中...</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.shopsId" :name="shop.shopsId" :selected="userInfo.currentShop.shopsId === shop.shopsId">{{shop.shopName}}</Dropdown-item>
</Dropdown-menu>
</Dropdown>
<a class="logout" href="javascript:;" @click="logout">[退出]</a>
</Col>
</Row>
</template>
<script>
import Vue from 'vue';
import UserService from 'services/user/user-service';
export default {
name: 'layout-user-info',
data() {
return {
userInfo: this.$user,
showLoading: false
};
},
created() {
this.userService = new UserService();
},
methods: {
logout() {
Vue.logout();
},
switchShop(id) {
if (this.userInfo.currentShop.shopsId !== id) {
this.showLoading = true;
this.userService.switchShop(id).then(res => {
this.showLoading = false;
if (res.code === 200) {
this.userInfo.currentShop = this.userInfo.shops.find(shop => shop.shopsId === id);
Vue.switchShop(id);
this.$emit('shop-change', this.userInfo.currentShop);
this.$Message.success(`当前店铺切换为:${this.userInfo.currentShop.shopName}`);
} else {
this.$Message.error(`切换失败:${res.message}`);
}
});
}
}
}
};
</script>
<style lang="scss">
.layout-header {
height: 50px !important;
background: #fff;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
font-size: 14px;
line-height: 20px;
padding: 15px;
position: relative;
&.user-collapse {
height: 0 !important;
padding: 0 !important;
overflow: hidden;
.fa-bars {
position: absolute;
color: #000;
}
}
&.print-hide {
display: none;
}
.fa {
font-size: 20px;
vertical-align: middle;
margin-right: 10px;
cursor: pointer;
}
.layout-header-right {
text-align: right;
padding-right: 20px;
.name {
margin-right: 5px;
}
.loading {
color: #ccc;
}
.swtich-shop {
margin-left: 5px;
font-size: 12px;
color: #444;
}
.logout {
color: #f44545;
font-size: 12px;
margin-left: 5px;
}
}
.layout-header-left {
.title {
float: left;
min-width: 90px;
}
.notice {
float: left;
margin-left: 30px;
li {
float: left;
font-size: 15px;
}
span {
color: #ccc;
}
a {
color: #444;
margin-left: 10px;
margin-right: 10px;
}
}
}
.update-pwd {
margin-left: 5px;
font-size: 12px;
color: #444;
}
}
</style>