index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="container" :style="{ '--font-scale': fontScale }">
  3. <view class="header">
  4. <text class="title">我的计划</text>
  5. <text class="subtitle">查看和管理家庭成长计划</text>
  6. </view>
  7. <!-- 加载中 -->
  8. <view class="loading" v-if="loading">
  9. <text>加载中...</text>
  10. </view>
  11. <!-- 空状态 -->
  12. <view class="empty" v-else-if="plans.length === 0">
  13. <text class="empty-icon">📋</text>
  14. <text class="empty-text">暂无计划</text>
  15. <text class="empty-hint">规划师可为您创建专属成长计划</text>
  16. </view>
  17. <!-- 计划列表 -->
  18. <view class="plan-list" v-else>
  19. <view class="plan-card" v-for="plan in plans" :key="plan.id" @click="goDetail(plan.id)">
  20. <view class="card-top">
  21. <text class="plan-title">{{ plan.title }}</text>
  22. <view class="plan-status" :class="'status-' + (plan.status || 0)">
  23. <text>{{ statusText(plan.status) }}</text>
  24. </view>
  25. </view>
  26. <text class="plan-desc" v-if="plan.description">{{ plan.description }}</text>
  27. <view class="card-meta">
  28. <text class="meta-item">成员:{{ plan.childName || '--' }}</text>
  29. <text class="meta-item">创建时间:{{ plan.createTime || '--' }}</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import { listFamilyPlans } from '../../../utils/api.js'
  37. import fontScaleMixin from '@/mixins/font-scale.js'
  38. export default {
  39. mixins: [fontScaleMixin],
  40. data() {
  41. return {
  42. loading: false,
  43. plans: []
  44. }
  45. },
  46. computed: {},
  47. onShow() {
  48. this.loadPlans()
  49. },
  50. methods: {
  51. loadPlans: function() {
  52. this.loading = true
  53. var self = this
  54. listFamilyPlans({}).then(function(res) {
  55. self.loading = false
  56. if (res.code === 200 && Array.isArray(res.data)) {
  57. self.plans = res.data
  58. } else if (res.code === 200 && res.data && res.data.records) {
  59. self.plans = res.data.records
  60. }
  61. }).catch(function() {
  62. self.loading = false
  63. self.plans = []
  64. })
  65. },
  66. goDetail: function(id) {
  67. uni.navigateTo({ url: './detail?planId=' + id })
  68. },
  69. statusText: function(status) {
  70. var map = { 0: '待审核', 1: '进行中', 2: '已完成', 3: '已取消' }
  71. return map[status] || '未知'
  72. }
  73. }
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. .container { min-height: 100vh; background: $facade-fill-page; padding-bottom: $uni-space-lg; }
  78. .header { padding: 40rpx $uni-space-page 20rpx; }
  79. .title { font-size: calc(36rpx * var(--font-scale, 1)); font-weight: bold; color: $facade-text-strong; display: block; }
  80. .subtitle { font-size: calc(26rpx * var(--font-scale, 1)); color: $facade-text-muted; margin-top: 8rpx; display: block; }
  81. .loading, .empty { display: flex; flex-direction: column; align-items: center; padding: 100rpx 0; }
  82. .empty-icon { font-size: calc($uni-font-size-5xl * var(--font-scale, 1)); }
  83. .empty-text { font-size: calc(30rpx * var(--font-scale, 1)); color: $facade-text-body; margin-top: 20rpx; }
  84. .empty-hint { font-size: calc(26rpx * var(--font-scale, 1)); color: $facade-text-ghost-light; margin-top: 10rpx; }
  85. .plan-list { padding: 0 $uni-space-page; }
  86. .plan-card { background: $app-surface; border-radius: 16rpx; padding: $uni-space-page; margin-bottom: 20rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  87. .card-top { display: flex; justify-content: space-between; align-items: center; }
  88. .plan-title { font-size: calc(30rpx * var(--font-scale, 1)); font-weight: bold; color: $facade-text-strong; flex: 1; }
  89. .plan-status { font-size: calc(22rpx * var(--font-scale, 1)); padding: 4rpx 16rpx; border-radius: 24rpx; }
  90. .status-0 { background: $fortune-1-tint; color: $brand-primary; }
  91. .status-1 { background: $mat-green-tint; color: $mat-green; }
  92. .status-2 { background: $mat-blue-tint; color: $mat-blue-base; }
  93. .status-3 { background: $facade-fill-2; color: $facade-text-muted; }
  94. .plan-desc { font-size: calc(26rpx * var(--font-scale, 1)); color: $facade-text-body; margin-top: 12rpx; display: block; line-height: 1.5; }
  95. .card-meta { display: flex; flex-direction: column; margin-top: 16rpx; gap: 6rpx; }
  96. .meta-item { font-size: calc(24rpx * var(--font-scale, 1)); color: $facade-text-ghost-light; }
  97. </style>