From edd977d5d240b6a191a3eaaf6c6b1113d61b8b26 Mon Sep 17 00:00:00 2001 From: Ethanfly Date: Mon, 9 Feb 2026 17:23:06 +0800 Subject: [PATCH] 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. --- .../pages/match/challenge-detail/index.js | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/miniprogram/pages/match/challenge-detail/index.js b/miniprogram/pages/match/challenge-detail/index.js index ea88d8b4..7a600d27 100644 --- a/miniprogram/pages/match/challenge-detail/index.js +++ b/miniprogram/pages/match/challenge-detail/index.js @@ -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' }) } },