detail.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="container">
  3. <!-- 加载中 -->
  4. <view class="loading" v-if="loading">
  5. <text>加载中...</text>
  6. </view>
  7. <!-- 计划详情 -->
  8. <template v-else-if="plan">
  9. <view class="header">
  10. <text class="title">{{ plan.title }}</text>
  11. <view class="status-badge" :class="'status-' + (plan.status || 0)">
  12. <text>{{ statusText(plan.status) }}</text>
  13. </view>
  14. </view>
  15. <view class="info-card" v-if="plan.description">
  16. <text class="info-label">计划说明</text>
  17. <text class="info-value">{{ plan.description }}</text>
  18. </view>
  19. <view class="info-card">
  20. <text class="info-label">孩子</text>
  21. <text class="info-value">{{ plan.childName || '--' }}</text>
  22. </view>
  23. <view class="info-card" v-if="plan.guideName">
  24. <text class="info-label">规划师</text>
  25. <text class="info-value">{{ plan.guideName }}</text>
  26. </view>
  27. <view class="info-card">
  28. <text class="info-label">创建时间</text>
  29. <text class="info-value">{{ plan.createTime || '--' }}</text>
  30. </view>
  31. <!-- 计划条目 -->
  32. <view class="items-section" v-if="plan.items && plan.items.length > 0">
  33. <text class="section-title">计划内容</text>
  34. <view class="item-card" v-for="item in plan.items" :key="item.id">
  35. <view class="item-top">
  36. <text class="item-title">{{ item.title }}</text>
  37. <text class="item-status" v-if="item.completed">✅ 已完成</text>
  38. </view>
  39. <text class="item-desc" v-if="item.description">{{ item.description }}</text>
  40. </view>
  41. </view>
  42. </template>
  43. <!-- 空状态 -->
  44. <view class="empty" v-else>
  45. <text class="empty-icon">📋</text>
  46. <text class="empty-text">计划不存在</text>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import { getGuidePlanDetail } from '../../../utils/api.js'
  52. export default {
  53. data() {
  54. return {
  55. loading: false,
  56. plan: null
  57. }
  58. },
  59. onLoad: function(options) {
  60. if (options.planId) {
  61. this.planId = options.planId
  62. this.loadDetail()
  63. }
  64. },
  65. methods: {
  66. loadDetail: function() {
  67. if (!this.planId) return
  68. this.loading = true
  69. var self = this
  70. getGuidePlanDetail({ planId: this.planId }).then(function(res) {
  71. self.loading = false
  72. if (res.code === 200 && res.data) {
  73. self.plan = res.data
  74. }
  75. }).catch(function() {
  76. self.loading = false
  77. })
  78. },
  79. statusText: function(status) {
  80. var map = { 0: '待审核', 1: '进行中', 2: '已完成', 3: '已取消' }
  81. return map[status] || '未知'
  82. }
  83. }
  84. }
  85. </script>
  86. <style scoped>
  87. .container { min-height: 100vh; background: #f8f8f8; padding-bottom: 30rpx; }
  88. .loading, .empty { display: flex; flex-direction: column; align-items: center; padding: 100rpx 0; }
  89. .empty-icon { font-size: 80rpx; }
  90. .empty-text { font-size: 30rpx; color: #666; margin-top: 20rpx; }
  91. .header { background: #fff; padding: 40rpx 30rpx; display: flex; justify-content: space-between; align-items: center; }
  92. .title { font-size: 36rpx; font-weight: bold; color: #333; flex: 1; }
  93. .status-badge { font-size: 24rpx; padding: 6rpx 20rpx; border-radius: 20rpx; }
  94. .status-0 { background: #FFF3E0; color: #F97316; }
  95. .status-1 { background: #E8F5E9; color: #4CAF50; }
  96. .status-2 { background: #E3F2FD; color: #2196F3; }
  97. .status-3 { background: #F5F5F5; color: #999; }
  98. .info-card { background: #fff; margin: 20rpx 30rpx; padding: 24rpx 30rpx; border-radius: 16rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  99. .info-label { font-size: 26rpx; color: #999; display: block; margin-bottom: 8rpx; }
  100. .info-value { font-size: 28rpx; color: #333; display: block; }
  101. .items-section { margin: 20rpx 30rpx; }
  102. .section-title { font-size: 30rpx; font-weight: bold; color: #333; display: block; margin-bottom: 16rpx; }
  103. .item-card { background: #fff; border-radius: 12rpx; padding: 24rpx; margin-bottom: 16rpx; box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04); }
  104. .item-top { display: flex; justify-content: space-between; align-items: center; }
  105. .item-title { font-size: 28rpx; font-weight: bold; color: #333; }
  106. .item-status { font-size: 24rpx; color: #4CAF50; }
  107. .item-desc { font-size: 26rpx; color: #666; margin-top: 10rpx; display: block; line-height: 1.5; }
  108. </style>