diff --git a/config.js b/config.js index 1bf5ad2..59b0622 100644 --- a/config.js +++ b/config.js @@ -26,5 +26,25 @@ module.exports = { tts: { female: { voiceType: 501004, volume: 9, speed: 1 }, male: { voiceType: 502005, volume: 9, speed: 1 } - } + }, + + /** + * 训练中轮换显示的平板支撑姿势要领。每条显示 tipInterval 秒后切换, + * 循环播放,帮助用户持续纠正姿势。增删改这里即可,无需改逻辑代码。 + */ + postureTips: [ + '收紧核心,腰部平直', + '肩膀沉肩,不要耸肩', + '目光看向地面,颈部保持自然中立', + '均匀呼吸,不要憋气', + '臀部与身体成一条直线', + '手肘位于肩正下方', + '腹部收紧,别塌腰', + '双腿伸直略微分开,脚跟后蹬', + '骨盆微微后倾,别翘臀', + '保持稳定,身体不晃' + ], + + /** 姿势要领每条显示的秒数 */ + tipInterval: 10 } diff --git a/pages/timer/timer.js b/pages/timer/timer.js index 433587f..13ea84d 100644 --- a/pages/timer/timer.js +++ b/pages/timer/timer.js @@ -5,7 +5,7 @@ const themeMod = require('../../utils/theme') const iconsMod = require('../../utils/icons') const voice = require('../../utils/voice') const { countUp } = require('../../utils/countUp') - +const config = require('../../config') Page({ data: { theme: { primary: '#FF6B35', primaryLight: '#FF8C5A', primaryBg: '#FFF3ED', primaryRgb: '255,107,53' }, @@ -18,6 +18,7 @@ Page({ isCompleted: false, overtime: 0, goalReached: false, + hintTip: (config.postureTips && config.postureTips[0]) || '', todayTarget: 0, planDay: 1, isFreeMode: false, @@ -96,6 +97,7 @@ Page({ this._lastMinuteAt = 0 this._lastCountdown = 0 this._saving = false + this._lastTipIndex = -1 this._clearVibrateTimers() this._timer = new Timer({ @@ -104,6 +106,7 @@ Page({ remaining: tick.remaining > 0 ? tick.remaining : 0, overtime: tick.remaining <= 0 ? tick.elapsed - this.data.duration : 0 }) + this._updateHintTip(tick) this._remind(tick) }, onGoalReached: () => { @@ -118,6 +121,24 @@ Page({ }) }, + /** + * Rotate the posture cue in the hint area every config.tipInterval seconds. + * Only runs while still under the target (after goalReached the hint + * switches to the "goal reached" line). Skips setData when the index + * hasn't changed to avoid per-second re-renders. + */ + _updateHintTip(tick) { + if (tick.remaining <= 0) return + const tips = config.postureTips || [] + if (tips.length === 0) return + const interval = config.tipInterval || 12 + const idx = Math.floor(tick.elapsed / interval) % tips.length + if (idx !== this._lastTipIndex) { + this._lastTipIndex = idx + this.setData({ hintTip: tips[idx] }) + } + }, + /** * Per-tick reminders: vibration + voice prompts at 4 fixed points. * - halfway: once when elapsed reaches half of duration @@ -431,6 +452,7 @@ Page({ this._last10Signaled = false this._lastMinuteAt = 0 this._lastCountdown = 0 + this._lastTipIndex = -1 this._clearVibrateTimers() this.setData({ showCompletion: false, diff --git a/pages/timer/timer.wxml b/pages/timer/timer.wxml index f4eb3a9..0f47ec4 100644 --- a/pages/timer/timer.wxml +++ b/pages/timer/timer.wxml @@ -67,7 +67,7 @@ - 保持姿势,核心收紧! + {{hintTip}} diff --git a/pages/timer/timer.wxss b/pages/timer/timer.wxss index 6e38461..61caf72 100644 --- a/pages/timer/timer.wxss +++ b/pages/timer/timer.wxss @@ -102,8 +102,8 @@ } .hint-icon { - width: 32rpx; - height: 32rpx; + width: 36rpx; + height: 36rpx; } .running-pulse { @@ -115,7 +115,7 @@ } .hint-text { - font-size: 28rpx; + font-size: 34rpx; color: var(--text-secondary); line-height: 1.3; }