teacher-home.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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. },
  164. onShow() {
  165. this.loadData()
  166. },
  167. methods: {
  168. loadData() {
  169. const userInfo = uni.getStorageSync('userInfo')
  170. this.teacherInfo = userInfo || {}
  171. },
  172. reapply() {
  173. uni.navigateTo({ url: '/pages/guide/register/index' })
  174. },
  175. async switchToParent() {
  176. try {
  177. const result = await switchRole('parent')
  178. if (result.code === 200 && result.data) {
  179. const data = result.data
  180. uni.setStorageSync('token', data.token)
  181. uni.setStorageSync('role', data.role)
  182. uni.setStorageSync('currentRole', 'parent')
  183. uni.setStorageSync('isSwitchedChild', false)
  184. uni.setStorageSync('isSwitchedTeacher', false)
  185. uni.$emit('switchRole')
  186. uni.reLaunch({ url: '/pages/index/index' })
  187. }
  188. } catch (e) {
  189. uni.showToast({ title: e.message || '切换失败', icon: 'none' })
  190. }
  191. },
  192. goTo(page) {
  193. const routes = {
  194. families: '/pages/teacher/families',
  195. packages: '/pages/guide/packages/index',
  196. team: '/pages/teacher/team',
  197. messages: '/pages/teacher/messages',
  198. orders: '/pages/teacher/orders',
  199. growth: '/pages/growth/index'
  200. }
  201. uni.reLaunch({ url: routes[page] })
  202. }
  203. }
  204. }
  205. </script>
  206. <style scoped>
  207. .container {
  208. padding: 24rpx;
  209. background: #F0F7FF;
  210. min-height: 100vh;
  211. }
  212. .header {
  213. display: flex;
  214. justify-content: space-between;
  215. align-items: center;
  216. background: #fff;
  217. border-radius: 16rpx;
  218. padding: 24rpx;
  219. margin-bottom: 24rpx;
  220. }
  221. .user-info {
  222. display: flex;
  223. align-items: center;
  224. }
  225. .avatar {
  226. width: 96rpx;
  227. height: 96rpx;
  228. border-radius: 50%;
  229. margin-right: 16rpx;
  230. }
  231. .info-text {
  232. display: flex;
  233. flex-direction: column;
  234. }
  235. .nickname {
  236. font-size: 32rpx;
  237. font-weight: bold;
  238. color: #1E293B;
  239. }
  240. .status-badge {
  241. background: #FEF3C7;
  242. padding: 4rpx 12rpx;
  243. border-radius: 8rpx;
  244. margin-top: 8rpx;
  245. }
  246. .badge-text {
  247. font-size: 22rpx;
  248. color: #D97706;
  249. }
  250. .switch-btn {
  251. background: #3B82F6;
  252. padding: 16rpx 24rpx;
  253. border-radius: 12rpx;
  254. }
  255. .switch-text {
  256. color: #fff;
  257. font-size: 24rpx;
  258. }
  259. .audit-section {
  260. margin-bottom: 24rpx;
  261. }
  262. .audit-card {
  263. background: #fff;
  264. border-radius: 16rpx;
  265. padding: 32rpx 24rpx;
  266. }
  267. .audit-card.rejected {
  268. border-left: 6rpx solid #EF4444;
  269. }
  270. .audit-title {
  271. font-size: 30rpx;
  272. font-weight: bold;
  273. color: #1E293B;
  274. margin-bottom: 24rpx;
  275. }
  276. .audit-steps {
  277. display: flex;
  278. align-items: center;
  279. justify-content: center;
  280. margin-bottom: 24rpx;
  281. }
  282. .step {
  283. display: flex;
  284. flex-direction: column;
  285. align-items: center;
  286. flex: 0 0 auto;
  287. }
  288. .step-dot {
  289. width: 24rpx;
  290. height: 24rpx;
  291. border-radius: 50%;
  292. background: #E2E8F0;
  293. margin-bottom: 8rpx;
  294. }
  295. .step.completed .step-dot {
  296. background: #10B981;
  297. }
  298. .step.active .step-dot {
  299. background: #3B82F6;
  300. box-shadow: 0 0 0 6rpx rgba(59, 130, 246, 0.2);
  301. }
  302. .step-text {
  303. font-size: 22rpx;
  304. color: #94A3B8;
  305. }
  306. .step.completed .step-text {
  307. color: #10B981;
  308. }
  309. .step.active .step-text {
  310. color: #3B82F6;
  311. font-weight: bold;
  312. }
  313. .step-line {
  314. width: 60rpx;
  315. height: 4rpx;
  316. background: #E2E8F0;
  317. margin: 0 8rpx;
  318. margin-bottom: 28rpx;
  319. }
  320. .step-line.completed {
  321. background: #10B981;
  322. }
  323. .audit-hint {
  324. font-size: 24rpx;
  325. color: #64748B;
  326. text-align: center;
  327. }
  328. .reject-reason {
  329. background: #FEF2F2;
  330. border-radius: 8rpx;
  331. padding: 16rpx;
  332. margin-bottom: 20rpx;
  333. }
  334. .reason-label {
  335. font-size: 24rpx;
  336. color: #991B1B;
  337. font-weight: bold;
  338. }
  339. .reason-text {
  340. font-size: 24rpx;
  341. color: #DC2626;
  342. }
  343. .reapply-btn {
  344. background: #3B82F6;
  345. border-radius: 12rpx;
  346. padding: 20rpx;
  347. text-align: center;
  348. }
  349. .reapply-text {
  350. color: #fff;
  351. font-size: 28rpx;
  352. font-weight: bold;
  353. }
  354. .stats-grid {
  355. display: grid;
  356. grid-template-columns: repeat(2, 1fr);
  357. gap: 16rpx;
  358. margin-bottom: 24rpx;
  359. }
  360. .stat-card {
  361. background: #fff;
  362. border-radius: 16rpx;
  363. padding: 24rpx;
  364. text-align: center;
  365. }
  366. .stat-value {
  367. font-size: 36rpx;
  368. font-weight: bold;
  369. display: block;
  370. margin-bottom: 8rpx;
  371. }
  372. .stat-label {
  373. font-size: 24rpx;
  374. color: #64748B;
  375. }
  376. .stat-card.blue .stat-value { color: #3B82F6; }
  377. .stat-card.green .stat-value { color: #10B981; }
  378. .stat-card.gold .stat-value { color: #F59E0B; }
  379. .stat-card.purple .stat-value { color: #8B5CF6; }
  380. .section {
  381. background: #fff;
  382. border-radius: 16rpx;
  383. padding: 24rpx;
  384. }
  385. .section-title {
  386. font-size: 30rpx;
  387. font-weight: bold;
  388. color: #1E293B;
  389. margin-bottom: 20rpx;
  390. }
  391. .menu-grid {
  392. display: grid;
  393. grid-template-columns: repeat(3, 1fr);
  394. gap: 20rpx;
  395. }
  396. .menu-item {
  397. display: flex;
  398. flex-direction: column;
  399. align-items: center;
  400. padding: 20rpx 0;
  401. }
  402. .menu-icon {
  403. width: 80rpx;
  404. height: 80rpx;
  405. border-radius: 16rpx;
  406. display: flex;
  407. align-items: center;
  408. justify-content: center;
  409. font-size: 36rpx;
  410. margin-bottom: 12rpx;
  411. }
  412. .menu-icon.blue { background: rgba(59, 130, 246, 0.15); }
  413. .menu-icon.gold { background: rgba(245, 158, 11, 0.15); }
  414. .menu-icon.purple { background: rgba(139, 92, 246, 0.15); }
  415. .menu-icon.green { background: rgba(16, 185, 129, 0.15); }
  416. .menu-icon.cyan { background: rgba(6, 182, 212, 0.15); }
  417. .menu-icon.gray { background: rgba(100, 116, 139, 0.15); }
  418. .menu-label {
  419. font-size: 24rpx;
  420. color: #64748B;
  421. }
  422. .bottom-space {
  423. height: 120rpx;
  424. }
  425. .disabled-section {
  426. opacity: 0.6;
  427. }
  428. .disabled .menu-item {
  429. pointer-events: none;
  430. }
  431. .disabled-icon {
  432. filter: grayscale(100%);
  433. opacity: 0.5;
  434. }
  435. .disabled-label {
  436. color: #94A3B8;
  437. }
  438. </style>