mine.vue
9.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
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
<template>
<div class="index_wrap">
<Top :activeIndex="activeIndex" ref="mychild"></Top>
<!-- 个人信息 -->
<div class="personal_msg">
<!-- 主体 -->
<div class="main layout align_center justify_center">
<!-- 个人信息内容 -->
<div>
<!-- 头像 -->
<div class="avatar_wrap layout flex_row">
<div class="avatar_box layout align_center justify_center">
<img :src="imageUrl" alt />
</div>
<!-- 姓名 -->
<div class="name_wrap layout justify_around align_left flex_diection">
<div class="name_box">
{{name}}
<div class="line_bot">
<img src="@/assets/img_20.png" alt />
</div>
</div>
<div class="upload_avatar">
<!-- 上传头像 -->
<el-upload
class="avatar-uploader layout align_center flex_row justify_start"
action="http://yiminadmin.zishike.cn/api/common/upload"
:headers="headers"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<!-- <el-upload
class="avatar-uploader layout align_center flex_row justify_start"
action="http://yiminadmin.zishike.com/api/common/upload"
:headers="headers"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
> -->
<!-- http://yiminadmin.zishike.com -->
<div class="upload_box layout justify align_center">
<div class="camera">
<img src="@/assets/img_31.png" alt />
</div>
<div class="upload_word">修改头像</div>
</div>
</el-upload>
<div class="upload_tips">* 支持JPG, PNG, BMP格式,大小不超过10M。</div>
</div>
</div>
</div>
<!-- 信息内容 -->
<div class="msg_content">
<div class="msg_single layout align_center flex_row justify_start">
<div class="msg_l">员工ID:</div>
<div class="msg_r">{{number}}</div>
</div>
<div class="msg_single layout align_center flex_row justify_start">
<div class="msg_l">手机号:</div>
<div class="msg_r">{{userName}}</div>
</div>
<div class="msg_single layout align_center flex_row justify_start">
<div class="msg_l">邮箱:</div>
<div class="msg_r" v-if="!isEditor">{{email}}</div>
<!-- 编辑 -->
<el-input class="email_input" v-model="email" v-else></el-input>
</div>
<div class="msg_single layout align_center flex_row justify_start">
<div class="msg_l">业务部门:</div>
<div class="msg_r">{{operatName}}</div>
</div>
</div>
<!-- 编辑按钮 -->
<div
class="editor_btn layout align_center flex_row justify_center"
@click="editorMsg()"
v-if="!isEditor"
>
<div>
<img src="@/assets/img_4.png" alt />
</div>
<div class="editor_word">编辑资料</div>
</div>
<!-- 编辑完成 提交按钮 -->
<div class="submit_btn layout align_center flex_row justify_around" v-else>
<div class="confirm_btn" @click="submit()">确定</div>
<div class="cancel_btn" @click="cancel()">取消</div>
</div>
</div>
</div>
</div>
<Bottom></Bottom>
</div>
</template>
<script>
import Top from "../../common/top";
import Bottom from "../../common/bottom";
import { Message } from "element-ui";
import { post } from "../../../api/http.js";
export default {
data() {
return {
activeIndex: 3,
// 头像
avatarUrl: "",
// 姓名
name: "",
// 编号
number: "",
// 联系方式
userName: "",
// 邮箱
email: "",
// 部门
operatName: "",
isEditor: false,
imageUrl: "",
headers: {
token: ""
},
gender:"",
chuanurl:''
};
},
methods: {
// 编辑信息
editorMsg() {
this.isEditor = true;
},
// 提交按钮
submit() {
if (
/^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(this.email)
) {
let url = "/api/user/update";
let params = {
avatar: this.chuanurl,
email: this.email
};
post(url, params).then(res => {
this.$refs.mychild.getUserInfor();
this.$message({
showClose: true,
message: "Modified success",
type: "success"
});
this.isEditor = false;
});
} else {
this.$message({
showClose: true,
message: "Please enter the correct email",
type: "warning"
});
}
},
// 撤销按钮
cancel() {
this.isEditor = false;
},
// 上传头像成功
handleAvatarSuccess(res, file) {
console.log(res,34893843894389)
this.avatarUrl = res.data.url;
this.chuanurl=res.data.relative_url
this.imageUrl = URL.createObjectURL(file.raw);
localStorage.setItem("avatar", this.avatarUrl);
let url = "/api/user/update";
let params = {
avatar: this.chuanurl,
email: this.email
};
post(url, params).then(res => {
this.$refs.mychild.getUserInfor();
this.$message({
showClose: true,
message: "Modified success",
type: "success"
});
this.isEditor = false;
});
},
beforeAvatarUpload(file) {
const isJPG =
file.type === "image/jpeg" ||
file.type === "image/png" ||
file.type === "image/bmp";
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isJPG) {
this.$message.error("上传头像图片只能是 JPG、PNG、BMP 格式!");
}
if (!isLt10M) {
this.$message.error("上传头像图片大小不能超过 10MB!");
}
return isJPG && isLt10M;
},
// 获取个人信息
getUserInfor() {
let url = "/api/user/member";
post(url).then(res => {
this.imageUrl = res.avatar;
this.name = res.name;
this.number = res.number;
this.userName = res.username;
this.gender=res.gender;
this.email = res.email;
this.operatName = res.department_name;
});
}
},
components: {
Top,
Bottom
},
mounted() {
this.getUserInfor();
// this.imageUrl = localStorage.getItem("avatar");
// console.log(this.imageUrl)
this.headers.token = localStorage.getItem("token");
}
};
</script>
<style scoped>
.main {
width: 1200px;
margin: 28px auto;
height: 940px;
box-shadow: #ccc 0px 0px 5px;
}
/* 头像 */
.avatar_box {
width: 264px;
height: 264px;
border-radius: 50%;
border: 1px solid #e5e5e5;
}
.avatar_box img {
width: 228px;
height: 228px;
border-radius: 50%;
}
/* 姓名 */
.name_wrap {
margin-left: 40px;
}
.name_box {
color: #526aa6;
font-size: 24px;
text-align: left;
}
.line_bot {
width: 290px;
margin-top: 3px;
}
/* 上传头像提示 */
/* 上传按钮 */
.upload_box {
width: 145px;
height: 46px;
background: linear-gradient(
102deg,
rgba(37, 123, 251, 1),
rgba(0, 229, 199, 1)
);
border-radius: 3px;
margin-bottom: 13px;
}
.upload_box:hover {
opacity: 0.8;
}
.camera {
width: 28px;
margin-left: 14px;
}
.upload_word {
font-size: 18px;
color: #fefefe;
margin-right: 14px;
}
.upload_tips {
color: #999;
font-size: 14px;
}
/* 信息内容 */
.msg_content {
margin: 60px 0;
}
.msg_single {
margin-bottom: 35px;
margin-left: 130px;
}
.msg_l {
width: 200px;
color: #333;
font-size: 20px;
font-weight: bold;
text-align: left;
}
.msg_r {
color: #666;
font-size: 20px;
text-align: left;
}
.email_input {
width: 300px;
font-size: 20px;
}
/* 编辑按钮 */
.editor_btn {
width: 185px;
height: 46px;
background: linear-gradient(
102deg,
rgba(37, 123, 251, 1),
rgba(0, 229, 199, 1)
);
border-radius: 3px;
margin: 100px auto 0;
color: #fefefe;
font-size: 18px;
}
.editor_btn:hover {
opacity: 0.8;
}
.editor_word {
margin-left: 20px;
}
/* 提交按钮 */
.submit_btn {
margin-top: 100px;
}
.confirm_btn {
width: 185px;
height: 46px;
background: linear-gradient(
102deg,
rgba(37, 123, 251, 1),
rgba(0, 229, 199, 1)
);
border-radius: 3px;
color: #fefefe;
font-size: 18px;
text-align: center;
line-height: 46px;
}
.confirm_btn:hover {
opacity: 0.8;
}
.cancel_btn {
width: 183px;
height: 44px;
border: 1px solid #999;
text-align: center;
line-height: 46px;
color: #666;
font-size: 18px;
border-radius: 3px;
}
.cancel_btn:hover {
border-color: #526aa6;
opacity: 0.8;
}
</style>