Browse Source

修改头像

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

67
subPackages/user/profile.vue

@ -150,36 +150,43 @@ 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,
"/api/common/base64" name: "file",
).then((res) => { header: {
if (res.data) { token: token || "",
this.Post( // token
{ },
avatar: res.data, success: (res) => {
}, let info = JSON.parse(res.data)
"/api/user/profile" this.Post(
).then((res) => { {
uni.showModal({ avatar: info.data.url,
title: "提示", },
content: res.msg, "/api/user/profile"
showCancel: false, ).then((res) => {
success: (res) => { uni.showModal({
if (res.confirm) { title: "提示",
this.getList(); content: res.msg,
} showCancel: false,
}, success: (res) => {
}); if (res.confirm) {
}); this.getList();
} }
}); },
}); });
});
},
fail: (err) => {
reject(err);
},
});
}, },
uploadImg() { uploadImg() {
uni.chooseImage({ uni.chooseImage({

Loading…
Cancel
Save