Browse Source

修改头像

dev_des
1054425342@qq.com 4 weeks ago
parent
commit
03fefae930
  1. 31
      subPackages/user/profile.vue

31
subPackages/user/profile.vue

@ -150,19 +150,23 @@ export default {
}); });
}, },
onChooseAvatar(e) { onChooseAvatar(e) {
console.log(e.detail, "=="); const token = uni.getStorageSync("userInfo")
pathToBase64(e.detail.avatarUrl).then((base64) => { ? JSON.parse(uni.getStorageSync("userInfo")).token
this.Post( : "";
{ const file = e.detail.avatarUrl
method: "POST", uni.uploadFile({
base64: base64, url: this.NEWAPIURL_DES + "/system/oss/upload", //
filePath: file,
name: "file",
header: {
token: token || "",
// token
}, },
"/api/common/base64" success: (res) => {
).then((res) => { let info = JSON.parse(res.data)
if (res.data) {
this.Post( this.Post(
{ {
avatar: res.data, avatar: info.data.url,
}, },
"/api/user/profile" "/api/user/profile"
).then((res) => { ).then((res) => {
@ -177,9 +181,12 @@ export default {
}, },
}); });
}); });
} },
}); fail: (err) => {
reject(err);
},
}); });
}, },
uploadImg() { uploadImg() {
uni.chooseImage({ uni.chooseImage({

Loading…
Cancel
Save