Commit 61f89c44851d3ddb39fef687e10e72313576b241
1 parent
249594b5
提交登陆
Showing
3 changed files
with
165 additions
and
75 deletions
src/api/mycar.js
... | ... | @@ -26,11 +26,10 @@ export function boundCarNum(params) { |
26 | 26 | * 解绑车牌 |
27 | 27 | * @param params |
28 | 28 | */ |
29 | -export function unboundCarNum(params) { | |
29 | +export function unboundCarNum() { | |
30 | 30 | return request({ |
31 | 31 | url: '/personCarNumPc/unboundCarNum', |
32 | - method: 'post', | |
33 | - params | |
32 | + method: 'post' | |
34 | 33 | }) |
35 | 34 | } |
36 | 35 | ... | ... |
src/api/user.js
... | ... | @@ -34,3 +34,25 @@ export function logout() { |
34 | 34 | method: 'post' |
35 | 35 | }) |
36 | 36 | } |
37 | + | |
38 | +export function uploadUserPic(file){ | |
39 | + debugger | |
40 | + return request({ | |
41 | + url: '/personPc/uploadUserPic', | |
42 | + method: 'post', | |
43 | + data:file | |
44 | + }) | |
45 | +} | |
46 | + | |
47 | +/** | |
48 | + * 更新个人客户信息 | |
49 | + * @param params | |
50 | + */ | |
51 | +export function updatePersonByCustId(params){ | |
52 | + return request({ | |
53 | + url: '/personPc/updatePersonBycustId', | |
54 | + method: 'post', | |
55 | + data:params | |
56 | + }) | |
57 | +} | |
58 | + | ... | ... |
src/views/information/index.vue
1 | 1 | <template> |
2 | 2 | <div class=""> |
3 | - <!--卡片--> | |
4 | - <el-row :gutter="16" class=""> | |
5 | - <el-col :span="8"> | |
6 | - <el-card class="box-card"> | |
7 | - <el-upload | |
8 | - class="avatar-uploader text-center" | |
9 | - action="https://jsonplaceholder.typicode.com/posts/" | |
10 | - :show-file-list="false" | |
11 | - :on-success="handleAvatarSuccess" | |
12 | - :on-remove="handleRemove" | |
13 | - :before-upload="beforeAvatarUpload"> | |
14 | - <img v-if="imageUrl" :src="imageUrl" class="avatar"> | |
15 | - <i v-else class="el-icon-plus avatar-uploader-icon"></i> | |
16 | - </el-upload> | |
17 | - <!--<el-button class="text-center" size="small" type="primary">点击上传</el-button>--> | |
18 | - <!--<div slot="tip" class="el-upload__tip"></div>--> | |
19 | - <div class="common-color text-center" style="line-height: 30px">15143234323</div> | |
20 | - | |
21 | - <div class="font-size12 text-center" style="line-height: 30px">支持JPG格式且小于5MB</div> | |
22 | - <div class="font-size12 text-center" style="height: 146px"> </div> | |
23 | - </el-card> | |
24 | - </el-col> | |
25 | - <el-col :span="16"> | |
26 | - <el-card class="box-card"> | |
27 | - <!-- <div slot="header" class="clearfix" style="line-height: 32px;"> | |
28 | - <span>个人资料</span> | |
29 | - </div>--> | |
30 | - <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px"> | |
31 | - <el-form-item label="姓名" class="margin-bottom30" prop="username"> | |
32 | - <el-input v-model="ruleForm.username" style="width: 300px"></el-input> | |
33 | - </el-form-item> | |
34 | - <el-form-item label="性别" class="margin-bottom30" prop="sex"> | |
35 | - <el-select v-model="ruleForm.sex" style="width: 300px"> | |
36 | - <el-option label="男" value="1"/> | |
37 | - <el-option label="女" value="2"/> | |
38 | - </el-select> | |
39 | - </el-form-item> | |
40 | - <el-form-item label="生日" class="margin-bottom30" prop="birthday"> | |
41 | - <el-date-picker | |
42 | - v-model="ruleForm.birthday" | |
43 | - type="date" | |
44 | - placeholder="选择日期" style="width: 300px"> | |
45 | - </el-date-picker> | |
46 | - </el-form-item> | |
47 | - <el-form-item label="年龄" class="margin-bottom30" prop="num"> | |
48 | - <el-input-number v-model="ruleForm.num" @change="handleChange" :min="1" :max="150" style="width: 300px"></el-input-number> | |
49 | - </el-form-item> | |
50 | - <el-form-item label="位置" class="margin-bottom30" prop="address"> | |
51 | - <el-input type="text" v-model="ruleForm.address" style="width: 300px"></el-input> | |
52 | - </el-form-item> | |
53 | - | |
54 | - <el-form-item> | |
55 | - <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button> | |
56 | - <el-button @click="resetForm('ruleForm')">取消</el-button> | |
57 | - </el-form-item> | |
58 | - </el-form> | |
59 | - </el-card> | |
60 | - </el-col> | |
61 | - </el-row> | |
3 | + <!--卡片--> | |
4 | + <el-row :gutter="16" class=""> | |
5 | + <el-col :span="8"> | |
6 | + <el-card class="box-card"> | |
7 | + <el-form status-icon :rules="rules" ref="fileUploadForm"> | |
8 | + <el-upload | |
9 | + class="avatar-uploader text-center" | |
10 | + action="#" | |
11 | + :show-file-list="false" | |
12 | + :on-success="handleAvatarSuccess" | |
13 | + :on-remove="handleRemove" | |
14 | + :before-upload="beforeAvatarUpload"> | |
15 | + <img v-if="imageUrl" :src="imageUrl" class="avatar"> | |
16 | + <i v-else class="el-icon-plus avatar-uploader-icon"></i> | |
17 | + </el-upload> | |
18 | + </el-form> | |
19 | + <!--<el-button class="text-center" size="small" type="primary">点击上传</el-button>--> | |
20 | + <!--<div slot="tip" class="el-upload__tip"></div>--> | |
21 | + <div class="common-color text-center" style="line-height: 30px">{{userPhone}}</div> | |
22 | + | |
23 | + <div class="font-size12 text-center" style="line-height: 30px">支持JPG格式且小于5MB</div> | |
24 | + <div class="font-size12 text-center" style="height: 146px"></div> | |
25 | + </el-card> | |
26 | + </el-col> | |
27 | + <el-col :span="16"> | |
28 | + <el-card class="box-card"> | |
29 | + <!-- <div slot="header" class="clearfix" style="line-height: 32px;"> | |
30 | + <span>个人资料</span> | |
31 | + </div>--> | |
32 | + <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px"> | |
33 | + <el-form-item label="姓名" class="margin-bottom30" prop="username"> | |
34 | + <el-input v-model="ruleForm.username" style="width: 300px"></el-input> | |
35 | + </el-form-item> | |
36 | + <el-form-item label="性别" class="margin-bottom30" prop="sex"> | |
37 | + <el-select v-model="ruleForm.sex" style="width: 300px"> | |
38 | + <el-option label="男" value="1"/> | |
39 | + <el-option label="女" value="2"/> | |
40 | + <el-option label="未知" value="3"/> | |
41 | + </el-select> | |
42 | + </el-form-item> | |
43 | + <el-form-item label="生日" class="margin-bottom30" prop="birthday"> | |
44 | + <el-date-picker | |
45 | + v-model="ruleForm.birthday" | |
46 | + type="date" | |
47 | + placeholder="选择日期" style="width: 300px"> | |
48 | + </el-date-picker> | |
49 | + </el-form-item> | |
50 | + <el-form-item label="位置" class="margin-bottom30" prop="address"> | |
51 | + <el-input type="text" v-model="ruleForm.address" style="width: 300px"></el-input> | |
52 | + </el-form-item> | |
53 | + | |
54 | + <el-form-item> | |
55 | + <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button> | |
56 | + </el-form-item> | |
57 | + </el-form> | |
58 | + </el-card> | |
59 | + </el-col> | |
60 | + </el-row> | |
62 | 61 | </div> |
63 | 62 | </template> |
64 | 63 | |
65 | 64 | <script> |
65 | + import {uploadUserPic,updatePersonByCustId} from '@/api/user.js'; | |
66 | + | |
66 | 67 | export default { |
67 | 68 | data() { |
68 | 69 | return { |
69 | 70 | imageUrl: '', |
70 | 71 | ruleForm: { |
71 | - username: '万八', | |
72 | - num: '23', | |
73 | - sex:'男', | |
74 | - birthday: '2019-08-17', | |
75 | - address: '北京海淀区上地五街1003号' | |
72 | + username: '', | |
73 | + num: '', | |
74 | + sex: '', | |
75 | + birthday: '', | |
76 | + address: '', | |
77 | + custId: '', | |
76 | 78 | }, |
79 | + userPhone:'', | |
77 | 80 | rules: { |
78 | 81 | username: [ |
79 | - { required: true, message: '请输入活动名称', trigger: 'blur' }, | |
80 | - { min: 1, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' } | |
82 | + {required: true, message: '请输入用户名', trigger: 'blur'}, | |
83 | + {min: 1, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur'} | |
81 | 84 | ], |
82 | 85 | birthday: [ |
83 | - { required: true, message: '请输入日期', trigger: 'blur' }, | |
84 | - { type: 'email', message: '请输入正确的日期', trigger: ['blur', 'change'] } | |
86 | + {required: true, message: '请输入日期', trigger: 'blur'} | |
85 | 87 | ], |
86 | 88 | address: [ |
87 | - { required: true, message: '请输入活动名称', trigger: 'blur' }, | |
88 | - { min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' } | |
89 | + {required: true, message: '请输入地址信息', trigger: 'blur'}, | |
90 | + {min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur'} | |
89 | 91 | ], |
90 | 92 | } |
91 | 93 | }; |
... | ... | @@ -96,8 +98,10 @@ |
96 | 98 | }, |
97 | 99 | handleAvatarSuccess(res, file) { |
98 | 100 | this.imageUrl = URL.createObjectURL(file.raw); |
101 | + debugger | |
99 | 102 | }, |
100 | 103 | beforeAvatarUpload(file) { |
104 | + let that = this; | |
101 | 105 | const isJPG = file.type === 'image/jpeg'; |
102 | 106 | const isLt5M = file.size / 1024 / 1024 < 5; |
103 | 107 | |
... | ... | @@ -107,15 +111,76 @@ |
107 | 111 | if (!isLt5M) { |
108 | 112 | this.$message.error('上传头像图片大小不能超过 5MB!'); |
109 | 113 | } |
114 | + let userInfo = this.$store.state.user.userInfo; | |
115 | + let fd = new FormData(); | |
116 | + fd.append('custId', userInfo.custId) | |
117 | + fd.append('file', file) | |
118 | + uploadUserPic(fd).then(response => { | |
119 | + if(response.code ='8888'){ | |
120 | + that.imageUrl=response.data; | |
121 | + } | |
122 | + | |
123 | + | |
124 | + }); | |
125 | + | |
126 | + | |
110 | 127 | return isJPG && isLt5M; |
111 | 128 | }, |
129 | + submitForm: function (formName) { | |
130 | + let username = this.ruleForm.username; | |
131 | + let sex = this.ruleForm.sex; | |
132 | + let birthday = this.ruleForm.birthday | |
133 | + let address = this.ruleForm.address; | |
134 | + let custId = this.ruleForm.custId; | |
135 | + | |
136 | + this.$refs[formName].validate((valid) => { | |
137 | + if (valid) { | |
138 | + let req ={ | |
139 | + custName:username, | |
140 | + sex:sex, | |
141 | + birthDate:birthday, | |
142 | + address:address, | |
143 | + custId:custId | |
144 | + }; | |
145 | + updatePersonByCustId(req).then(response =>{ | |
146 | + if(response.code ='8888'){ | |
147 | + debugger | |
148 | + let userInfo = this.$store.state.user.userInfo; | |
149 | + userInfo.custName=username; | |
150 | + userInfo.sex=sex; | |
151 | + userInfo.birthDate=birthday; | |
152 | + userInfo.address=address; | |
153 | + this.$message({ | |
154 | + type: 'success', | |
155 | + message: '更新用户信息成功!' | |
156 | + }); | |
157 | + } | |
158 | + }); | |
159 | + } | |
160 | + }); | |
161 | + }, | |
112 | 162 | resetForm(formName) { |
113 | 163 | this.$refs[formName].resetFields(); |
164 | + }, | |
165 | + queryUserInfo: function () { | |
166 | + let userInfo = this.$store.state.user.userInfo; | |
167 | + this.userPhone=userInfo.userPhone; | |
168 | + this.ruleForm = { | |
169 | + username: userInfo.custName, | |
170 | + //num: '', | |
171 | + sex: userInfo.sex + "", | |
172 | + birthday: userInfo.birthDate, | |
173 | + address: userInfo.address, | |
174 | + custId: userInfo.custId | |
175 | + } | |
114 | 176 | } |
177 | + }, | |
178 | + mounted: function () { | |
179 | + this.queryUserInfo(); | |
115 | 180 | } |
116 | 181 | } |
117 | 182 | </script> |
118 | -<style lang="scss" > | |
183 | +<style lang="scss"> | |
119 | 184 | |
120 | 185 | .avatar-uploader .el-upload { |
121 | 186 | border: 1px dashed #d9d9d9; |
... | ... | @@ -124,9 +189,11 @@ |
124 | 189 | position: relative; |
125 | 190 | overflow: hidden; |
126 | 191 | } |
192 | + | |
127 | 193 | .avatar-uploader .el-upload:hover { |
128 | 194 | border-color: #409EFF; |
129 | 195 | } |
196 | + | |
130 | 197 | .avatar-uploader-icon { |
131 | 198 | font-size: 28px; |
132 | 199 | color: #8c939d; |
... | ... | @@ -135,12 +202,14 @@ |
135 | 202 | line-height: 178px; |
136 | 203 | text-align: center; |
137 | 204 | } |
205 | + | |
138 | 206 | .avatar { |
139 | 207 | width: 178px; |
140 | 208 | height: 178px; |
141 | 209 | display: block; |
142 | 210 | } |
143 | - .margin-bottom30{ | |
211 | + | |
212 | + .margin-bottom30 { | |
144 | 213 | margin-bottom: 30px; |
145 | 214 | } |
146 | 215 | </style> | ... | ... |