list.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="list-container" :style="{ '--font-scale': fontScale }">
  3. <!-- 加载状态 -->
  4. <view class="loading-wrap" v-if="loading">
  5. <text class="loading-text">加载中...</text>
  6. </view>
  7. <!-- 方案列表 -->
  8. <view class="plan-list" v-else-if="plans.length > 0">
  9. <view
  10. class="plan-card"
  11. v-for="item in plans"
  12. :key="item.id"
  13. @click="goToDetail(item.id)"
  14. >
  15. <view class="plan-card-top">
  16. <text class="plan-name">{{ item.name || '测评方案' }}</text>
  17. <text class="plan-status" :class="'status-' + (item.status || 'unknown')">{{ statusLabel(item.status) }}</text>
  18. </view>
  19. <view class="plan-meta" v-if="item.startDate || item.endDate">
  20. <text class="plan-meta-item">周期:{{ formatDate(item.startDate) }} ~ {{ formatDate(item.endDate) }}</text>
  21. </view>
  22. <view class="plan-progress" v-if="item.totalDays">
  23. <view class="progress-track">
  24. <view class="progress-fill" :style="'width:' + progressPercent(item) + '%'"></view>
  25. </view>
  26. <text class="progress-text">{{ item.completedDays || 0 }} / {{ item.totalDays }} 天</text>
  27. </view>
  28. <view class="plan-arrow">›</view>
  29. </view>
  30. </view>
  31. <!-- 空状态 -->
  32. <view class="empty-wrap" v-else>
  33. <text class="empty-icon">📋</text>
  34. <text class="empty-title">暂无测评方案</text>
  35. <text class="empty-desc">上传健康报告后,系统将自动为您生成个性化测评方案</text>
  36. </view>
  37. <!-- 底部占位 -->
  38. <view class="bottom-spacer"></view>
  39. </view>
  40. </template>
  41. <script>
  42. import { getMyAssessmentPlans } from '../../utils/api.js'
  43. import { parseDate } from '../../utils/format.js'
  44. import fontScaleMixin from '@/mixins/font-scale.js'
  45. export default {
  46. mixins: [fontScaleMixin],
  47. data() {
  48. return {
  49. plans: [],
  50. loading: false,
  51. familyId: null,
  52. childId: null
  53. }
  54. },
  55. onLoad(options) {
  56. this.familyId = options.familyId ? parseInt(options.familyId) : null
  57. this.childId = options.childId ? parseInt(options.childId) : null
  58. this.loadData()
  59. },
  60. methods: {
  61. loadData() {
  62. var self = this
  63. var familyId = this.familyId || uni.getStorageSync('familyId')
  64. if (!familyId) {
  65. uni.showToast({ title: '请先选择家庭', icon: 'none' })
  66. return
  67. }
  68. self.loading = true
  69. getMyAssessmentPlans(familyId, this.childId).then(function(res) {
  70. if (res.code === 200) {
  71. self.plans = res.data || []
  72. } else {
  73. uni.showToast({ title: res.message || '加载失败', icon: 'none' })
  74. }
  75. }).catch(function(e) {
  76. console.log('获取测评方案失败', e)
  77. uni.showToast({ title: '加载失败', icon: 'none' })
  78. }).finally(function() {
  79. self.loading = false
  80. })
  81. },
  82. goToDetail(planId) {
  83. uni.navigateTo({ url: '/pages/assessment-plan/detail?planId=' + planId })
  84. },
  85. statusLabel(status) {
  86. var map = { active: '进行中', completed: '已完成', cancelled: '已取消', generated: '待审核', reviewed: '已通过', rejected: '已驳回' }
  87. return map[status] || (status || '未知')
  88. },
  89. progressPercent(item) {
  90. if (!item.totalDays) return 0
  91. var completed = item.completedDays || 0
  92. var p = Math.round(completed / item.totalDays * 100)
  93. return p > 100 ? 100 : p
  94. },
  95. formatDate(dateStr) {
  96. if (!dateStr) return '--'
  97. var d = parseDate(dateStr)
  98. if (!d) return dateStr
  99. var y = d.getFullYear()
  100. var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
  101. var day = ('' + d.getDate()).padStart(2, '0')
  102. return y + '-' + m + '-' + day
  103. }
  104. }
  105. }
  106. </script>
  107. <style scoped lang="scss">
  108. .list-container {
  109. min-height: 100vh;
  110. background: $app-bg;
  111. }
  112. /* ===== 加载状态 ===== */
  113. .loading-wrap {
  114. display: flex;
  115. justify-content: center;
  116. padding: 80rpx 0;
  117. }
  118. .loading-text {
  119. font-size: calc(28rpx * var(--font-scale, 1));
  120. color: $facade-text-muted;
  121. }
  122. /* ===== 方案列表 ===== */
  123. .plan-list {
  124. margin: 20rpx $uni-space-lg;
  125. }
  126. .plan-card {
  127. background: $app-surface;
  128. border-radius: 16rpx;
  129. padding: 28rpx 24rpx;
  130. margin-bottom: 16rpx;
  131. position: relative;
  132. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  133. }
  134. .plan-card:active {
  135. opacity: 0.8;
  136. }
  137. .plan-card-top {
  138. display: flex;
  139. flex-direction: row;
  140. align-items: center;
  141. justify-content: space-between;
  142. }
  143. .plan-name {
  144. font-size: calc(30rpx * var(--font-scale, 1));
  145. font-weight: 600;
  146. color: $facade-text-strong;
  147. flex: 1;
  148. min-width: 0;
  149. }
  150. .plan-status {
  151. font-size: calc(22rpx * var(--font-scale, 1));
  152. padding: 4rpx 16rpx;
  153. border-radius: 24rpx;
  154. margin-left: 12rpx;
  155. }
  156. .status-active { background: $mat-blue-tint; color: $mat-blue-strong; }
  157. .status-completed { background: $mat-green-tint; color: $mat-green-strong; }
  158. .status-cancelled { background: $mat-bluegray-50; color: $mat-bluegray-400; }
  159. .status-generated { background: $fortune-1-tint; color: $mat-orange-strong; }
  160. .status-reviewed { background: $mat-green-tint; color: $mat-green-strong; }
  161. .status-rejected { background: $status-danger-tint-4; color: $status-danger-strong-2; }
  162. .status-unknown { background: $mat-bluegray-50; color: $mat-bluegray-400; }
  163. /* ===== 维度 ===== */
  164. .plan-meta {
  165. margin-top: 12rpx;
  166. }
  167. .plan-meta-item {
  168. font-size: calc(24rpx * var(--font-scale, 1));
  169. color: $facade-text-faint;
  170. }
  171. /* ===== 进度 ===== */
  172. .plan-progress {
  173. display: flex;
  174. flex-direction: row;
  175. align-items: center;
  176. margin-top: 16rpx;
  177. }
  178. .progress-track {
  179. flex: 1;
  180. height: 12rpx;
  181. background: #EEF2F7;
  182. border-radius: 8rpx;
  183. overflow: hidden;
  184. margin-right: 16rpx;
  185. }
  186. .progress-fill {
  187. height: 100%;
  188. background: $brand-primary;
  189. border-radius: 8rpx;
  190. }
  191. .progress-text {
  192. font-size: calc(22rpx * var(--font-scale, 1));
  193. color: $facade-text-muted;
  194. }
  195. /* ===== 箭头 ===== */
  196. .plan-arrow {
  197. position: absolute;
  198. right: 24rpx;
  199. top: 50%;
  200. transform: translateY(-50%);
  201. font-size: calc(36rpx * var(--font-scale, 1));
  202. color: $facade-text-ghost;
  203. }
  204. /* ===== 空状态 ===== */
  205. .empty-wrap {
  206. display: flex;
  207. flex-direction: column;
  208. align-items: center;
  209. padding: 120rpx 60rpx;
  210. }
  211. .empty-icon {
  212. font-size: calc($uni-font-size-5xl * var(--font-scale, 1));
  213. margin-bottom: 24rpx;
  214. }
  215. .empty-title {
  216. font-size: calc(32rpx * var(--font-scale, 1));
  217. font-weight: bold;
  218. color: $facade-text-strong;
  219. margin-bottom: 12rpx;
  220. }
  221. .empty-desc {
  222. font-size: calc(26rpx * var(--font-scale, 1));
  223. color: $facade-text-muted;
  224. text-align: center;
  225. margin-bottom: 40rpx;
  226. line-height: 1.5;
  227. }
  228. /* ===== 底部 ===== */
  229. .bottom-spacer {
  230. height: 60rpx;
  231. }
  232. </style>