feat(timer): 循环训练组进度改为圆环分段弧 + 信息气泡三行合一

- progress-ring 新增 sets/currentSet/resting/successColor 属性,
  圆环外圈绘制分段弧(已完成=主色/当前=呼吸光点/休息下一组=绿),单组模式零渲染
- timer 删除顶部 circuit-bar 进度面板,布局骨架三模式统一
- 呼吸环淡化(描边 0.55→0.20,柔光渐变强度减半)
- 目标卡与提示气泡合并为 info-bubble,状态文案(撑住/休息中/已暂停)并入气泡顶部
This commit is contained in:
2026-08-12 09:39:41 +08:00
parent 0464eeaba6
commit 05c4763e49
18 changed files with 720 additions and 497 deletions
+1 -49
View File
@@ -19,18 +19,11 @@ Page({
// 空则回退占位(人形图标 + "运动达人"),settings 改完回首页即刷新。
nickName: '',
avatarUrl: '',
// Ring number font size in rpx. WeChat auto-scales text by the user's
// font-size setting (fontSizeScaleFactor) but does NOT scale rpx box
// dimensions — so on a real device with enlarged system font the 84rpx
// number grows past the fixed-size circular ring and gets clipped. We
// cancel that scale here so the number renders at a constant visual size
// (matching the devtools/simulator) on every device. See _readFontScale().
targetTimeFontSize: 96,
streakCount: 0,
planName: '',
planDay: 1,
planTotal: 7,
// hero / 进度地图 / dial 相关展示字段(由 refresh 生成)
// hero / 进度地图 / 时长展示相关字段(由 refresh 生成)
greetText: '你好',
streakText: '今天开启坚持之旅',
questNodes: [],
@@ -52,50 +45,9 @@ Page({
onLoad() {
themeMod.applyThemeToPage(this)
this._readFontScale()
this._firstShow = true
},
/**
* Read the device's WeChat font-size scale and compensate the ring number
* so it never overflows the fixed circular clip on real devices.
*
* WeChat auto-applies `fontSizeScaleFactor` to ALL text (including rpx font
* sizes) but leaves rpx box dimensions untouched. A user who bumps up the
* system font therefore sees enlarged text inside a non-enlarged ring.
*
* CRITICAL asymmetry: the DevTools simulator reports the SAME
* `fontSizeScaleFactor` as a real device (the user's actual WeChat setting)
* but does NOT actually scale rendered text. So if we compensate there, the
* number ends up too small in the simulator. We therefore SKIP the
* compensation under DevTools (host.env === 'devtools') and keep the design
* size — matching what the simulator renders literally.
*
* On real devices, dividing our design size by the factor cancels the
* auto-scale, keeping the number a constant 96rpx-equivalent everywhere.
* Bounded so a bad reading can only ever make the number smaller (safe),
* never larger (overflow).
*/
_readFontScale() {
let factor = 1
try {
const info = wx.getAppBaseInfo ? wx.getAppBaseInfo() : wx.getSystemInfoSync()
const isDevtools = info.host && info.host.env === 'devtools'
if (!isDevtools) {
if (typeof info.fontSizeScaleFactor === 'number' && info.fontSizeScaleFactor > 0) {
factor = info.fontSizeScaleFactor
} else if (typeof info.fontSizeSetting === 'number' && info.fontSizeSetting > 0) {
// fontSizeScaleFactor == currentFontSize / standardFontSize(17px)
factor = info.fontSizeSetting / 17
}
}
} catch (e) {}
const DESIGN = 96
let size = Math.round(DESIGN / factor)
size = Math.max(48, Math.min(96, size))
this.setData({ targetTimeFontSize: size })
},
onShow() {
themeMod.applyThemeToPage(this)
try {
+4 -6
View File
@@ -1,4 +1,4 @@
<view class="container page-enter" style="{{themeStyle}}">
<view class="container page-enter index-page" style="{{themeStyle}}">
<!-- 全宽渐变头图 hero -->
<view class="hero">
@@ -37,12 +37,10 @@
<text class="quest-tip">{{questTip}}</text>
</ui-card>
<!-- 计时环 dial -->
<!-- 今日目标时长(无圆环, 大字流光时间) -->
<view class="timer-wrap">
<view class="dial">
<text class="dial-time" style="font-size: {{targetTimeFontSize}}rpx;">{{todayTargetText}}</text>
<text class="dial-label">今日目标时长</text>
</view>
<text class="time-display">{{todayTargetText}}</text>
<text class="time-label">今日目标时长</text>
<view class="benefit">⚡ 预计消耗 <text class="benefit-hl">{{estKcal}}</text> 千卡</view>
</view>
+34 -43
View File
@@ -3,6 +3,14 @@
底部留大内边距给下方 quest-card 负 margin 上浮叠住。文字统一白色,图标用
*White 变体(若有)。hero 用 opacity-only 动画,避免 transform 把 .container
变成 containing block 而破坏弹窗定位(同 app.wxss pageIn 思路)。 */
/* index-page:仅本页面把 .container 升级为 flex 列,
时钟区 flex:1 居中,操作按钮 margin-top:auto 贴底(不动全局 container)。 */
.index-page {
display: flex;
flex-direction: column;
}
.hero {
margin: -24rpx -24rpx 0;
padding: 24rpx 24rpx 72rpx;
@@ -199,57 +207,41 @@
100% { box-shadow: 0 0 0 4rpx rgba(var(--primary-rgb), 0); }
}
/* ===== 计时环 dial ===== */
/* ===== 今日目标时长(无圆环, 大字流光) =====
在 index-page 这条 flex 列里 .timer-wrap 充当"中间时钟区":flex:1 占满
hero+quest 与底部按钮之间的剩余高度,内部再垂直居中把"00:30 / 今日目标
时长 / 预计消耗 千卡"这组文字真正落到屏幕中部(原来只是默认排在卡片下方) */
.timer-wrap {
text-align: center;
margin: 32rpx 0 8rpx;
}
.dial {
width: 320rpx;
height: 320rpx;
border-radius: 50%;
margin: 0 auto;
position: relative;
background: radial-gradient(circle at 35% 30%, #ffffff, #f4f6f2 70%);
box-shadow: inset 0 4rpx 14rpx rgba(var(--primary-rgb), 0.12), 0 10rpx 24rpx rgba(var(--primary-rgb), 0.12);
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
animation: ringBreathe 3s ease-in-out infinite;
}
/* 虚线刻度环 */
.dial::before {
content: '';
position: absolute;
inset: 14rpx;
border-radius: 50%;
border: 2rpx dashed rgba(var(--primary-rgb), 0.28);
}
.dial-time {
font-size: 84rpx;
font-weight: 800;
color: var(--primary);
font-variant-numeric: tabular-nums;
letter-spacing: -1rpx;
line-height: 1;
max-width: 280rpx;
text-align: center;
white-space: nowrap;
overflow: hidden;
min-height: 0;
}
.dial-label {
font-size: 24rpx;
.time-display {
display: block;
font-family: 'Saira Condensed', 'Arial Narrow', sans-serif;
font-size: 200rpx;
font-weight: 900;
line-height: 1.1;
letter-spacing: 6rpx;
font-variant-numeric: tabular-nums;
color: var(--primary);
text-shadow: 0 8rpx 6rpx rgba(var(--primary-rgb), 0.35);
}
.time-label {
display: block;
font-size: 26rpx;
color: var(--text-secondary);
margin-top: 8rpx;
}
.benefit {
margin-top: 20rpx;
margin-top: 18rpx;
font-size: 28rpx;
color: var(--text-secondary);
}
@@ -260,17 +252,16 @@
font-size: 30rpx;
}
@keyframes ringBreathe {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.02); }
}
/* ===== action buttons ===== */
/* 在 index-page flex 列里,3 个按钮(rechallenge + free + circuit)靠
margin-top:auto 推到列底、紧贴底部 toolbar 上方,与上方居中的时钟
区之间自然留白;gap 保持按钮自身间距不变 */
.action-buttons {
display: flex;
flex-direction: column;
gap: 24rpx;
margin: 8rpx 0 8rpx;
margin-top: auto;
}
/* 自由训练 / 循环训练 并排一行 */