index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="container">
  3. <!-- 头部 -->
  4. <view class="header">
  5. <view class="header-title">服务中心</view>
  6. <view class="header-close" @click="close">
  7. <text>✕</text>
  8. </view>
  9. </view>
  10. <!-- 统计概览 -->
  11. <view class="stats-row">
  12. <view class="stat-card blue">
  13. <text class="stat-value">{{ serviceFamilyCount }}</text>
  14. <text class="stat-label">服务家庭</text>
  15. </view>
  16. <view class="stat-card green">
  17. <text class="stat-value">{{ pendingTaskCount }}</text>
  18. <text class="stat-label">待处理任务</text>
  19. </view>
  20. </view>
  21. <view class="stats-row">
  22. <view class="stat-card gold">
  23. <text class="stat-value">{{ formatPriceWithSymbol(todayIncome) }}</text>
  24. <text class="stat-label">今日收入</text>
  25. </view>
  26. <view class="stat-card purple">
  27. <text class="stat-value">{{ teamCount }}</text>
  28. <text class="stat-label">团队成员</text>
  29. </view>
  30. </view>
  31. <!-- 快捷功能 -->
  32. <view class="section" v-if="isTeacherApproved">
  33. <view class="section-title">快捷功能</view>
  34. <view class="menu-row">
  35. <view class="menu-item" @click="goToFamilies">
  36. <view class="menu-icon blue">👨‍👩‍👧</view>
  37. <text class="menu-label">服务家庭</text>
  38. </view>
  39. <view class="menu-item" @click="goToServiceTasks">
  40. <view class="menu-icon green">⚡</view>
  41. <text class="menu-label">待办任务</text>
  42. </view>
  43. <view class="menu-item" @click="goToMessages">
  44. <view class="menu-icon cyan">💬</view>
  45. <text class="menu-label">消息中心</text>
  46. </view>
  47. <view class="menu-item" @click="goToAssessmentResult">
  48. <view class="menu-icon purple">📊</view>
  49. <text class="menu-label">录入测评结果</text>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 无权限提示 -->
  54. <view class="section" v-else>
  55. <view class="section-title">服务中心</view>
  56. <view class="empty-tip" v-if="isTeacherPending">申请审核中,暂未开放服务中心功能</view>
  57. <view class="empty-tip" v-if="isTeacherRejected">申请未通过,请联系管理员</view>
  58. <view class="empty-tip" v-if="!isTeacher && !isTeacherPending && !isTeacherRejected">暂无服务中心权限</view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import { getTeacherPendingTasks, getTeacherUnreadCount } from '@/utils/api.js'
  64. export default {
  65. data() {
  66. return {
  67. isTeacher: false,
  68. isTeacherApproved: false,
  69. isTeacherPending: false,
  70. isTeacherRejected: false,
  71. serviceFamilyCount: 0,
  72. pendingTaskCount: 0,
  73. todayIncome: 0,
  74. teamCount: 0
  75. }
  76. },
  77. onLoad() {
  78. this.initRole()
  79. this.loadTeacherData()
  80. },
  81. methods: {
  82. initRole() {
  83. var role = uni.getStorageSync('role') || uni.getStorageSync('currentRole') || 'parent'
  84. this.isTeacher = role === 'teacher'
  85. var status = uni.getStorageSync('teacherStatus') || ''
  86. this.isTeacherPending = role === 'teacher' && status === 'pending'
  87. this.isTeacherRejected = role === 'teacher' && status === 'rejected'
  88. this.isTeacherApproved = role === 'teacher' && status === 'approved'
  89. },
  90. async loadTeacherData() {
  91. if (!this.isTeacherApproved) return
  92. try {
  93. var res = await getTeacherPendingTasks()
  94. if (res && res.data && Array.isArray(res.data)) {
  95. this.pendingTaskCount = res.data.length
  96. } else if (res && res.data && res.data.pendingCount != null) {
  97. this.pendingTaskCount = res.data.pendingCount
  98. }
  99. } catch (e) {
  100. this.pendingTaskCount = uni.getStorageSync('pendingTaskCount') || 0
  101. }
  102. // 今日收入/服务家庭/团队数:后端暂无专用接口,暂用存储兜底
  103. this.todayIncome = uni.getStorageSync('todayIncome') || 0
  104. this.serviceFamilyCount = uni.getStorageSync('serviceFamilyCount') || 0
  105. this.teamCount = uni.getStorageSync('teamCount') || 0
  106. },
  107. formatPriceWithSymbol(value) {
  108. if (!value) return '¥0'
  109. return '¥' + parseFloat(value).toFixed(2)
  110. },
  111. close() {
  112. uni.navigateBack()
  113. },
  114. goToFamilies() {
  115. uni.navigateTo({ url: '/pages/teacher/families' })
  116. },
  117. goToServiceTasks() {
  118. uni.navigateTo({ url: '/pages/teacher/service-tasks' })
  119. },
  120. goToMessages() {
  121. uni.navigateTo({ url: '/pages/teacher/messages' })
  122. },
  123. goToAssessmentResult() {
  124. uni.navigateTo({ url: '/pages/assessment/execution' })
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped>
  130. .container {
  131. background: #F8F4EF;
  132. min-height: 100vh;
  133. padding: 0 0 40rpx;
  134. }
  135. .header {
  136. display: flex;
  137. flex-direction: row;
  138. justify-content: space-between;
  139. align-items: center;
  140. background: #fff;
  141. border-radius: 16rpx 16rpx 0 0;
  142. padding: 24rpx 30rpx;
  143. margin-bottom: 24rpx;
  144. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  145. }
  146. .header-title {
  147. font-size: 34rpx;
  148. font-weight: bold;
  149. color: #1E293B;
  150. }
  151. .header-close {
  152. font-size: 28rpx;
  153. color: #999;
  154. }
  155. /* 统计卡片横排(替代 grid,使用 flexbox) */
  156. .stats-row {
  157. display: flex;
  158. flex-direction: row;
  159. gap: 16rpx;
  160. padding: 0 24rpx;
  161. margin-bottom: 16rpx;
  162. }
  163. .stat-card {
  164. flex: 1;
  165. background: #fff;
  166. border-radius: 16rpx;
  167. padding: 24rpx;
  168. align-items: center;
  169. display: flex;
  170. flex-direction: column;
  171. }
  172. .stat-card.blue { border-top: 4rpx solid #3B82F6; }
  173. .stat-card.green { border-top: 4rpx solid #10B981; }
  174. .stat-card.gold { border-top: 4rpx solid #F59E0B; }
  175. .stat-card.purple { border-top: 4rpx solid #8B5CF6; }
  176. .stat-value {
  177. font-size: 36rpx;
  178. font-weight: bold;
  179. color: #1E293B;
  180. display: block;
  181. margin-bottom: 8rpx;
  182. }
  183. .stat-label {
  184. font-size: 24rpx;
  185. color: #64748B;
  186. }
  187. .section {
  188. background: #fff;
  189. border-radius: 16rpx;
  190. padding: 24rpx;
  191. margin: 0 24rpx 24rpx;
  192. }
  193. .section-title {
  194. font-size: 30rpx;
  195. font-weight: bold;
  196. color: #1E293B;
  197. margin-bottom: 20rpx;
  198. }
  199. /* 菜单横排(替代 grid,使用 flexbox) */
  200. .menu-row {
  201. display: flex;
  202. flex-direction: row;
  203. flex-wrap: wrap;
  204. gap: 16rpx;
  205. }
  206. .menu-item {
  207. flex: 1 1 45%;
  208. display: flex;
  209. flex-direction: column;
  210. align-items: center;
  211. padding: 20rpx 0;
  212. background: #F8F4EF;
  213. border-radius: 16rpx;
  214. }
  215. .menu-icon {
  216. width: 60rpx;
  217. height: 60rpx;
  218. border-radius: 12rpx;
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. font-size: 30rpx;
  223. margin-bottom: 12rpx;
  224. }
  225. .menu-icon.blue { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }
  226. .menu-icon.green { background: rgba(16, 185, 129, 0.15); color: #10B981; }
  227. .menu-icon.cyan { background: rgba(6, 182, 212, 0.15); color: #06B6D4; }
  228. .menu-icon.purple { background: rgba(139, 92, 246, 0.15); color: #8B5CF6; }
  229. .menu-label {
  230. font-size: 24rpx;
  231. color: #64748B;
  232. }
  233. .empty-tip {
  234. text-align: center;
  235. color: #999;
  236. padding: 60rpx 0;
  237. font-size: 26rpx;
  238. }
  239. </style>