修复头像上传
This commit is contained in:
parent
637cad590d
commit
d05c73f5ee
File diff suppressed because it is too large
Load Diff
|
@ -7,9 +7,8 @@
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
:headers="headerObj"
|
:headers="headerObj"
|
||||||
:on-success="handleAvatarSuccess"
|
:on-success="handleAvatarSuccess"
|
||||||
:before-upload="beforeAvatarUpload"
|
|
||||||
>
|
>
|
||||||
<img v-if="imageUrl" :src="imageUrl" class="avatar" />
|
<img v-if="user.avatar" :src="user.avatar" class="avatar" />
|
||||||
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
|
|
||||||
|
@ -19,15 +18,15 @@
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="请输入昵称"
|
placeholder="请输入昵称"
|
||||||
v-model="list.nicekname"
|
v-model="user.nicekname"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<p>性别</p>
|
<p>性别</p>
|
||||||
<div class="radio">
|
<div class="radio">
|
||||||
<el-radio v-model="list.sex" label="male">男</el-radio>
|
<el-radio v-model="user.sex" label="male">男</el-radio>
|
||||||
<el-radio v-model="list.sex" label="nv">女</el-radio>
|
<el-radio v-model="user.sex" label="nv">女</el-radio>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="请输入手机号"
|
placeholder="请输入手机号"
|
||||||
v-model="list.phonenumber"
|
v-model="user.phonenumber"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -57,11 +56,11 @@ export default {
|
||||||
return {
|
return {
|
||||||
cdata: {},
|
cdata: {},
|
||||||
headerObj: {
|
headerObj: {
|
||||||
"Content-Type": "application/json",
|
// "Content-Type": "application/json",
|
||||||
saToken: localStorage.getItem("token"),
|
saToken: localStorage.getItem("token"),
|
||||||
},
|
},
|
||||||
imageUrl:'',
|
imageUrl:'',
|
||||||
list: {
|
user: {
|
||||||
phonenumber: "",
|
phonenumber: "",
|
||||||
nicekname: "",
|
nicekname: "",
|
||||||
avatar: "",
|
avatar: "",
|
||||||
|
@ -76,23 +75,28 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
handleSelect(e){
|
||||||
|
|
||||||
|
},
|
||||||
handleAvatarSuccess(res, file) {
|
handleAvatarSuccess(res, file) {
|
||||||
this.imageUrl= URL.createObjectURL(file.raw);
|
console.log(res);
|
||||||
this.list.avatar = this.imageUrl
|
this.user.avatar =res.url
|
||||||
|
// this.imageUrl= URL.createObjectURL(file.raw);
|
||||||
|
// this.list.avatar = this.imageUrl
|
||||||
},
|
},
|
||||||
searchUser() {
|
searchUser() {
|
||||||
apiServe.admin(this.cdata).then((res) => {
|
apiServe.admin(this.cdata).then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
this.list = res.data.data;
|
this.user = res.data.data;
|
||||||
this.imageUrl = res.data.data.avatar;
|
this.imageUrl = res.data.data.avatar;
|
||||||
localStorage.setItem("userid", res.data.data.id);
|
localStorage.setItem("userid", res.data.data.id);
|
||||||
localStorage.setItem("img", res.data.data.avatar);
|
localStorage.setItem("img", res.data.data.avatar);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
save() {
|
save() {
|
||||||
apiServe.editAdmin(this.list).then((res) => {
|
apiServe.editAdmin(this.user).then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
// this.$router.push("/index");
|
this.$router.push("/index");
|
||||||
this.$message({
|
this.$message({
|
||||||
message: "个人信息保存成功!",
|
message: "个人信息保存成功!",
|
||||||
type: "success",
|
type: "success",
|
||||||
|
|
Loading…
Reference in New Issue