feat(timer): 训练超时与完成展示优化 (v3.0)
- 超时后圆环底环变绿,中心改显总训练时长(MM:SS 实时涨),移除 +Xs 小徽章 - 完成弹窗成绩由纯秒数改为分秒(如 1分23秒),>=60s 时缩字号防撑破卡片 - 修复结束确认弹窗停留期间计时器未暂停导致训练时长虚增:onStop 暂停、取消恢复、确认取暂停值 - progress-ring 新增 elapsed prop,remaining=0 时中心切显总时长 - 清理废弃的 overtime 字段与 .overtime-badge 样式 - 版本号 v2.9 -> v3.0,更新日期 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+19
-5
@@ -16,7 +16,7 @@ Page({
|
||||
isRunning: false,
|
||||
isPaused: false,
|
||||
isCompleted: false,
|
||||
overtime: 0,
|
||||
elapsed: 0,
|
||||
goalReached: false,
|
||||
hintTip: (config.postureTips && config.postureTips[0]) || '',
|
||||
todayTarget: 0,
|
||||
@@ -82,7 +82,8 @@ Page({
|
||||
todayTarget: target,
|
||||
planDay: isFreeMode ? 0 : planDay,
|
||||
isFreeMode,
|
||||
goalReached: false
|
||||
goalReached: false,
|
||||
elapsed: 0
|
||||
})
|
||||
|
||||
if (this._timer) {
|
||||
@@ -104,7 +105,7 @@ Page({
|
||||
onTick: (tick) => {
|
||||
this.setData({
|
||||
remaining: tick.remaining > 0 ? tick.remaining : 0,
|
||||
overtime: tick.remaining <= 0 ? tick.elapsed - this.data.duration : 0
|
||||
elapsed: tick.elapsed
|
||||
})
|
||||
this._updateHintTip(tick)
|
||||
this._remind(tick)
|
||||
@@ -321,11 +322,24 @@ Page({
|
||||
// 用自定义确认弹窗替代 wx.showModal:
|
||||
// 系统原生 modal 在 WebView stacking context 下 hit-test 偶发不稳,
|
||||
// 自定义 modal + catchtouchmove 与现有 completion-mask 同模式,行为更可靠。
|
||||
this.setData({ showStopConfirm: true })
|
||||
// 弹窗停留期间暂停计时,避免犹豫时间被计入训练时长
|
||||
this._stopWasPaused = this.data.isPaused
|
||||
const patch = { showStopConfirm: true }
|
||||
if (this.data.isRunning && !this.data.isPaused) {
|
||||
this._timer.pause()
|
||||
patch.isPaused = true
|
||||
patch.status = 'paused'
|
||||
}
|
||||
this.setData(patch)
|
||||
},
|
||||
|
||||
onStopCancel() {
|
||||
this.setData({ showStopConfirm: false })
|
||||
// 弹窗前若正在计时(被 onStop 暂停),取消后恢复
|
||||
if (!this._stopWasPaused && this.data.isRunning) {
|
||||
this._timer.resume()
|
||||
this.setData({ isRunning: true, isPaused: false, status: 'running' })
|
||||
}
|
||||
},
|
||||
|
||||
onStopConfirm() {
|
||||
@@ -462,7 +476,7 @@ Page({
|
||||
isRunning: false,
|
||||
isPaused: false,
|
||||
remaining: this.data.duration,
|
||||
overtime: 0,
|
||||
elapsed: 0,
|
||||
goalReached: false
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user