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) {
console.log(e.detail, "==");
pathToBase64(e.detail.avatarUrl).then((base64) => {
this.Post(
{
method: "POST",
base64: base64,
},
"/api/common/base64"
).then((res) => {
if (res.data) {
this.Post(
{
avatar: res.data,
},
"/api/user/profile"
).then((res) => {
uni.showModal({
title: "提示",
content: res.msg,
showCancel: false,
success: (res) => {
if (res.confirm) {
this.getList();
}
},
});
});
}
});
});
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
},
success: (res) => {
let info = JSON.parse(res.data)
this.Post(
{
avatar: info.data.url,
},
"/api/user/profile"
).then((res) => {
uni.showModal({
title: "提示",
content: res.msg,
showCancel: false,
success: (res) => {
if (res.confirm) {
this.getList();
}
},
});
});
},
fail: (err) => {
reject(err);
},
});
},
uploadImg() {
uni.chooseImage({

Loading…
Cancel
Save