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

Loading…
Cancel
Save