|
@@ -71,21 +71,33 @@ Component({
|
|
|
// this.setData({
|
|
// this.setData({
|
|
|
// avatarUrl: avatarUrl,
|
|
// avatarUrl: avatarUrl,
|
|
|
// })
|
|
// })
|
|
|
-
|
|
|
|
|
|
|
+ // wx.showToast({ title: "进来了" })
|
|
|
const that = this;
|
|
const that = this;
|
|
|
|
|
|
|
|
this.setData({ tempAvatarUrl: avatarUrl });
|
|
this.setData({ tempAvatarUrl: avatarUrl });
|
|
|
- // 下载头像图片
|
|
|
|
|
- wx.downloadFile({
|
|
|
|
|
- url: avatarUrl,
|
|
|
|
|
- success(res) {
|
|
|
|
|
- if (res.statusCode === 200) {
|
|
|
|
|
- console.log('download success');
|
|
|
|
|
- const tempFilePath = res.tempFilePath
|
|
|
|
|
- that.uploadAvatar(tempFilePath);
|
|
|
|
|
|
|
+ if (avatarUrl.includes("wxfile://")) {
|
|
|
|
|
+ that.uploadAvatar(avatarUrl);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 下载头像图片
|
|
|
|
|
+ wx.downloadFile({
|
|
|
|
|
+ url: avatarUrl,
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ if (res.statusCode === 200) {
|
|
|
|
|
+ console.log('download success');
|
|
|
|
|
+ const tempFilePath = res.tempFilePath
|
|
|
|
|
+ that.uploadAvatar(tempFilePath);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wx.showToast({ title: '上传失败' })
|
|
|
|
|
+ // wx.showToast({ title: JSON.stringify(res) })
|
|
|
|
|
+ // wx.showToast({ title: JSON.stringify(avatarUrl) })
|
|
|
|
|
+ }
|
|
|
|
|
+ }, fail: function (err) {
|
|
|
|
|
+ wx.showToast({ title: '上传失败' })
|
|
|
|
|
+ // wx.showToast({ title: JSON.stringify(err) })
|
|
|
|
|
+ // wx.showToast({ title: JSON.stringify(avatarUrl) })
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
this.checkHasUserInfo();
|
|
this.checkHasUserInfo();
|
|
|
},
|
|
},
|
|
|
|
|
|