top.vue
9.2 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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<template>
<div class="top">
<div class="top_wrap">
<!-- 上层 -->
<div class="logo_wrap clearfix">
<!-- logo -->
<div class="logo">
<img src="@/assets/img_3.png" alt />
</div>
<!-- 公司名称 -->
<div class="company_name">
全球移民与置业评估系统
<!-- International Immigration
<br />& Asset Allocation Assessed System-->
</div>
<!-- 个人信息 -->
<div class="person_msg clearfix" @mouseenter="showChoice()" @mouseleave="closeChoice()">
<div class="avatar">
<img :src="avatar" alt />
</div>
<div class="name">{{name}}</div>
<div class="bot_arrow">
<img :src="isTop?imgArrow1:imgArrow2" alt />
</div>
<!-- 修改密码 退出 -->
<div class="show_wrap" v-show="!isTop">
<div class="show_groups">
<!-- 修改密码 -->
<div class="change_pwd" @click="dialogPwdVisible = true">更改密码</div>
<!-- 退出 -->
<div class="logout" @click="loginOut()">退出</div>
</div>
</div>
</div>
</div>
<!-- 修改密码弹窗 -->
<div class="pwd_dialog">
<el-dialog :visible.sync="dialogPwdVisible" width="500px">
<div class="dialog_title_contract">更改密码</div>
<!-- 输入框 -->
<div class="input_group">
<el-form ref="form" :model="form" :rules="rules">
<el-form-item prop="oldPwd">
<el-input class="input_single" v-model="form.oldPwd" placeholder="请输入原密码"></el-input>
</el-form-item>
<el-form-item prop="newPwd">
<el-input class="input_single" v-model="form.newPwd" placeholder="请输入新密码"></el-input>
</el-form-item>
<el-form-item prop="repeatPwd">
<el-input class="input_single" v-model="form.repeatPwd" placeholder="请再次输入"></el-input>
</el-form-item>
</el-form>
<div class="pwd_btn layout flex_row justify_around align_center">
<div class="pwd_l_btn" @click="changePwd('form')">确定</div>
<div class="pwd_r_btn" @click="dialogPwdVisible = false">取消</div>
</div>
</div>
</el-dialog>
</div>
<!-- nav -->
<div class="nav_wrap">
<ul class="layout align_left flex_row">
<li
@click="choiceNav(index)"
class="nav_li"
:class="{active_li:isActive == index}"
v-for="(item,index) in navList"
:key="index"
>{{item}}</li>
</ul>
</div>
</div>
</div>
</template>
<script>
import { Message } from "element-ui";
import { post } from "../../api/http.js";
export default {
props: ["activeIndex"],
data() {
// 旧密码
var validateOldPass = (rule, value, callback) => {
if (!value) {
callback(new Error("请输入原密码"));
} else {
callback();
}
};
// 新密码
var validatePass = (rule, value, callback) => {
if (!value) {
callback(new Error("请输入新密码"));
} else {
callback();
}
};
// 确认密码
var validatePass2 = (rule, value, callback) => {
if (value == "") {
callback(new Error("请再次输入"));
} else if (value !== this.form.newPwd) {
callback(new Error("两次密码不一致!"));
} else {
callback();
}
};
return {
navList: ["首页", "我的客户", "工作报告", "个人中心"],
// 选中的按钮
isActive: 0,
// 个人信息箭头
isTop: true,
imgArrow1: require("@/assets/bot.png"),
imgArrow2: require("@/assets/top.png"),
// 修改密码弹窗
dialogPwdVisible: false,
token: "",
// 个人信息
avatar: "",
name: "",
// 重置密码
form: {
oldPwd: "",
newPwd: "",
repeatPwd: ""
},
// 验证密码
rules: {
oldPwd: [
{
required: true,
validator: validateOldPass,
trigger: "blur"
}
],
newPwd: [
{
required: true,
validator: validatePass,
trigger: "blur"
}
],
repeatPwd: [
{
required: true,
validator: validatePass2,
trigger: "blur"
}
]
}
};
},
methods: {
// 选择nav
choiceNav(index) {
this.isActive = index;
switch (index) {
case 0:
this.$router.push({ path: "/index" });
break;
case 1:
this.$router.push({ path: "/myClient" });
break;
case 2:
this.$router.push({ path: "/workReport" });
break;
case 3:
this.$router.push({ path: "/mine" });
break;
}
},
// 显示弹窗
showChoice() {
this.isTop = false;
},
// 弹窗消失
closeChoice() {
this.isTop = true;
},
// 修改密码
changePwd(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
let url = "/api/user/update_password";
let params = {
past_password: this.form.oldPwd,
now_password: this.form.newPwd,
repeat_password: this.form.repeatPwd
};
post(url, params).then(res => {
this.dialogPwdVisible = true;
this.$message({
showClose: true,
message: "修改成功",
type: "success"
});
});
}
});
},
// 退出登录
loginOut() {
let url = "/api/user/login_out";
post(url).then(res => {
this.$message({
showClose: true,
message: "退出成功",
type: "success"
});
localStorage.removeItem("token");
localStorage.removeItem("avatar");
localStorage.removeItem("type");
this.$router.push({
path: "/"
});
});
},
// 获取个人信息
getUserInfor() {
let url = "/api/user/member";
post(url).then(res => {
this.avatar = res.avatar;
this.name = res.name;
// type 1:业务员 2:代理商
localStorage.setItem("type", res.type);
});
}
},
mounted() {
this.isActive = this.activeIndex;
this.token = localStorage.getItem("token");
this.getUserInfor();
}
};
</script>
<style>
/* 修改密码弹窗 */
.pwd_dialog .el-dialog {
margin-top: 42vh !important;
}
.pwd_dialog .el-dialog__header {
display: none;
}
.pwd_dialog .el-dialog__body {
padding: 0 !important;
}
</style>
<style scoped>
.top {
border-bottom: 1px solid #999;
}
/* 内容 */
.top_wrap {
width: 1200px;
margin: 0 auto;
height: 162px;
position: relative;
}
/* logo */
.logo {
float: left;
width: 61px;
height: 60px;
margin-top: 26px;
margin-right: 20px;
}
/* 公司名称 */
.company_name {
float: left;
color: #6a6a6a;
font-size: 22px;
text-align: left;
margin-top: 40px;
line-height: 32px;
}
/* 个人信息 */
.person_msg {
float: right;
color: #6a6a6a;
font-size: 22px;
margin-top: 13px;
position: relative;
}
.avatar {
float: left;
width: 66px;
height: 66px;
}
.avatar img {
border-radius: 50%;
}
.name {
float: left;
margin: 22px 20px 0;
}
.bot_arrow {
float: left;
width: 23px;
/* height: 13px; */
margin-top: 24px;
}
/* 修改密码 退出 */
.show_wrap {
padding-top: 20px;
position: absolute;
left: 0;
bottom: -145px;
}
.show_groups {
width: 289px;
height: 135px;
background: rgba(255, 255, 255, 1);
box-shadow: 2px 0px 5px 1px rgba(0, 0, 0, 0.2);
color: #666;
font-size: 20px;
}
/* 修改密码 */
.change_pwd {
width: 100%;
height: 67px;
line-height: 67px;
text-align: center;
border-bottom: 1px solid #e2e2e2;
}
.change_pwd:hover,
.logout:hover {
background-color: #526aa6;
opacity: 0.8;
color: #fff;
}
.logout {
width: 100%;
height: 67px;
line-height: 67px;
text-align: center;
}
/* 修改密码弹窗 */
/* 头部 */
.dialog_title_contract {
color: #fff;
background-color: #526aa6;
padding-left: 30px;
height: 40px;
line-height: 40px;
text-align: left;
font-size: 18px;
}
/* 输入框 */
.input_group {
padding: 14px 20px;
}
.input_single {
/* margin-bottom: 25px; */
font-size: 14px;
}
/* 按钮 */
.pwd_btn {
margin: 40px auto 15px;
}
.pwd_l_btn {
width: 120px;
height: 38px;
background: rgba(82, 106, 166, 1);
border-radius: 3px;
text-align: center;
line-height: 38px;
color: #fff;
font-size: 16px;
}
.pwd_l_btn:hover {
opacity: 0.8;
}
.pwd_r_btn {
width: 118px;
height: 36px;
border: 1px solid rgba(153, 153, 153, 1);
border-radius: 3px;
text-align: center;
line-height: 38px;
color: #999;
font-size: 16px;
}
.pwd_r_btn:hover {
opacity: 0.8;
border-color: #526aa6;
}
/* nav */
.nav_wrap {
position: absolute;
bottom: 0;
left: 0;
/* margin-top: 21px; */
}
.nav_li {
font-size: 20px;
color: #333;
padding: 0 20px 16px;
border-bottom: 3px solid #fff;
}
.active_li {
color: #526aa6;
border-color: #526aa6;
}
</style>