Files
fitness-coach/miniprogram/pages/plan-detail/plan-detail.wxml
wm 06bd96a473 fix: 修复动作卡片点击双触发导致跳 404
- 8 个页面 exercise-card 由 bind:tap 改为 catch:tap,拦截原生 tap 冒泡
  避免一次点击被『自定义事件 + 原生冒泡』触发两次,
  第二次 e.detail 无 id → navigateTo detail?id=undefined → 404
- 所有 onExercise 顶部加 id 守卫,无 id 直接 return
- exercise-card 点击前校验 exercise.id,缺失不触发
- detail onLoad 的 id 为空时直接显示空态,不再发起错误请求
2026-07-22 15:30:28 +08:00

40 lines
1.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<view class="page" wx:if="{{plan}}">
<navbar title="{{plan.name}}" show-back />
<view class="header" style="background: linear-gradient(135deg, {{plan.color}}26, var(--surface));">
<view class="header__emoji" style="background: {{plan.color}}22; color: {{plan.color}};">{{plan.emoji}}</view>
<view class="header__name" style="color: {{plan.color}};">{{plan.name}}</view>
<view wx:if="{{plan.description}}" class="header__desc">{{plan.description}}</view>
<view class="header__meta">共 {{exercises.length}} 个动作<text wx:if="{{plan.updatedAtText}}"> · 更新于 {{plan.updatedAtText}}</text></view>
</view>
<view class="section" style="padding-top: 8rpx;">
<section-header eyebrow="EXERCISES" title="动作列表" subtitle="点击查看详情 · 可在动作页加入本计划" />
<view class="list" wx:if="{{exercises.length}}">
<view class="list__item" wx:for="{{exercises}}" wx:key="id">
<view class="list__card">
<exercise-card exercise="{{item}}" catch:tap="onExercise" />
</view>
<view class="list__remove" data-id="{{item.id}}" catchtap="onRemoveExercise">移除</view>
</view>
</view>
<view wx:elif="{{!loading}}" class="empty-box">
<view class="empty-box__emoji">🏋️</view>
<view class="empty-box__t">这个计划还没有动作,去添加吧</view>
<view class="empty-box__btn" bindtap="onAdd"> 添加动作</view>
</view>
<view wx:else class="empty">加载中…</view>
</view>
<view class="actionbar">
<view class="btn btn--gold" bindtap="onAdd"> 添加动作</view>
<view class="btn btn--ghost" bindtap="onEdit">编辑</view>
<view class="btn btn--del" bindtap="onDelete">删除计划</view>
</view>
</view>
<view wx:else class="empty-page">
<view class="empty">{{ loading ? '加载中…' : '未找到该计划' }}</view>
</view>