index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="container">
  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'" />
  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'" />
  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'" />
  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. export default {
  72. data() {
  73. return {
  74. childGuides: [],
  75. allChildGuides: [],
  76. parentGuide: null
  77. }
  78. },
  79. onLoad() {
  80. this.loadData()
  81. this._onLoadFired = true
  82. },
  83. onShow() {
  84. // 首次进入:onLoad 已加载,跳过避免双发;切 Tab 返回时刷新
  85. if (this._onLoadFired) {
  86. this._onLoadFired = false
  87. } else {
  88. this.loadData()
  89. }
  90. },
  91. methods: {
  92. async loadData() {
  93. try {
  94. const userId = uni.getStorageSync('userId')
  95. // 并行获取数据
  96. const [childRes, allChildRes, parentRes] = await Promise.all([
  97. getChildGuides(userId),
  98. getAllChildGuides(userId),
  99. getParentGuide(userId)
  100. ])
  101. if (childRes.code === 200) {
  102. this.childGuides = childRes.data || []
  103. }
  104. if (allChildRes.code === 200) {
  105. this.allChildGuides = allChildRes.data || []
  106. }
  107. if (parentRes.code === 200) {
  108. this.parentGuide = parentRes.data
  109. }
  110. } catch (e) {
  111. console.error('加载数据失败', e)
  112. }
  113. },
  114. viewGuideDetail(guide) {
  115. uni.showModal({
  116. title: '成长规划师详情',
  117. content: `姓名: ${guide.nickname || '未命名'}\n服务家庭: ${guide.familyCount || 0}\n测评次数: ${guide.assessmentCount || 0}`,
  118. showCancel: false
  119. })
  120. },
  121. viewReports(guide) {
  122. uni.navigateTo({
  123. url: `/pages/assessment/results?guideId=${guide.id}`
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped>
  130. .container {
  131. padding: 30rpx;
  132. background: #F8F8F8;
  133. min-height: 100vh;
  134. }
  135. .header {
  136. text-align: center;
  137. padding: 60rpx 0 40rpx;
  138. }
  139. .title {
  140. font-size: 48rpx;
  141. font-weight: bold;
  142. color: #333;
  143. display: block;
  144. margin-bottom: 20rpx;
  145. }
  146. .subtitle {
  147. font-size: 28rpx;
  148. color: #666;
  149. }
  150. .section {
  151. background: #fff;
  152. border-radius: 20rpx;
  153. padding: 30rpx;
  154. margin-bottom: 30rpx;
  155. }
  156. .section-title {
  157. font-size: 32rpx;
  158. font-weight: bold;
  159. color: #333;
  160. margin-bottom: 20rpx;
  161. }
  162. .guide-list {
  163. display: flex;
  164. flex-direction: column;
  165. gap: 20rpx;
  166. }
  167. .guide-item {
  168. display: flex;
  169. align-items: center;
  170. background: #F8F8F8;
  171. border-radius: 10rpx;
  172. padding: 20rpx;
  173. }
  174. .guide-avatar {
  175. width: 80rpx;
  176. height: 80rpx;
  177. border-radius: 50%;
  178. object-fit: cover;
  179. margin-right: 20rpx;
  180. }
  181. .guide-info {
  182. flex: 1;
  183. }
  184. .guide-name {
  185. font-size: 30rpx;
  186. font-weight: bold;
  187. color: #333;
  188. display: block;
  189. margin-bottom: 8rpx;
  190. }
  191. .guide-stats {
  192. font-size: 24rpx;
  193. color: #999;
  194. display: block;
  195. margin-bottom: 4rpx;
  196. }
  197. .guide-actions {
  198. display: flex;
  199. gap: 10rpx;
  200. }
  201. .action-btn {
  202. font-size: 24rpx;
  203. color: #667eea;
  204. padding: 8rpx 16rpx;
  205. background: #F0F4FF;
  206. border-radius: 20rpx;
  207. }
  208. .empty-state {
  209. text-align: center;
  210. padding: 60rpx 0;
  211. }
  212. .empty-icon {
  213. font-size: 80rpx;
  214. display: block;
  215. margin-bottom: 20rpx;
  216. }
  217. .empty-text {
  218. font-size: 28rpx;
  219. color: #999;
  220. display: block;
  221. margin-bottom: 10rpx;
  222. }
  223. .empty-hint {
  224. font-size: 24rpx;
  225. color: #CCC;
  226. }
  227. .parent-guide-card {
  228. display: flex;
  229. align-items: center;
  230. background: #F0F4FF;
  231. border-radius: 10rpx;
  232. padding: 20rpx;
  233. }
  234. </style>