index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="container" :style="{ '--font-scale': fontScale }">
  3. <view class="header">
  4. <text class="title">我的下级成长规划师</text>
  5. <text class="subtitle">查看和管理下级成长规划师</text>
  6. </view>
  7. <!-- 下级成长规划师列表 -->
  8. <view class="section">
  9. <view class="section-title">直接下级</view>
  10. <view class="guide-list" v-if="childGuides.length > 0">
  11. <view
  12. class="guide-item"
  13. v-for="guide in childGuides"
  14. :key="guide.id"
  15. @click="viewGuideDetail(guide)"
  16. >
  17. <image class="guide-avatar" :src="guide.avatar || '/static/default-avatar.png'" mode="aspectFill" />
  18. <view class="guide-info">
  19. <text class="guide-name">{{ guide.nickname || '未命名' }}</text>
  20. <text class="guide-stats">服务家庭: {{ guide.familyCount || 0 }}</text>
  21. <text class="guide-stats">测评次数: {{ guide.assessmentCount || 0 }}</text>
  22. </view>
  23. <view class="guide-actions">
  24. <text class="action-btn" @click.stop="viewReports(guide)">查看报告</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="empty-state" v-else>
  29. <text class="empty-icon">👥</text>
  30. <text class="empty-text">还没有下级成长规划师</text>
  31. <text class="empty-hint">分享邀请码邀请其他成长规划师加入</text>
  32. </view>
  33. </view>
  34. <!-- 所有下级成长规划师 -->
  35. <view class="section" v-if="allChildGuides.length > 0">
  36. <view class="section-title">所有下级(含间接)</view>
  37. <view class="guide-list">
  38. <view
  39. class="guide-item"
  40. v-for="guide in allChildGuides"
  41. :key="guide.id"
  42. @click="viewGuideDetail(guide)"
  43. >
  44. <image class="guide-avatar" :src="guide.avatar || '/static/default-avatar.png'" mode="aspectFill" />
  45. <view class="guide-info">
  46. <text class="guide-name">{{ guide.nickname || '未命名' }}</text>
  47. <text class="guide-stats">服务家庭: {{ guide.familyCount || 0 }}</text>
  48. <text class="guide-stats">测评次数: {{ guide.assessmentCount || 0 }}</text>
  49. </view>
  50. <view class="guide-actions">
  51. <text class="action-btn" @click.stop="viewReports(guide)">查看报告</text>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 上级成长规划师 -->
  57. <view class="section" v-if="parentGuide">
  58. <view class="section-title">我的上级成长规划师</view>
  59. <view class="parent-guide-card">
  60. <image class="guide-avatar" :src="parentGuide.avatar || '/static/default-avatar.png'" mode="aspectFill" />
  61. <view class="guide-info">
  62. <text class="guide-name">{{ parentGuide.nickname || '未命名' }}</text>
  63. <text class="guide-desc">我的上级成长规划师</text>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import { getChildGuides, getAllChildGuides, getParentGuide } from '../../../utils/api.js'
  71. import fontScaleMixin from '@/mixins/font-scale.js'
  72. export default {
  73. mixins: [fontScaleMixin],
  74. data() {
  75. return {
  76. childGuides: [],
  77. allChildGuides: [],
  78. parentGuide: null
  79. }
  80. },
  81. onLoad() {
  82. this.loadData()
  83. this._onLoadFired = true
  84. },
  85. onShow() {
  86. // 首次进入:onLoad 已加载,跳过避免双发;切 Tab 返回时刷新
  87. if (this._onLoadFired) {
  88. this._onLoadFired = false
  89. } else {
  90. this.loadData()
  91. }
  92. },
  93. methods: {
  94. async loadData() {
  95. try {
  96. const userId = uni.getStorageSync('userId')
  97. // 并行获取数据
  98. const [childRes, allChildRes, parentRes] = await Promise.all([
  99. getChildGuides(userId),
  100. getAllChildGuides(userId),
  101. getParentGuide(userId)
  102. ])
  103. if (childRes.code === 200) {
  104. this.childGuides = childRes.data || []
  105. }
  106. if (allChildRes.code === 200) {
  107. this.allChildGuides = allChildRes.data || []
  108. }
  109. if (parentRes.code === 200) {
  110. this.parentGuide = parentRes.data
  111. }
  112. } catch (e) {
  113. console.error('加载数据失败', e)
  114. }
  115. },
  116. viewGuideDetail(guide) {
  117. uni.showModal({
  118. title: '成长规划师详情',
  119. content: `姓名: ${guide.nickname || '未命名'}\n服务家庭: ${guide.familyCount || 0}\n测评次数: ${guide.assessmentCount || 0}`,
  120. showCancel: false
  121. })
  122. },
  123. viewReports(guide) {
  124. uni.navigateTo({
  125. url: `/pages/assessment/results?guideId=${guide.id}`
  126. })
  127. }
  128. }
  129. }
  130. </script>
  131. <style scoped lang="scss">
  132. .container {
  133. padding: $uni-space-page;
  134. background: $facade-fill-page;
  135. min-height: 100vh;
  136. }
  137. .header {
  138. text-align: center;
  139. padding: 60rpx 0 40rpx;
  140. }
  141. .title {
  142. font-size: calc(48rpx * var(--font-scale, 1));
  143. font-weight: bold;
  144. color: $facade-text-strong;
  145. display: block;
  146. margin-bottom: 20rpx;
  147. }
  148. .subtitle {
  149. font-size: calc(28rpx * var(--font-scale, 1));
  150. color: $facade-text-body;
  151. }
  152. .section {
  153. background: $app-surface;
  154. border-radius: 24rpx;
  155. padding: $uni-space-lg;
  156. margin-bottom: $uni-space-lg;
  157. }
  158. .section-title {
  159. font-size: calc(32rpx * var(--font-scale, 1));
  160. font-weight: bold;
  161. color: $facade-text-strong;
  162. margin-bottom: 20rpx;
  163. }
  164. .guide-list {
  165. display: flex;
  166. flex-direction: column;
  167. gap: 20rpx;
  168. }
  169. .guide-item {
  170. display: flex;
  171. align-items: center;
  172. background: $facade-fill-page;
  173. border-radius: 8rpx;
  174. padding: 20rpx;
  175. }
  176. .guide-avatar {
  177. width: 80rpx;
  178. height: 80rpx;
  179. border-radius: 50%;
  180. object-fit: cover;
  181. margin-right: 20rpx;
  182. }
  183. .guide-info {
  184. flex: 1;
  185. }
  186. .guide-name {
  187. font-size: calc(30rpx * var(--font-scale, 1));
  188. font-weight: bold;
  189. color: $facade-text-strong;
  190. display: block;
  191. margin-bottom: 8rpx;
  192. }
  193. .guide-stats {
  194. font-size: calc(24rpx * var(--font-scale, 1));
  195. color: $facade-text-muted;
  196. display: block;
  197. margin-bottom: 4rpx;
  198. }
  199. .guide-actions {
  200. display: flex;
  201. gap: 10rpx;
  202. }
  203. .action-btn {
  204. font-size: calc(24rpx * var(--font-scale, 1));
  205. color: $accent-indigo;
  206. padding: 8rpx 16rpx;
  207. background: $dim-wisdom-tint-3;
  208. border-radius: 24rpx;
  209. }
  210. .empty-state {
  211. text-align: center;
  212. padding: 60rpx 0;
  213. }
  214. .empty-icon {
  215. font-size: calc($uni-font-size-5xl * var(--font-scale, 1));
  216. display: block;
  217. margin-bottom: 20rpx;
  218. }
  219. .empty-text {
  220. font-size: calc(28rpx * var(--font-scale, 1));
  221. color: $facade-text-muted;
  222. display: block;
  223. margin-bottom: 10rpx;
  224. }
  225. .empty-hint {
  226. font-size: calc(24rpx * var(--font-scale, 1));
  227. color: $facade-text-ghost;
  228. }
  229. .parent-guide-card {
  230. display: flex;
  231. align-items: center;
  232. background: $dim-wisdom-tint-3;
  233. border-radius: 8rpx;
  234. padding: 20rpx;
  235. }
  236. </style>