当前的逻辑是在编辑页面用户选择一个图片作为头像,然后点击返回,返回当“我的”页面,如果未刷新“我的页面”,那用户头像的位置依然显示更改之前的头像
- “编辑”页面
- “我的”页面
- 点击“头像”的方法
avatorClick() {
const app = getApp()
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: res => {
const tempFilePaths = res.tempFilePaths
wx.cloud.callFunction({
name: 'handleYunMusicUserInfo',
data: {
type: "update",
avatarUrl: tempFilePaths
}
}).then(res => {
this.onLoad()
// !!!!!!!!!
// 获取当前页面
const pages = getCurrentPages();
// 获取上一级页面
const beforePage = pages[pages.length - 2];
// 调用上一级页面的onLoad方法进行刷新
beforePage.onLoad()
}).catch(() => {
app.catchErr()
})
}
})
},