Files
fitness-coach/miniprogram/pages/plan-detail/plan-detail.wxml
wm 54a5ae858d fix(plan-detail): 增加加载/错误/重试/未找到四态,杜绝静默空白
- 此前详情页请求失败时仅 setData(loading:false),plan 仍为 null,
  整页只显示一行小字,用户感知为「空白」且无法定位原因。
- 现明确区分 loading / error(带重试按钮) / not-found 三种空态;
  request 失败时按 statusCode 给具体提示(401 登录失效 / 404 未找到 / 其他网络错误)。
- onLoad 对 getApp().globalData 取值加防御;缺失 id 直接报错不发起请求。
2026-07-22 23:58:48 +08:00

46 lines
2.3 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}};"><fc-icon name="{{plan.icon}}" size="48" color="{{plan.color}}" /></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"><fc-icon name="dumbbell" size="64" color="var(--text-3)" /></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 wx:if="{{loading}}" class="empty">加载中…</view>
<view wx:elif="{{error}}" class="empty-box">
<view class="empty-box__emoji"><fc-icon name="alert-circle" size="64" color="var(--text-3)" /></view>
<view class="empty-box__t">{{errorMsg || '加载失败'}}</view>
<view class="empty-box__btn" bindtap="onRetry">重试</view>
</view>
<view wx:else class="empty">未找到该计划</view>
</view>