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'
|
||||
})
|
||||
|
||||
// 刷新数据
|
||||
setTimeout(() => {
|
||||
this.loadMatchDetail()
|
||||
}, 1500)
|
||||
// 接口执行成功后刷新当前比赛详情
|
||||
await this.loadMatchDetail()
|
||||
} catch (e) {
|
||||
wx.hideLoading()
|
||||
console.error('响应挑战失败:', e)
|
||||
@ -491,10 +489,8 @@ Page({
|
||||
wx.showToast({ title: '比分已提交,等待对方确认', icon: 'success' })
|
||||
this.closeScoreModal()
|
||||
|
||||
// 刷新数据
|
||||
setTimeout(() => {
|
||||
this.loadMatchDetail()
|
||||
}, 1500)
|
||||
// 接口执行成功后刷新当前比赛详情
|
||||
await this.loadMatchDetail()
|
||||
} catch (e) {
|
||||
wx.hideLoading()
|
||||
console.error('提交比分失败:', e)
|
||||
@ -523,14 +519,13 @@ Page({
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 刷新数据
|
||||
setTimeout(() => {
|
||||
this.loadMatchDetail()
|
||||
}, 1500)
|
||||
// 接口执行成功后刷新当前比赛详情
|
||||
await this.loadMatchDetail()
|
||||
} catch (e) {
|
||||
wx.hideLoading()
|
||||
console.error('确认比分失败:', e)
|
||||
wx.showToast({ title: '操作失败', icon: 'none' })
|
||||
// 显示后端返回的具体错误信息,便于排查
|
||||
wx.showToast({ title: e.message || '操作失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user