wx.uploadFile 修改昵称和头像,不传图会失败?
saveInfo() {
var that = this;
console.log(that.avatarUrl, that.name)
wx.uploadFile({
url: "https://rongchuang.newreadingtech.com/api/v1/saveUserInfo",
filePath: that.avatarUrl,
header: {
"Authorization": 'bearer ' + uni.getStorageSync('token')
},
name: "headimgurl",
formData: {
"nickname": that.name
},
success: (res) => {
const data = JSON.parse(res.data);
console.log('data :>> ', data);
uni.showToast({
url: '保存成功',
mask: true,
complete() {
uni.redirectTo({
url: '/pages/mine/mine'
})
}
})
},
fail: (res) => {
console.log("失败")
}
});