teacher-home.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <view class="container">
  3. <!-- 顶部信息栏 -->
  4. <view class="header">
  5. <view class="user-info">
  6. <image class="avatar" :src="teacherInfo.avatar || '/static/default-avatar.png'" mode="aspectFill"></image>
  7. <view class="info-text">
  8. <text class="nickname">{{ teacherInfo.nickname || '成长规划师' }}</text>
  9. <view class="status-badge" v-if="teacherStatus !== 'approved'">
  10. <text class="badge-text">{{ teacherStatus === 'pending' ? '审核中' : teacherStatus }}</text>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="switch-btn" @click="switchToParent">
  15. <text class="switch-text">切换家长端</text>
  16. </view>
  17. </view>
  18. <!-- 审核进度提示 -->
  19. <view class="audit-section" v-if="teacherStatus === 'pending'">
  20. <view class="audit-card">
  21. <view class="audit-title">申请审核中</view>
  22. <view class="audit-steps">
  23. <view class="step completed">
  24. <view class="step-dot"></view>
  25. <text class="step-text">提交申请</text>
  26. </view>
  27. <view class="step-line completed"></view>
  28. <view class="step active">
  29. <view class="step-dot"></view>
  30. <text class="step-text">管理员审核</text>
  31. </view>
  32. <view class="step-line"></view>
  33. <view class="step">
  34. <view class="step-dot"></view>
  35. <text class="step-text">审核通过</text>
  36. </view>
  37. </view>
  38. <text class="audit-hint">您的成长规划师申请正在审核中,通常1-3个工作日内完成</text>
  39. </view>
  40. </view>
  41. <!-- 审核拒绝提示 -->
  42. <view class="audit-section" v-if="teacherStatus === 'rejected'">
  43. <view class="audit-card rejected">
  44. <view class="audit-title">申请未通过</view>
  45. <view class="reject-reason" v-if="teacherRejectReason">
  46. <text class="reason-label">拒绝原因:</text>
  47. <text class="reason-text">{{ teacherRejectReason }}</text>
  48. </view>
  49. <view class="reject-reason" v-else>
  50. <text class="reason-text">您的申请暂未通过审核</text>
  51. </view>
  52. <view class="reapply-btn" @click="reapply">
  53. <text class="reapply-text">重新申请</text>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 数据概览 -->
  58. <view class="stats-grid">
  59. <view class="stat-card blue">
  60. <text class="stat-value">{{ stats.serviceFamilyCount }}</text>
  61. <text class="stat-label">服务家庭</text>
  62. </view>
  63. <view class="stat-card green">
  64. <text class="stat-value">{{ stats.pendingTaskCount }}</text>
  65. <text class="stat-label">待处理任务</text>
  66. </view>
  67. <view class="stat-card gold">
  68. <text class="stat-value">{{ formatPriceWithSymbol(stats.todayIncome) }}</text>
  69. <text class="stat-label">今日收入</text>
  70. </view>
  71. <view class="stat-card purple">
  72. <text class="stat-value">{{ stats.teamCount }}</text>
  73. <text class="stat-label">团队成员</text>
  74. </view>
  75. </view>
  76. <!-- 快捷功能(仅审核通过后可使用) -->
  77. <view class="section" v-if="teacherStatus === 'approved'">
  78. <view class="section-title">快捷功能</view>
  79. <view class="menu-grid">
  80. <view class="menu-item" @click="goTo('families')">
  81. <view class="menu-icon blue">👨‍👩‍👧</view>
  82. <text class="menu-label">服务家庭</text>
  83. </view>
  84. <view class="menu-item" @click="goTo('packages')">
  85. <view class="menu-icon gold">📦</view>
  86. <text class="menu-label">任务模板管理</text>
  87. </view>
  88. <view class="menu-item" @click="goTo('team')">
  89. <view class="menu-icon purple">👥</view>
  90. <text class="menu-label">我的团队</text>
  91. </view>
  92. <view class="menu-item" @click="goTo('messages')">
  93. <view class="menu-icon green">💬</view>
  94. <text class="menu-label">消息中心</text>
  95. </view>
  96. <view class="menu-item" @click="goTo('orders')">
  97. <view class="menu-icon cyan">📊</view>
  98. <text class="menu-label">订单佣金</text>
  99. </view>
  100. <view class="menu-item" @click="goTo('growth')">
  101. <view class="menu-icon gray">📋</view>
  102. <text class="menu-label">成长记录</text>
  103. </view>
  104. </view>
  105. </view>
  106. <view class="section disabled-section" v-else>
  107. <view class="section-title">快捷功能</view>
  108. <view class="menu-grid disabled">
  109. <view class="menu-item">
  110. <view class="menu-icon blue disabled-icon">👨‍👩‍👧</view>
  111. <text class="menu-label disabled-label">服务家庭</text>
  112. </view>
  113. <view class="menu-item">
  114. <view class="menu-icon gold disabled-icon">📦</view>
  115. <text class="menu-label disabled-label">任务模板管理</text>
  116. </view>
  117. <view class="menu-item">
  118. <view class="menu-icon purple disabled-icon">👥</view>
  119. <text class="menu-label disabled-label">我的团队</text>
  120. </view>
  121. <view class="menu-item">
  122. <view class="menu-icon green disabled-icon">💬</view>
  123. <text class="menu-label disabled-label">消息中心</text>
  124. </view>
  125. <view class="menu-item">
  126. <view class="menu-icon cyan disabled-icon">📊</view>
  127. <text class="menu-label disabled-label">订单佣金</text>
  128. </view>
  129. <view class="menu-item">
  130. <view class="menu-icon gray disabled-icon">📋</view>
  131. <text class="menu-label disabled-label">成长记录</text>
  132. </view>
  133. </view>
  134. </view>
  135. <!-- 底部占位(TabBar高度) -->
  136. <view class="bottom-space"></view>
  137. </view>
  138. </template>
  139. <script>
  140. import { switchRole } from '../../utils/api.js'
  141. export default {
  142. data() {
  143. return {
  144. teacherInfo: {},
  145. stats: {
  146. serviceFamilyCount: 0,
  147. pendingTaskCount: 0,
  148. todayIncome: 0,
  149. teamCount: 0
  150. }
  151. }
  152. },
  153. computed: {
  154. teacherStatus() {
  155. return uni.getStorageSync('teacherStatus') || 'pending'
  156. },
  157. teacherRejectReason() {
  158. return uni.getStorageSync('teacherRejectReason') || ''
  159. }
  160. },
  161. onLoad() {
  162. this.loadData()
  163. this._onLoadFired = true
  164. },
  165. onShow() {
  166. if (this._onLoadFired) {
  167. this._onLoadFired = false
  168. } else {
  169. this.loadData()
  170. }
  171. },
  172. methods: {
  173. loadData() {
  174. const userInfo = uni.getStorageSync('userInfo')
  175. this.teacherInfo = userInfo || {}
  176. },
  177. reapply() {
  178. uni.navigateTo({ url: '/pages/guide/register/index' })
  179. },
  180. async switchToParent() {
  181. try {
  182. const result = await switchRole('parent')
  183. if (result.code === 200 && result.data) {
  184. const data = result.data
  185. uni.setStorageSync('token', data.token)
  186. uni.setStorageSync('role', data.role)
  187. uni.setStorageSync('currentRole', 'parent')
  188. uni.setStorageSync('isSwitchedChild', false)
  189. uni.setStorageSync('isSwitchedTeacher', false)
  190. uni.$emit('switchRole')
  191. uni.reLaunch({ url: '/pages/index-home/index' })
  192. }
  193. } catch (e) {
  194. uni.showToast({ title: e.message || '切换失败', icon: 'none' })
  195. }
  196. },
  197. goTo(page) {
  198. const routes = {
  199. families: '/pages/teacher/families',
  200. packages: '/pages/guide/packages/index',
  201. team: '/pages/teacher/team',
  202. messages: '/pages/teacher/messages',
  203. orders: '/pages/teacher/orders',
  204. growth: '/pages/growth-main/index'
  205. }
  206. uni.reLaunch({ url: routes[page] })
  207. }
  208. }
  209. }
  210. </script>
  211. <style scoped>
  212. .container {
  213. padding: 24rpx;
  214. background: #F0F7FF;
  215. min-height: 100vh;
  216. }
  217. .header {
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. background: #fff;
  222. border-radius: 16rpx;
  223. padding: 24rpx;
  224. margin-bottom: 24rpx;
  225. }
  226. .user-info {
  227. display: flex;
  228. align-items: center;
  229. }
  230. .avatar {
  231. width: 96rpx;
  232. height: 96rpx;
  233. border-radius: 50%;
  234. margin-right: 16rpx;
  235. }
  236. .info-text {
  237. display: flex;
  238. flex-direction: column;
  239. }
  240. .nickname {
  241. font-size: 32rpx;
  242. font-weight: bold;
  243. color: #1E293B;
  244. }
  245. .status-badge {
  246. background: #FEF3C7;
  247. padding: 4rpx 12rpx;
  248. border-radius: 8rpx;
  249. margin-top: 8rpx;
  250. }
  251. .badge-text {
  252. font-size: 22rpx;
  253. color: #D97706;
  254. }
  255. .switch-btn {
  256. background: #3B82F6;
  257. padding: 16rpx 24rpx;
  258. border-radius: 12rpx;
  259. }
  260. .switch-text {
  261. color: #fff;
  262. font-size: 24rpx;
  263. }
  264. .audit-section {
  265. margin-bottom: 24rpx;
  266. }
  267. .audit-card {
  268. background: #fff;
  269. border-radius: 16rpx;
  270. padding: 32rpx 24rpx;
  271. }
  272. .audit-card.rejected {
  273. border-left: 6rpx solid #EF4444;
  274. }
  275. .audit-title {
  276. font-size: 30rpx;
  277. font-weight: bold;
  278. color: #1E293B;
  279. margin-bottom: 24rpx;
  280. }
  281. .audit-steps {
  282. display: flex;
  283. align-items: center;
  284. justify-content: center;
  285. margin-bottom: 24rpx;
  286. }
  287. .step {
  288. display: flex;
  289. flex-direction: column;
  290. align-items: center;
  291. flex: 0 0 auto;
  292. }
  293. .step-dot {
  294. width: 24rpx;
  295. height: 24rpx;
  296. border-radius: 50%;
  297. background: #E2E8F0;
  298. margin-bottom: 8rpx;
  299. }
  300. .step.completed .step-dot {
  301. background: #10B981;
  302. }
  303. .step.active .step-dot {
  304. background: #3B82F6;
  305. box-shadow: 0 0 0 6rpx rgba(59, 130, 246, 0.2);
  306. }
  307. .step-text {
  308. font-size: 22rpx;
  309. color: #94A3B8;
  310. }
  311. .step.completed .step-text {
  312. color: #10B981;
  313. }
  314. .step.active .step-text {
  315. color: #3B82F6;
  316. font-weight: bold;
  317. }
  318. .step-line {
  319. width: 60rpx;
  320. height: 4rpx;
  321. background: #E2E8F0;
  322. margin: 0 8rpx;
  323. margin-bottom: 28rpx;
  324. }
  325. .step-line.completed {
  326. background: #10B981;
  327. }
  328. .audit-hint {
  329. font-size: 24rpx;
  330. color: #64748B;
  331. text-align: center;
  332. }
  333. .reject-reason {
  334. background: #FEF2F2;
  335. border-radius: 8rpx;
  336. padding: 16rpx;
  337. margin-bottom: 20rpx;
  338. }
  339. .reason-label {
  340. font-size: 24rpx;
  341. color: #991B1B;
  342. font-weight: bold;
  343. }
  344. .reason-text {
  345. font-size: 24rpx;
  346. color: #DC2626;
  347. }
  348. .reapply-btn {
  349. background: #3B82F6;
  350. border-radius: 12rpx;
  351. padding: 20rpx;
  352. text-align: center;
  353. }
  354. .reapply-text {
  355. color: #fff;
  356. font-size: 28rpx;
  357. font-weight: bold;
  358. }
  359. .stats-grid {
  360. display: grid;
  361. grid-template-columns: repeat(2, 1fr);
  362. gap: 16rpx;
  363. margin-bottom: 24rpx;
  364. }
  365. .stat-card {
  366. background: #fff;
  367. border-radius: 16rpx;
  368. padding: 24rpx;
  369. text-align: center;
  370. }
  371. .stat-value {
  372. font-size: 36rpx;
  373. font-weight: bold;
  374. display: block;
  375. margin-bottom: 8rpx;
  376. }
  377. .stat-label {
  378. font-size: 24rpx;
  379. color: #64748B;
  380. }
  381. .stat-card.blue .stat-value { color: #3B82F6; }
  382. .stat-card.green .stat-value { color: #10B981; }
  383. .stat-card.gold .stat-value { color: #F59E0B; }
  384. .stat-card.purple .stat-value { color: #8B5CF6; }
  385. .section {
  386. background: #fff;
  387. border-radius: 16rpx;
  388. padding: 24rpx;
  389. }
  390. .section-title {
  391. font-size: 30rpx;
  392. font-weight: bold;
  393. color: #1E293B;
  394. margin-bottom: 20rpx;
  395. }
  396. .menu-grid {
  397. display: grid;
  398. grid-template-columns: repeat(3, 1fr);
  399. gap: 20rpx;
  400. }
  401. .menu-item {
  402. display: flex;
  403. flex-direction: column;
  404. align-items: center;
  405. padding: 20rpx 0;
  406. }
  407. .menu-icon {
  408. width: 80rpx;
  409. height: 80rpx;
  410. border-radius: 16rpx;
  411. display: flex;
  412. align-items: center;
  413. justify-content: center;
  414. font-size: 36rpx;
  415. margin-bottom: 12rpx;
  416. }
  417. .menu-icon.blue { background: rgba(59, 130, 246, 0.15); }
  418. .menu-icon.gold { background: rgba(245, 158, 11, 0.15); }
  419. .menu-icon.purple { background: rgba(139, 92, 246, 0.15); }
  420. .menu-icon.green { background: rgba(16, 185, 129, 0.15); }
  421. .menu-icon.cyan { background: rgba(6, 182, 212, 0.15); }
  422. .menu-icon.gray { background: rgba(100, 116, 139, 0.15); }
  423. .menu-label {
  424. font-size: 24rpx;
  425. color: #64748B;
  426. }
  427. .bottom-space {
  428. height: 120rpx;
  429. }
  430. .disabled-section {
  431. opacity: 0.6;
  432. }
  433. .disabled .menu-item {
  434. pointer-events: none;
  435. }
  436. .disabled-icon {
  437. filter: grayscale(100%);
  438. opacity: 0.5;
  439. }
  440. .disabled-label {
  441. color: #94A3B8;
  442. }
  443. </style>