index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. <!-- 邀请码分享 -->
  68. <view class="section">
  69. <view class="section-title">邀请下级成长规划师</view>
  70. <button class="btn-share" @click="goToShare">
  71. <text class="btn-icon">📤</text>
  72. <text class="btn-text">分享邀请码</text>
  73. </button>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import { getChildGuides, getAllChildGuides, getParentGuide } from '../../../utils/api.js'
  79. export default {
  80. data() {
  81. return {
  82. childGuides: [],
  83. allChildGuides: [],
  84. parentGuide: null
  85. }
  86. },
  87. onLoad() {
  88. this.loadData()
  89. },
  90. onShow() {
  91. this.loadData()
  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. goToShare() {
  129. uni.navigateTo({
  130. url: '/pages/guide/invite/share'
  131. })
  132. }
  133. }
  134. }
  135. </script>
  136. <style scoped>
  137. .container {
  138. padding: 30rpx;
  139. background: #F8F8F8;
  140. min-height: 100vh;
  141. }
  142. .header {
  143. text-align: center;
  144. padding: 60rpx 0 40rpx;
  145. }
  146. .title {
  147. font-size: 48rpx;
  148. font-weight: bold;
  149. color: #333;
  150. display: block;
  151. margin-bottom: 20rpx;
  152. }
  153. .subtitle {
  154. font-size: 28rpx;
  155. color: #666;
  156. }
  157. .section {
  158. background: #fff;
  159. border-radius: 20rpx;
  160. padding: 30rpx;
  161. margin-bottom: 30rpx;
  162. }
  163. .section-title {
  164. font-size: 32rpx;
  165. font-weight: bold;
  166. color: #333;
  167. margin-bottom: 20rpx;
  168. }
  169. .guide-list {
  170. display: flex;
  171. flex-direction: column;
  172. gap: 20rpx;
  173. }
  174. .guide-item {
  175. display: flex;
  176. align-items: center;
  177. background: #F8F8F8;
  178. border-radius: 10rpx;
  179. padding: 20rpx;
  180. }
  181. .guide-avatar {
  182. width: 80rpx;
  183. height: 80rpx;
  184. border-radius: 50%;
  185. object-fit: cover;
  186. margin-right: 20rpx;
  187. }
  188. .guide-info {
  189. flex: 1;
  190. }
  191. .guide-name {
  192. font-size: 30rpx;
  193. font-weight: bold;
  194. color: #333;
  195. display: block;
  196. margin-bottom: 8rpx;
  197. }
  198. .guide-stats {
  199. font-size: 24rpx;
  200. color: #999;
  201. display: block;
  202. margin-bottom: 4rpx;
  203. }
  204. .guide-actions {
  205. display: flex;
  206. gap: 10rpx;
  207. }
  208. .action-btn {
  209. font-size: 24rpx;
  210. color: #667eea;
  211. padding: 8rpx 16rpx;
  212. background: #F0F4FF;
  213. border-radius: 20rpx;
  214. }
  215. .empty-state {
  216. text-align: center;
  217. padding: 60rpx 0;
  218. }
  219. .empty-icon {
  220. font-size: 80rpx;
  221. display: block;
  222. margin-bottom: 20rpx;
  223. }
  224. .empty-text {
  225. font-size: 28rpx;
  226. color: #999;
  227. display: block;
  228. margin-bottom: 10rpx;
  229. }
  230. .empty-hint {
  231. font-size: 24rpx;
  232. color: #CCC;
  233. }
  234. .parent-guide-card {
  235. display: flex;
  236. align-items: center;
  237. background: #F0F4FF;
  238. border-radius: 10rpx;
  239. padding: 20rpx;
  240. }
  241. .btn-share {
  242. width: 100%;
  243. height: 80rpx;
  244. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  245. color: #fff;
  246. border-radius: 40rpx;
  247. font-size: 28rpx;
  248. font-weight: bold;
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. gap: 10rpx;
  253. }
  254. .btn-icon {
  255. font-size: 32rpx;
  256. }
  257. .btn-text {
  258. font-size: 28rpx;
  259. }
  260. </style>