feat(timer): 训练页改版 hero 风格 + 进度环刻度 + 醒目姿态提示气泡
- progress-ring: canvas 新增秒刻度层(四分位加粗), 环内加 subText, 移除组件内 statusText - timer.wxml: 环下方状态词 + 目标信息卡(今日目标·第N天›静态箭头) + 运行提示; 进度环传 ticks/subText - timer.js: 派生 ringTicks/ringSubText/statusText/goalLine/runningTip/tipType/tipIcon, 各生命周期计算下发 - timer.wxss: 按钮贴底(flex-start+margin-top:auto), 新增 .timer-status/.goal-card/.timer-tip 气泡卡片(主色左边框+小三角+tipPulse 呼吸), 文字放大加粗 - 姿态提示分语义: posture/phase(主色) / done(成功色), 图标用 peopleFill/successFill - 状态机/计时/循环FSM/呼吸环/彩带/弹窗/语音震动常亮全部保留 - 另含 index 进度地图右上角奖杯图标删除(quest-trophy 样式清理)
This commit is contained in:
+57
-10
@@ -59,6 +59,14 @@ Page({
|
||||
// 完成弹窗科学提示(config.scienceTips 按本次时长选段)
|
||||
completionTipValue: '',
|
||||
completionTipRisk: '',
|
||||
// --- 计时页改版派生字段(状态文案 / 目标信息卡 / 环刻度 / 环内副标题) ---
|
||||
ringTicks: 0,
|
||||
ringSubText: '',
|
||||
statusText: '准备开始',
|
||||
goalLine: '',
|
||||
runningTip: '',
|
||||
tipType: 'posture',
|
||||
tipIcon: '',
|
||||
icons: iconsMod.build()
|
||||
},
|
||||
|
||||
@@ -120,6 +128,7 @@ Page({
|
||||
target = planMod.getTodayTarget(settings.planId, Math.min(planDay, plan.totalDays), customPlans)
|
||||
}
|
||||
|
||||
const durText = this._durationText(target)
|
||||
this.setData({
|
||||
duration: target,
|
||||
remaining: target,
|
||||
@@ -127,7 +136,14 @@ Page({
|
||||
planDay: isFreeMode ? 0 : planDay,
|
||||
isFreeMode,
|
||||
goalReached: false,
|
||||
elapsed: 0
|
||||
elapsed: 0,
|
||||
goalLine: isFreeMode ? `自由训练 · 目标 ${durText}` : `今日目标 ${durText} · 第 ${planDay} 天`,
|
||||
ringTicks: Math.min(target, 60),
|
||||
ringSubText: `目标 ${durText}`,
|
||||
statusText: '准备开始',
|
||||
runningTip: '',
|
||||
tipType: 'posture',
|
||||
tipIcon: this.data.icons.peopleFill
|
||||
})
|
||||
|
||||
if (this._timer) {
|
||||
@@ -149,7 +165,10 @@ Page({
|
||||
onTick: (tick) => {
|
||||
this.setData({
|
||||
remaining: tick.remaining > 0 ? tick.remaining : 0,
|
||||
elapsed: tick.elapsed
|
||||
elapsed: tick.elapsed,
|
||||
runningTip: this.data.goalReached ? '目标达成,继续挑战!' : this.data.hintTip,
|
||||
tipType: this.data.goalReached ? 'done' : 'posture',
|
||||
tipIcon: this.data.goalReached ? this.data.icons.successFill : this.data.icons.peopleFill
|
||||
})
|
||||
this._updateHintTip(tick)
|
||||
this._remind(tick)
|
||||
@@ -161,7 +180,7 @@ Page({
|
||||
if (s.voiceGuide !== false) {
|
||||
voice.play('goal')
|
||||
}
|
||||
this.setData({ goalReached: true })
|
||||
this.setData({ goalReached: true, runningTip: '目标达成,继续挑战!', tipType: 'done', tipIcon: this.data.icons.successFill })
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -221,7 +240,11 @@ Page({
|
||||
// number keep working: the ring shows the CURRENT set's countdown.
|
||||
remaining: t.phaseRemaining,
|
||||
elapsed: t.workTotal,
|
||||
duration: t.phase === 'working' ? hold : rest
|
||||
duration: t.phase === 'working' ? hold : rest,
|
||||
statusText: resting ? '休息中' : '撑住',
|
||||
runningTip: resting ? '' : this.data.phaseTip,
|
||||
tipType: 'phase',
|
||||
tipIcon: this.data.icons.peopleFill
|
||||
})
|
||||
this._circuitCue(t)
|
||||
},
|
||||
@@ -236,6 +259,7 @@ Page({
|
||||
for (let i = 1; i <= sets; i++) dots.push(i)
|
||||
}
|
||||
|
||||
const durText = this._durationText(hold)
|
||||
this.setData({
|
||||
isCircuitMode: true,
|
||||
isFreeMode: false,
|
||||
@@ -267,7 +291,14 @@ Page({
|
||||
isRunning: false,
|
||||
isPaused: false,
|
||||
isCompleted: false,
|
||||
showCompletion: false
|
||||
showCompletion: false,
|
||||
goalLine: `每组 ${durText} · 共 ${sets} 组`,
|
||||
ringTicks: Math.min(hold, 60),
|
||||
ringSubText: `每组 ${durText}`,
|
||||
statusText: '准备开始',
|
||||
runningTip: '',
|
||||
tipType: 'posture',
|
||||
tipIcon: this.data.icons.peopleFill
|
||||
})
|
||||
},
|
||||
|
||||
@@ -277,6 +308,18 @@ Page({
|
||||
return Math.max(min, Math.min(max, n))
|
||||
},
|
||||
|
||||
/**
|
||||
* 把秒数转成口语化时长文本:45 -> "45秒", 90 -> "1分30", 120 -> "2分钟"。
|
||||
* 用于目标信息卡与环内副标题,比 MM:SS 更贴近自然语言。
|
||||
*/
|
||||
_durationText(sec) {
|
||||
const s = Math.floor(sec || 0)
|
||||
if (s < 60) return s + '秒'
|
||||
const m = Math.floor(s / 60)
|
||||
const rem = s % 60
|
||||
return rem === 0 ? m + '分钟' : m + '分' + rem
|
||||
},
|
||||
|
||||
/**
|
||||
* Fire a haptic buzz, tracked so pause/stop/unload can cancel pending ones.
|
||||
* Mirrors the vibrate helper inside _remind().
|
||||
@@ -624,7 +667,7 @@ Page({
|
||||
// Re-assert: if the user backgrounded the app while paused, WeChat has
|
||||
// already cleared the flag for us.
|
||||
this._keepScreenOn(true)
|
||||
this.setData({ isRunning: true, isPaused: false, status: 'running' })
|
||||
this.setData({ isRunning: true, isPaused: false, status: 'running', statusText: '撑住', runningTip: '' })
|
||||
return
|
||||
}
|
||||
if (this.data.isRunning) return
|
||||
@@ -640,7 +683,7 @@ Page({
|
||||
this.setData({ remaining: this.data.duration })
|
||||
}
|
||||
this._timer.start(this.data.duration)
|
||||
this.setData({ isRunning: true, status: 'running' })
|
||||
this.setData({ isRunning: true, status: 'running', statusText: '撑住', runningTip: '' })
|
||||
const s = storage.getSettings()
|
||||
if (s.voiceGuide !== false) voice.play('start')
|
||||
},
|
||||
@@ -650,7 +693,7 @@ Page({
|
||||
this._timer.pause()
|
||||
voice.stop()
|
||||
this._clearVibrateTimers()
|
||||
this.setData({ isPaused: true, status: 'paused' })
|
||||
this.setData({ isPaused: true, status: 'paused', statusText: '已暂停', runningTip: '' })
|
||||
},
|
||||
|
||||
onStop() {
|
||||
@@ -673,7 +716,7 @@ Page({
|
||||
// 弹窗前若正在计时(被 onStop 暂停),取消后恢复
|
||||
if (!this._stopWasPaused && this.data.isRunning) {
|
||||
this._timer.resume()
|
||||
this.setData({ isRunning: true, isPaused: false, status: 'running' })
|
||||
this.setData({ isRunning: true, isPaused: false, status: 'running', statusText: '撑住', runningTip: '' })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -855,7 +898,11 @@ Page({
|
||||
isPaused: false,
|
||||
remaining: this.data.duration,
|
||||
elapsed: 0,
|
||||
goalReached: false
|
||||
goalReached: false,
|
||||
statusText: '准备开始',
|
||||
runningTip: '',
|
||||
tipType: 'posture',
|
||||
tipIcon: this.data.icons.peopleFill
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user