|
|
@@ -7,19 +7,7 @@
|
|
|
</el-row>
|
|
|
<div class="avatar-wrapper">
|
|
|
<!-- <img :src="avatar" /> -->
|
|
|
- <el-upload
|
|
|
- :action="uploadUrl"
|
|
|
- :show-file-list="false"
|
|
|
- :on-success="handleAvatarSuccess"
|
|
|
- :before-upload="beforeAvatarUpload"
|
|
|
- :on-error="handleAvatarError"
|
|
|
- accept="image/*"
|
|
|
- v-loading="avatarUploading"
|
|
|
- >
|
|
|
- <img v-if="avatar" :src="avatar" />
|
|
|
- <i v-else class="avatar"></i>
|
|
|
- <div class="edit_avatar">点击头像修改</div>
|
|
|
- </el-upload>
|
|
|
+ <single-upload :value="(userInfo || {}).avatar" @input="changeAvatar"> </single-upload>
|
|
|
</div>
|
|
|
<el-form ref="form" :model="form" label-width="150px" :rules="rules" style="max-width: 600px;" size="small">
|
|
|
<el-form-item label="企业名称" prop="orgName">
|
|
|
@@ -102,6 +90,7 @@ import resolveUrl from 'resolve-url';
|
|
|
import province from '@/mixins/provinces.json';
|
|
|
import cities from '@/mixins/cities.json';
|
|
|
import areas from '@/mixins/areas.json';
|
|
|
+import { mapState } from 'vuex';
|
|
|
|
|
|
export default {
|
|
|
name: 'editInfo',
|
|
|
@@ -197,10 +186,8 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- handleAvatarSuccess(res, file) {
|
|
|
- this.avatar = URL.createObjectURL(file.raw);
|
|
|
- this.avatarUploading = false;
|
|
|
- this.$http.post('/user/updateProfile', { avatar: res }).then(res => {
|
|
|
+ changeAvatar(avatar) {
|
|
|
+ this.$http.post('/user/updateProfile', { avatar }).then(res => {
|
|
|
this.$message.success('修改成功');
|
|
|
this.$http.get('/user/my').then(res => {
|
|
|
this.$store.commit('updateUserInfo', res);
|
|
|
@@ -270,7 +257,9 @@ export default {
|
|
|
this.$message.error(e.error);
|
|
|
});
|
|
|
},
|
|
|
- computed: {}
|
|
|
+ computed: {
|
|
|
+ ...mapState(['userInfo'])
|
|
|
+ }
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="less" scoped>
|
|
|
@@ -297,23 +286,17 @@ export default {
|
|
|
// flex-direction: column;
|
|
|
// align-items: center;
|
|
|
// justify-content: center;
|
|
|
- .el-upload {
|
|
|
- img {
|
|
|
- width: 148px;
|
|
|
- height: 148px;
|
|
|
- border-radius: 74px;
|
|
|
- }
|
|
|
+ /deep/ .upload-image {
|
|
|
+ width: 148px;
|
|
|
+ height: 148px;
|
|
|
+ border-radius: 74px;
|
|
|
+ object-fit: cover;
|
|
|
}
|
|
|
- .edit_avatar {
|
|
|
- width: 96px;
|
|
|
- height: 36px;
|
|
|
- margin: 20px auto 0 auto;
|
|
|
- line-height: 36px;
|
|
|
- text-align: center;
|
|
|
- cursor: pointer;
|
|
|
- color: #939599;
|
|
|
- font-size: 13px;
|
|
|
- border: 1px solid #dcdfe6;
|
|
|
+ /deep/ .single-uploader-icon {
|
|
|
+ width: 148px;
|
|
|
+ height: 148px;
|
|
|
+ line-height: 148px;
|
|
|
+ border-radius: 74px;
|
|
|
}
|
|
|
}
|
|
|
.editInfo {
|