mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-13 03:39:55 +08:00
去除用户修改头像前的路径
This commit is contained in:
@@ -51,7 +51,8 @@ const user = {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getInfo().then(res => {
|
getInfo().then(res => {
|
||||||
const user = res.user
|
const user = res.user
|
||||||
const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
|
// const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
|
||||||
|
const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : user.avatar;
|
||||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||||
commit('SET_ROLES', res.roles)
|
commit('SET_ROLES', res.roles)
|
||||||
commit('SET_PERMISSIONS', res.permissions)
|
commit('SET_PERMISSIONS', res.permissions)
|
||||||
|
|||||||
@@ -1,22 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="点击上传头像" class="img-circle img-lg" /></div>
|
<div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="点击上传头像"
|
||||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
|
class="img-circle img-lg" /></div>
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened"
|
||||||
|
@close="closeDialog">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :xs="24" :md="12" :style="{height: '350px'}">
|
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||||
<vue-cropper
|
<vue-cropper ref="cropper" :img="options.img" :info="true" :autoCrop="options.autoCrop"
|
||||||
ref="cropper"
|
:autoCropWidth="options.autoCropWidth" :autoCropHeight="options.autoCropHeight" :fixedBox="options.fixedBox"
|
||||||
:img="options.img"
|
@realTime="realTime" v-if="visible" />
|
||||||
:info="true"
|
|
||||||
:autoCrop="options.autoCrop"
|
|
||||||
:autoCropWidth="options.autoCropWidth"
|
|
||||||
:autoCropHeight="options.autoCropHeight"
|
|
||||||
:fixedBox="options.fixedBox"
|
|
||||||
@realTime="realTime"
|
|
||||||
v-if="visible"
|
|
||||||
/>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :md="12" :style="{height: '350px'}">
|
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||||
<div class="avatar-upload-preview">
|
<div class="avatar-upload-preview">
|
||||||
<img :src="previews.url" :style="previews.img" />
|
<img :src="previews.url" :style="previews.img" />
|
||||||
</div>
|
</div>
|
||||||
@@ -32,19 +26,19 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 1, offset: 2}" :md="2">
|
<el-col :lg="{ span: 1, offset: 2 }" :md="2">
|
||||||
<el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button>
|
<el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 1, offset: 1}" :md="2">
|
<el-col :lg="{ span: 1, offset: 1 }" :md="2">
|
||||||
<el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button>
|
<el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 1, offset: 1}" :md="2">
|
<el-col :lg="{ span: 1, offset: 1 }" :md="2">
|
||||||
<el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button>
|
<el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 1, offset: 1}" :md="2">
|
<el-col :lg="{ span: 1, offset: 1 }" :md="2">
|
||||||
<el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button>
|
<el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{span: 2, offset: 6}" :md="2">
|
<el-col :lg="{ span: 2, offset: 6 }" :md="2">
|
||||||
<el-button type="primary" size="small" @click="uploadImg()">提 交</el-button>
|
<el-button type="primary" size="small" @click="uploadImg()">提 交</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -116,6 +110,7 @@ export default {
|
|||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
this.options.img = reader.result;
|
this.options.img = reader.result;
|
||||||
|
// console.log(this.options.img);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -124,11 +119,17 @@ export default {
|
|||||||
this.$refs.cropper.getCropBlob(data => {
|
this.$refs.cropper.getCropBlob(data => {
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
formData.append("avatarfile", data);
|
formData.append("avatarfile", data);
|
||||||
|
console.log(data, formData);
|
||||||
uploadAvatar(formData).then(response => {
|
uploadAvatar(formData).then(response => {
|
||||||
|
console.log(response.code);
|
||||||
|
if (response.code === 200) {
|
||||||
this.open = false;
|
this.open = false;
|
||||||
this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl;
|
// this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl;
|
||||||
|
this.options.img = response.imgUrl;
|
||||||
|
console.log(this.options.img);
|
||||||
store.commit('SET_AVATAR', this.options.img);
|
store.commit('SET_AVATAR', this.options.img);
|
||||||
this.$modal.msgSuccess("修改成功");
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
}
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user