Files
wx_pbzc/pages/timer/timer.wxss
T
lc 326bc013fe fix(timer): 完成页圆环覆盖弹窗 + 自定义确认 modal 替代 wx.showModal
训练完成的三个相关 bug:
1. progress-ring 圆环覆盖完成页弹窗 → @tap ring wx:if 让完成态时直接 unmount
2. 完成弹窗内按钮需要点 2 次才能响应 → completion-mask 加 catchtouchmove 拦截 touchmove
3. wx.showModal "结束训练" 系统弹窗在 stacking context 下 hit-test 不稳

根因: .timer-page.page-enter 永久保留 transform: translateY(0),
创建永久 stacking context,影响 native modal 的 WebView 部分 hit-test。

修法:
- 新增自定义 stop-confirm modal (catchtouchmove + 内部 catchtap + bindtap),
  与 ui-modal/settings.plan-editor-mask 同模式,行为可靠
- completion-mask 用相同模式拦截 touchmove
- 顺便修 overtime-badge 暗色 (rgba(var(--success-rgb)))
2026-07-08 15:21:46 +08:00

477 lines
10 KiB
Plaintext

.timer-page {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding-top: 80rpx;
padding-bottom: calc(170rpx + env(safe-area-inset-bottom));
min-height: 100vh;
box-sizing: border-box;
}
/* ---- ring wrapper ---- */
.ring-wrapper {
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
/* breathing guide rings — three concentric layers */
.breathe-ring {
position: absolute;
border-radius: 50%;
border: 3rpx solid rgba(var(--primary-rgb), 0.15);
animation: breathePulse 3.5s ease-in-out infinite;
pointer-events: none;
z-index: 0;
}
.breathe-ring-1 { width: 480rpx; height: 480rpx; animation-delay: 0s; }
.breathe-ring-2 { width: 400rpx; height: 400rpx; animation-delay: 0.5s; border-color: rgba(var(--primary-rgb), 0.25); border-width: 4rpx; }
.breathe-ring-3 { width: 320rpx; height: 320rpx; animation-delay: 1s; border-color: rgba(var(--primary-rgb), 0.35); border-width: 5rpx; }
.breathe-ring.fast { animation: breathePulseFast 1.4s ease-in-out infinite; }
.breathe-ring.fast.breathe-ring-1 { animation-delay: 0s; border-color: rgba(var(--primary-rgb), 0.3); }
.breathe-ring.fast.breathe-ring-2 { animation-delay: 0.25s; border-color: rgba(var(--primary-rgb), 0.45); }
.breathe-ring.fast.breathe-ring-3 { animation-delay: 0.5s; border-color: rgba(var(--primary-rgb), 0.6); }
/* celebration burst */
.celebrate-burst {
position: absolute;
width: 520rpx;
height: 520rpx;
pointer-events: none;
z-index: 2;
}
.spark {
position: absolute;
font-size: 36rpx;
animation: sparkBurst 1s ease-out forwards;
}
.s1 { top: -10rpx; left: 50%; margin-left: -18rpx; animation-delay: 0s; }
.s2 { top: 30rpx; right: -10rpx; animation-delay: 0.1s; }
.s3 { bottom: -10rpx; right: 50rpx; animation-delay: 0.2s; }
.s4 { bottom: 20rpx; left: 30rpx; animation-delay: 0.15s; }
.s5 { top: 50%; right: -20rpx; animation-delay: 0.25s; }
.s6 { top: -20rpx; left: 40rpx; animation-delay: 0.05s; }
@keyframes sparkBurst {
0% { opacity: 0; transform: translate(0, 0) scale(0.3); }
40% { opacity: 1; transform: translate(0, -30rpx) scale(1.3); }
100% { opacity: 0; transform: translate(0, -80rpx) scale(0.4); }
}
/* overtime badge */
.overtime-badge {
position: absolute;
bottom: 10rpx;
left: 50%;
transform: translateX(-50%);
background: rgba(var(--success-rgb), 0.12);
border: 2rpx solid rgba(var(--success-rgb), 0.3);
color: var(--success);
padding: 8rpx 24rpx;
border-radius: 24rpx;
font-size: 28rpx;
font-weight: 600;
display: flex;
align-items: center;
gap: 6rpx;
animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.overtime-icon {
width: 28rpx;
height: 28rpx;
}
/* ---- hint section ---- */
.hint-section {
margin-top: 36rpx;
text-align: center;
}
.hint-row {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 10rpx;
}
.hint-icon {
width: 32rpx;
height: 32rpx;
}
.running-pulse {
animation: float 1.5s ease-in-out infinite;
}
.completed-bounce {
animation: bounceSoft 0.6s ease infinite;
}
.hint-text {
font-size: 28rpx;
color: var(--text-secondary);
line-height: 1.3;
}
.hint-text.running { color: var(--primary); font-weight: 600; }
.hint-text.paused { color: var(--primary-light); }
.hint-text.completed { color: var(--success); font-weight: 600; }
.completed-hint { animation: popIn 0.5s ease; }
/* ---- controls ---- */
.controls {
margin-top: 60rpx;
width: 100%;
display: flex;
justify-content: center;
}
.ctrl-row {
display: flex;
justify-content: center;
align-items: center;
}
/* ---- full-screen confetti ---- */
.confetti {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
pointer-events: none;
z-index: 9999;
overflow: hidden;
}
.confetti-piece {
position: absolute;
top: -20rpx;
border-radius: 4rpx;
animation: confettiFall 2.4s ease-out forwards;
}
/* Higher celebration levels: faster / longer fall */
.confetti-piece--milestone,
.confetti-piece--first,
.confetti-piece--record {
animation-duration: 3.2s;
}
.confetti-piece--first {
animation-duration: 4s;
}
@keyframes confettiFall {
0% { opacity: 1; transform: translateY(0) rotate(0deg); }
100% { opacity: 0.6; transform: translateY(100vh) rotate(720deg); }
}
/* ---- achievement banner ---- */
.achievement-banner {
position: fixed;
top: 160rpx;
left: 50%;
transform: translateX(-50%);
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: #FFFFFF;
font-size: 32rpx;
font-weight: 700;
padding: 24rpx 48rpx;
border-radius: 48rpx;
box-shadow: 0 8rpx 24rpx rgba(var(--primary-rgb), 0.4);
z-index: 10000;
animation: achievementIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both,
achievementOut 0.4s ease-in 3.5s both;
white-space: nowrap;
}
.achievement-text {
display: block;
line-height: 1;
}
@keyframes achievementIn {
0% { opacity: 0; transform: translateX(-50%) scale(0.5); }
100% { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes achievementOut {
0% { opacity: 1; transform: translateX(-50%) scale(1); }
100% { opacity: 0; transform: translateX(-50%) scale(0.8); }
}
/* ---- completion modal (full-screen summary after training ends) ---- */
.completion-mask {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.55);
z-index: 10000;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
box-sizing: border-box;
animation: completionMaskIn 0.3s ease;
}
@keyframes completionMaskIn {
from { opacity: 0; }
to { opacity: 1; }
}
.completion-card {
width: 100%;
max-width: 640rpx;
background: var(--card-bg);
border-radius: 32rpx;
padding: 56rpx 40rpx 40rpx;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 16rpx 48rpx rgba(0, 0, 0, 0.25);
animation: completionCardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes completionCardIn {
0% { transform: scale(0.6) translateY(40rpx); opacity: 0; }
100% { transform: scale(1) translateY(0); opacity: 1; }
}
.completion-emoji-wrap {
width: 140rpx;
height: 140rpx;
border-radius: 50%;
background: linear-gradient(135deg, var(--primary), var(--primary-light));
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 24rpx;
box-shadow: 0 8rpx 24rpx rgba(var(--primary-rgb), 0.4);
animation: completionEmojiPulse 1.6s ease-in-out infinite;
}
@keyframes completionEmojiPulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.08); }
}
.completion-emoji {
font-size: 80rpx;
line-height: 1;
}
.completion-title {
font-size: 32rpx;
font-weight: 600;
color: var(--text);
margin-bottom: 32rpx;
text-align: center;
}
.completion-number-wrap {
display: flex;
align-items: baseline;
justify-content: center;
margin-bottom: 8rpx;
}
.completion-number {
font-size: 180rpx;
font-weight: 800;
color: var(--primary);
line-height: 1;
font-variant-numeric: tabular-nums;
letter-spacing: -4rpx;
text-shadow: 0 4rpx 12rpx rgba(var(--primary-rgb), 0.2);
}
.completion-unit {
font-size: 36rpx;
font-weight: 600;
color: var(--text-secondary);
margin-left: 8rpx;
}
.completion-label {
font-size: 26rpx;
color: var(--text-secondary);
margin-bottom: 24rpx;
}
.completion-overtime {
display: flex;
align-items: baseline;
gap: 6rpx;
background: rgba(var(--primary-rgb), 0.12);
padding: 12rpx 24rpx;
border-radius: 32rpx;
margin-bottom: 16rpx;
animation: overtimePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 1.1s both;
}
@keyframes overtimePop {
0% { transform: scale(0); opacity: 0; }
100% { transform: scale(1); opacity: 1; }
}
.overtime-plus {
font-size: 32rpx;
font-weight: 700;
color: var(--primary);
line-height: 1;
}
.overtime-label {
font-size: 24rpx;
color: var(--primary);
font-weight: 500;
}
.completion-streak {
display: flex;
align-items: center;
gap: 8rpx;
margin-bottom: 36rpx;
font-size: 26rpx;
color: var(--text);
}
.streak-flame {
font-size: 32rpx;
}
.streak-text {
font-weight: 500;
}
.completion-actions {
display: flex;
gap: 20rpx;
width: 100%;
margin-bottom: 12rpx;
}
.completion-btn {
flex: 1;
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 44rpx;
font-size: 30rpx;
font-weight: 600;
transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
background: var(--bg-soft);
color: var(--text);
}
.completion-btn:active {
transform: scale(0.96);
opacity: 0.85;
}
.completion-btn--primary {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: #FFFFFF;
box-shadow: 0 8rpx 20rpx rgba(var(--primary-rgb), 0.3);
}
.completion-btn--text {
background: transparent;
color: var(--text-secondary);
font-weight: 500;
height: 64rpx;
font-size: 26rpx;
margin-top: 4rpx;
}
/* ---- stop confirm modal (替代 wx.showModal,自定义实现) ---- */
.stop-confirm-mask {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.55);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
box-sizing: border-box;
animation: completionMaskIn 0.25s ease;
}
.stop-confirm-card {
width: 100%;
max-width: 560rpx;
background: var(--card-bg);
border-radius: 24rpx;
padding: 48rpx 40rpx 24rpx;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 12rpx 36rpx rgba(0, 0, 0, 0.22);
animation: stopConfirmPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes stopConfirmPop {
0% { transform: scale(0.85); opacity: 0; }
100% { transform: scale(1); opacity: 1; }
}
.stop-confirm-title {
font-size: 32rpx;
font-weight: 700;
color: var(--text);
margin-bottom: 20rpx;
line-height: 1.3;
}
.stop-confirm-content {
font-size: 28rpx;
color: var(--text-secondary);
line-height: 1.5;
text-align: center;
margin-bottom: 40rpx;
}
.stop-confirm-actions {
display: flex;
width: 100%;
gap: 16rpx;
border-top: 1rpx solid var(--border);
padding-top: 24rpx;
}
.stop-confirm-btn {
flex: 1;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: 600;
border-radius: 12rpx;
background: var(--bg-soft);
color: var(--text);
transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
}
.stop-confirm-btn:active {
transform: scale(0.96);
opacity: 0.85;
}
.stop-confirm-btn--primary {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: #FFFFFF;
box-shadow: 0 6rpx 16rpx rgba(var(--primary-rgb), 0.3);
}