修复头像上传

This commit is contained in:
Strange 2024-04-21 11:24:07 +08:00
parent 637cad590d
commit d05c73f5ee
2 changed files with 4997 additions and 2694 deletions

5885
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,9 +7,8 @@
:show-file-list="false"
:headers="headerObj"
: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>
</el-upload>
@ -19,15 +18,15 @@
<input
type="text"
placeholder="请输入昵称"
v-model="list.nicekname"
v-model="user.nicekname"
/>
</div>
<div class="item">
<p>性别</p>
<div class="radio">
<el-radio v-model="list.sex" label="male"></el-radio>
<el-radio v-model="list.sex" label="nv"></el-radio>
<el-radio v-model="user.sex" label="male"></el-radio>
<el-radio v-model="user.sex" label="nv"></el-radio>
</div>
</div>
@ -36,7 +35,7 @@
<input
type="text"
placeholder="请输入手机号"
v-model="list.phonenumber"
v-model="user.phonenumber"
/>
</div>
@ -57,11 +56,11 @@ export default {
return {
cdata: {},
headerObj: {
"Content-Type": "application/json",
// "Content-Type": "application/json",
saToken: localStorage.getItem("token"),
},
imageUrl:'',
list: {
user: {
phonenumber: "",
nicekname: "",
avatar: "",
@ -76,23 +75,28 @@ export default {
},
methods: {
handleSelect(e){
},
handleAvatarSuccess(res, file) {
this.imageUrl= URL.createObjectURL(file.raw);
this.list.avatar = this.imageUrl
console.log(res);
this.user.avatar =res.url
// this.imageUrl= URL.createObjectURL(file.raw);
// this.list.avatar = this.imageUrl
},
searchUser() {
apiServe.admin(this.cdata).then((res) => {
console.log(res);
this.list = res.data.data;
this.user = res.data.data;
this.imageUrl = res.data.data.avatar;
localStorage.setItem("userid", res.data.data.id);
localStorage.setItem("img", res.data.data.avatar);
});
},
save() {
apiServe.editAdmin(this.list).then((res) => {
apiServe.editAdmin(this.user).then((res) => {
console.log(res);
// this.$router.push("/index");
this.$router.push("/index");
this.$message({
message: "个人信息保存成功!",
type: "success",