refactor: Simplify match detail refresh logic and improve error handling
- Replaced setTimeout with direct await calls to loadMatchDetail after successful API responses, ensuring immediate data refresh. - Enhanced error handling by displaying specific backend error messages in toast notifications for better user feedback.
This commit is contained in:
parent
7a98070af6
commit
edd977d5d2
@ -405,10 +405,8 @@ Page({
|
|||||||
icon: 'success'
|
icon: 'success'
|
||||||
})
|
})
|
||||||
|
|
||||||
// 刷新数据
|
// 接口执行成功后刷新当前比赛详情
|
||||||
setTimeout(() => {
|
await this.loadMatchDetail()
|
||||||
this.loadMatchDetail()
|
|
||||||
}, 1500)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
console.error('响应挑战失败:', e)
|
console.error('响应挑战失败:', e)
|
||||||
@ -491,10 +489,8 @@ Page({
|
|||||||
wx.showToast({ title: '比分已提交,等待对方确认', icon: 'success' })
|
wx.showToast({ title: '比分已提交,等待对方确认', icon: 'success' })
|
||||||
this.closeScoreModal()
|
this.closeScoreModal()
|
||||||
|
|
||||||
// 刷新数据
|
// 接口执行成功后刷新当前比赛详情
|
||||||
setTimeout(() => {
|
await this.loadMatchDetail()
|
||||||
this.loadMatchDetail()
|
|
||||||
}, 1500)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
console.error('提交比分失败:', e)
|
console.error('提交比分失败:', e)
|
||||||
@ -523,14 +519,13 @@ Page({
|
|||||||
icon: 'success'
|
icon: 'success'
|
||||||
})
|
})
|
||||||
|
|
||||||
// 刷新数据
|
// 接口执行成功后刷新当前比赛详情
|
||||||
setTimeout(() => {
|
await this.loadMatchDetail()
|
||||||
this.loadMatchDetail()
|
|
||||||
}, 1500)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
console.error('确认比分失败:', e)
|
console.error('确认比分失败:', e)
|
||||||
wx.showToast({ title: '操作失败', icon: 'none' })
|
// 显示后端返回的具体错误信息,便于排查
|
||||||
|
wx.showToast({ title: e.message || '操作失败', icon: 'none' })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user