families.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="container">
  3. <view class="filter-bar">
  4. <view class="filter-item" :class="{ active: filterType === 'all' }" @click="changeFilter('all')">全部</view>
  5. <view class="filter-item" :class="{ active: filterType === 'active' }" @click="changeFilter('active')">活跃</view>
  6. <view class="filter-item" :class="{ active: filterType === 'pending' }" @click="changeFilter('pending')">待审核</view>
  7. </view>
  8. <view class="family-list">
  9. <view class="family-card" v-for="family in families" :key="family.id" @click="viewFamily(family)">
  10. <view class="family-header">
  11. <text class="family-name">{{ family.familyName || '家庭' + family.familyId }}</text>
  12. <text class="family-status">{{ family.status === 'active' ? '服务中' : '已暂停' }}</text>
  13. </view>
  14. <view class="family-info">
  15. <text class="info-item">👶 {{ family.childrenCount || 0 }}个孩子</text>
  16. <text class="info-item">📍 {{ family.address || '未设置地址' }}</text>
  17. </view>
  18. <view class="family-tasks">
  19. <text class="task-info">今日任务: {{ family.todayTaskCount || 0 }}/{{ family.totalTaskCount || 0 }}</text>
  20. </view>
  21. <view class="family-actions">
  22. <button class="btn-action" size="mini" @click.stop="viewDetail(family)">查看详情</button>
  23. <button class="btn-action primary" size="mini" @click.stop="sendMessage(family)">发消息</button>
  24. </view>
  25. </view>
  26. <view class="empty-tip" v-if="families.length === 0">
  27. <text>暂无服务家庭</text>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { getBoundFamilies } from '../../utils/api.js'
  34. export default {
  35. data() {
  36. return {
  37. filterType: 'all',
  38. families: []
  39. }
  40. },
  41. onLoad() {
  42. this.loadFamilies()
  43. },
  44. methods: {
  45. async loadFamilies() {
  46. try {
  47. const res = await getBoundFamilies()
  48. if (res.data) {
  49. this.families = res.data
  50. }
  51. } catch (e) {
  52. console.error(e)
  53. }
  54. },
  55. changeFilter(type) {
  56. this.filterType = type
  57. },
  58. viewFamily(family) {
  59. uni.navigateTo({
  60. url: `/pages/family/detail?id=${family.familyId}`
  61. })
  62. },
  63. viewDetail(family) {
  64. this.viewFamily(family)
  65. },
  66. sendMessage(family) {
  67. uni.navigateTo({
  68. url: `/pages/teacher/messages?familyId=${family.familyId}`
  69. })
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped>
  75. .container {
  76. padding: 30rpx;
  77. background: #f5f5f5;
  78. min-height: 100vh;
  79. }
  80. .filter-bar {
  81. display: flex;
  82. background: #fff;
  83. border-radius: 16rpx;
  84. padding: 20rpx;
  85. margin-bottom: 30rpx;
  86. }
  87. .filter-item {
  88. flex: 1;
  89. text-align: center;
  90. padding: 16rpx 0;
  91. font-size: 28rpx;
  92. color: #666;
  93. border-radius: 8rpx;
  94. }
  95. .filter-item.active {
  96. background: #667eea;
  97. color: #fff;
  98. }
  99. .family-card {
  100. background: #fff;
  101. border-radius: 16rpx;
  102. padding: 30rpx;
  103. margin-bottom: 20rpx;
  104. }
  105. .family-header {
  106. display: flex;
  107. justify-content: space-between;
  108. align-items: center;
  109. margin-bottom: 20rpx;
  110. }
  111. .family-name {
  112. font-size: 32rpx;
  113. font-weight: bold;
  114. color: #333;
  115. }
  116. .family-status {
  117. font-size: 24rpx;
  118. color: #67C23A;
  119. background: #f0f9eb;
  120. padding: 8rpx 16rpx;
  121. border-radius: 8rpx;
  122. }
  123. .family-info {
  124. margin-bottom: 16rpx;
  125. }
  126. .info-item {
  127. font-size: 26rpx;
  128. color: #666;
  129. display: block;
  130. margin-bottom: 8rpx;
  131. }
  132. .family-tasks {
  133. padding: 16rpx 0;
  134. border-top: 1rpx solid #f0f0f0;
  135. border-bottom: 1rpx solid #f0f0f0;
  136. margin-bottom: 20rpx;
  137. }
  138. .task-info {
  139. font-size: 26rpx;
  140. color: #666;
  141. }
  142. .family-actions {
  143. display: flex;
  144. justify-content: flex-end;
  145. }
  146. .btn-action {
  147. margin-left: 20rpx;
  148. font-size: 24rpx;
  149. }
  150. .btn-action.primary {
  151. background: #667eea;
  152. color: #fff;
  153. }
  154. .empty-tip {
  155. text-align: center;
  156. color: #999;
  157. padding: 60rpx 0;
  158. }
  159. </style>