613d2a9c
Andy
add icon
|
1
|
<template>
|
c0534536
Andy
add 个人资料 前端页面
|
2
|
<div class="">
|
61f89c44
王富生
提交登陆
|
3
4
|
<!--卡片-->
<el-row :gutter="16" class="">
|
5ab16151
王富生
提交权限控制
|
5
|
<!-- <el-col :span="8">
|
52ef4112
王富生
提交登陆
|
6
|
<el-card class="box-card" style="height: 364px">
|
61f89c44
王富生
提交登陆
|
7
8
9
10
11
12
13
14
15
16
17
18
|
<el-form status-icon :rules="rules" ref="fileUploadForm">
<el-upload
class="avatar-uploader text-center"
action="#"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:on-remove="handleRemove"
:before-upload="beforeAvatarUpload">
<img v-if="imageUrl" :src="imageUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
</el-form>
|
5ab16151
王富生
提交权限控制
|
19
|
|
52ef4112
王富生
提交登陆
|
20
|
<div class="common-color text-center" style="line-height: 60px;font-size: 24px">{{userPhone}}</div>
|
61f89c44
王富生
提交登陆
|
21
22
23
24
|
<div class="font-size12 text-center" style="line-height: 30px">支持JPG格式且小于5MB</div>
<div class="font-size12 text-center" style="height: 146px"></div>
</el-card>
|
5ab16151
王富生
提交权限控制
|
25
26
|
</el-col>-->
<el-col :span="24">
|
61f89c44
王富生
提交登陆
|
27
28
29
30
|
<el-card class="box-card">
<!-- <div slot="header" class="clearfix" style="line-height: 32px;">
<span>个人资料</span>
</div>-->
|
50ae39a5
Andy
add bug修复
|
31
|
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" style="width:450px;margin:0 auto;" :label-position="right">
|
5ab16151
王富生
提交权限控制
|
32
33
34
|
<el-form-item label="手机号" class="margin-bottom30" >
<el-input style="width: 300px" v-model="userPhone" :disabled="true" ></el-input>
</el-form-item>
|
61f89c44
王富生
提交登陆
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<el-form-item label="姓名" class="margin-bottom30" prop="username">
<el-input v-model="ruleForm.username" style="width: 300px"></el-input>
</el-form-item>
<el-form-item label="性别" class="margin-bottom30" prop="sex">
<el-select v-model="ruleForm.sex" style="width: 300px">
<el-option label="男" value="1"/>
<el-option label="女" value="2"/>
<el-option label="未知" value="3"/>
</el-select>
</el-form-item>
<el-form-item label="生日" class="margin-bottom30" prop="birthday">
<el-date-picker
v-model="ruleForm.birthday"
type="date"
placeholder="选择日期" style="width: 300px">
</el-date-picker>
</el-form-item>
|
1e73ec12
Andy
add 黄石官网 个人信息 地址优化
|
52
|
<el-form-item label="地址" class="margin-bottom30" prop="address">
|
61f89c44
王富生
提交登陆
|
53
54
55
56
57
58
59
60
61
62
|
<el-input type="text" v-model="ruleForm.address" style="width: 300px"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
</el-form-item>
</el-form>
</el-card>
</el-col>
</el-row>
|
613d2a9c
Andy
add icon
|
63
64
65
66
|
</div>
</template>
<script>
|
61f89c44
王富生
提交登陆
|
67
68
|
import {uploadUserPic,updatePersonByCustId} from '@/api/user.js';
|
613d2a9c
Andy
add icon
|
69
|
export default {
|
613d2a9c
Andy
add icon
|
70
71
|
data() {
return {
|
c0534536
Andy
add 个人资料 前端页面
|
72
73
|
imageUrl: '',
ruleForm: {
|
61f89c44
王富生
提交登陆
|
74
75
76
77
78
79
|
username: '',
num: '',
sex: '',
birthday: '',
address: '',
custId: '',
|
c0534536
Andy
add 个人资料 前端页面
|
80
|
},
|
61f89c44
王富生
提交登陆
|
81
|
userPhone:'',
|
c0534536
Andy
add 个人资料 前端页面
|
82
83
|
rules: {
username: [
|
61f89c44
王富生
提交登陆
|
84
85
|
{required: true, message: '请输入用户名', trigger: 'blur'},
{min: 1, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur'}
|
c0534536
Andy
add 个人资料 前端页面
|
86
|
],
|
c0534536
Andy
add 个人资料 前端页面
|
87
|
birthday: [
|
61f89c44
王富生
提交登陆
|
88
|
{required: true, message: '请输入日期', trigger: 'blur'}
|
c0534536
Andy
add 个人资料 前端页面
|
89
|
],
|
c0534536
Andy
add 个人资料 前端页面
|
90
|
address: [
|
61f89c44
王富生
提交登陆
|
91
92
|
{required: true, message: '请输入地址信息', trigger: 'blur'},
{min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur'}
|
c0534536
Andy
add 个人资料 前端页面
|
93
|
],
|
613d2a9c
Andy
add icon
|
94
|
}
|
c0534536
Andy
add 个人资料 前端页面
|
95
|
};
|
613d2a9c
Andy
add icon
|
96
|
},
|
613d2a9c
Andy
add icon
|
97
|
methods: {
|
c0534536
Andy
add 个人资料 前端页面
|
98
99
100
101
102
|
handleRemove(res, file) {
console.log(res, file);
},
handleAvatarSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw);
|
c0534536
Andy
add 个人资料 前端页面
|
103
104
|
},
beforeAvatarUpload(file) {
|
61f89c44
王富生
提交登陆
|
105
|
let that = this;
|
c0534536
Andy
add 个人资料 前端页面
|
106
107
108
109
110
111
112
113
114
|
const isJPG = file.type === 'image/jpeg';
const isLt5M = file.size / 1024 / 1024 < 5;
if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG 格式!');
}
if (!isLt5M) {
this.$message.error('上传头像图片大小不能超过 5MB!');
}
|
61f89c44
王富生
提交登陆
|
115
116
117
118
119
120
121
122
123
124
125
126
127
|
let userInfo = this.$store.state.user.userInfo;
let fd = new FormData();
fd.append('custId', userInfo.custId)
fd.append('file', file)
uploadUserPic(fd).then(response => {
if(response.code ='8888'){
that.imageUrl=response.data;
}
});
|
c0534536
Andy
add 个人资料 前端页面
|
128
|
return isJPG && isLt5M;
|
7efbb9fb
Andy
add 个人资料 前端页面
|
129
|
},
|
61f89c44
王富生
提交登陆
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
submitForm: function (formName) {
let username = this.ruleForm.username;
let sex = this.ruleForm.sex;
let birthday = this.ruleForm.birthday
let address = this.ruleForm.address;
let custId = this.ruleForm.custId;
this.$refs[formName].validate((valid) => {
if (valid) {
let req ={
custName:username,
sex:sex,
birthDate:birthday,
address:address,
custId:custId
};
updatePersonByCustId(req).then(response =>{
if(response.code ='8888'){
|
61f89c44
王富生
提交登陆
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
let userInfo = this.$store.state.user.userInfo;
userInfo.custName=username;
userInfo.sex=sex;
userInfo.birthDate=birthday;
userInfo.address=address;
this.$message({
type: 'success',
message: '更新用户信息成功!'
});
}
});
}
});
},
|
7efbb9fb
Andy
add 个人资料 前端页面
|
162
163
|
resetForm(formName) {
this.$refs[formName].resetFields();
|
61f89c44
王富生
提交登陆
|
164
165
166
167
168
169
170
171
172
173
174
175
|
},
queryUserInfo: function () {
let userInfo = this.$store.state.user.userInfo;
this.userPhone=userInfo.userPhone;
this.ruleForm = {
username: userInfo.custName,
//num: '',
sex: userInfo.sex + "",
birthday: userInfo.birthDate,
address: userInfo.address,
custId: userInfo.custId
}
|
613d2a9c
Andy
add icon
|
176
|
}
|
61f89c44
王富生
提交登陆
|
177
178
179
|
},
mounted: function () {
this.queryUserInfo();
|
613d2a9c
Andy
add icon
|
180
181
182
|
}
}
</script>
|
61f89c44
王富生
提交登陆
|
183
|
<style lang="scss">
|
c0534536
Andy
add 个人资料 前端页面
|
184
185
186
|
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
|
7efbb9fb
Andy
add 个人资料 前端页面
|
187
|
border-radius: 50%;
|
c0534536
Andy
add 个人资料 前端页面
|
188
189
190
191
|
cursor: pointer;
position: relative;
overflow: hidden;
}
|
61f89c44
王富生
提交登陆
|
192
|
|
c0534536
Andy
add 个人资料 前端页面
|
193
194
195
|
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
|
61f89c44
王富生
提交登陆
|
196
|
|
c0534536
Andy
add 个人资料 前端页面
|
197
198
199
200
201
202
203
204
|
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
|
61f89c44
王富生
提交登陆
|
205
|
|
c0534536
Andy
add 个人资料 前端页面
|
206
207
208
209
210
|
.avatar {
width: 178px;
height: 178px;
display: block;
}
|
61f89c44
王富生
提交登陆
|
211
212
|
.margin-bottom30 {
|
c0534536
Andy
add 个人资料 前端页面
|
213
214
215
|
margin-bottom: 30px;
}
</style>
|
613d2a9c
Andy
add icon
|
|
|