team-system.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. <template>
  2. <view class="page-team-system">
  3. <!-- 头部:体系信息 -->
  4. <view class="system-header" v-if="systemInfo">
  5. <view class="system-info">
  6. <view class="system-icon">🏢</view>
  7. <view class="system-detail">
  8. <text class="system-name">{{ systemInfo.name || '我的供应商体系' }}</text>
  9. <text class="system-desc">服务商团队管理</text>
  10. </view>
  11. </view>
  12. <view class="system-status" :class="systemInfo.status">
  13. <text>{{ systemInfo.status === 'active' ? '活跃' : '未激活' }}</text>
  14. </view>
  15. </view>
  16. <!-- 层级关系 -->
  17. <view class="section" v-if="hierarchyInfo">
  18. <view class="section-header">
  19. <text class="section-title">层级关系</text>
  20. </view>
  21. <view class="hierarchy-grid">
  22. <!-- 上级 -->
  23. <view class="hierarchy-item" v-if="hierarchyInfo.parent">
  24. <view class="hierarchy-label">上级服务商</view>
  25. <view class="hierarchy-person">
  26. <image v-if="hierarchyInfo.parent.avatar" class="avatar-img" :src="hierarchyInfo.parent.avatar" mode="aspectFill"></image>
  27. <text v-else class="avatar-placeholder">👤</text>
  28. <view class="person-info">
  29. <text class="person-name">{{ hierarchyInfo.parent.nickname || '服务商' }}</text>
  30. <text class="person-level">上级</text>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 下级 -->
  35. <view class="hierarchy-item" v-else>
  36. <view class="hierarchy-label">下级服务商</view>
  37. <view class="hierarchy-empty">
  38. <text>暂无下级</text>
  39. </view>
  40. </view>
  41. <!-- 团队规模 -->
  42. <view class="hierarchy-stat">
  43. <text class="stat-value">{{ hierarchyInfo.totalChildren || 0 }}</text>
  44. <text class="stat-label">团队成员</text>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 团队统计 -->
  49. <view class="section">
  50. <view class="section-header">
  51. <text class="section-title">团队数据</text>
  52. </view>
  53. <view class="stats-grid">
  54. <view class="stat-card">
  55. <text class="stat-num">{{ teamStats.memberCount || 0 }}</text>
  56. <text class="stat-name">团队成员</text>
  57. </view>
  58. <view class="stat-card">
  59. <text class="stat-num">{{ teamStats.customerCount || 0 }}</text>
  60. <text class="stat-name">客户归属</text>
  61. </view>
  62. <view class="stat-card">
  63. <text class="stat-num">{{ teamStats.orderCount || 0 }}</text>
  64. <text class="stat-name">关联订单</text>
  65. </view>
  66. <view class="stat-card">
  67. <text class="stat-num">{{ teamStats.amount || 0 }}</text>
  68. <text class="stat-name">关联金额(元)</text>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 团队成员列表 -->
  73. <view class="section">
  74. <view class="section-header">
  75. <text class="section-title">团队成员</text>
  76. <text class="section-action" @click="goToMembers">查看全部</text>
  77. </view>
  78. <view class="member-list">
  79. <view class="member-item" v-for="member in teamMembers.slice(0, 5)" :key="member.userId">
  80. <image v-if="member.avatar" class="member-avatar" :src="member.avatar" mode="aspectFill"></image>
  81. <text v-else class="member-avatar-placeholder">👤</text>
  82. <view class="member-info">
  83. <text class="member-name">{{ member.nickname || '微信用户' }}</text>
  84. <text class="member-role">{{ member.role || '成员' }}</text>
  85. </view>
  86. <view class="member-stats">
  87. <text class="member-count">{{ member.customerCount || 0 }}</text>
  88. <text class="member-label">客户</text>
  89. </view>
  90. </view>
  91. <view class="empty-tip" v-if="teamMembers.length === 0">
  92. <text>暂无团队成员</text>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 团队客户列表 -->
  97. <view class="section">
  98. <view class="section-header">
  99. <text class="section-title">团队客户</text>
  100. <text class="section-action" @click="goToCustomers">查看全部</text>
  101. </view>
  102. <view class="customer-list">
  103. <view class="customer-item" v-for="customer in teamCustomers.slice(0, 5)" :key="customer.id">
  104. <view class="customer-avatar">
  105. <text class="customer-icon">👥</text>
  106. </view>
  107. <view class="customer-info">
  108. <text class="customer-name">{{ customer.familyName || '未知家庭' }}</text>
  109. <text class="customer-meta">{{ customer.source === 'manual' ? '人工绑定' : customer.source === 'order' ? '下单自动' : '推荐码' }}</text>
  110. </view>
  111. <view class="customer-stats">
  112. <text class="customer-orders">{{ customer.orderCount || 0 }}</text>
  113. <text class="customer-label">订单</text>
  114. </view>
  115. </view>
  116. <view class="empty-tip" v-if="teamCustomers.length === 0">
  117. <text>暂无客户数据</text>
  118. </view>
  119. </view>
  120. </view>
  121. <!-- 操作按钮 -->
  122. <view class="action-bar">
  123. <button class="btn-manage" @click="goToManage">团队管理</button>
  124. <button class="btn-customers" @click="goToCustomers">客户列表</button>
  125. </view>
  126. </view>
  127. </template>
  128. <script>
  129. import { getVendorSystemInfo, getVendorHierarchyInfo, getVendorTeamMembers, getVendorTeamCustomers } from '@/utils/api.js'
  130. export default {
  131. data() {
  132. return {
  133. systemInfo: null,
  134. hierarchyInfo: null,
  135. teamStats: {
  136. memberCount: 0,
  137. customerCount: 0,
  138. orderCount: 0,
  139. amount: 0
  140. },
  141. teamMembers: [],
  142. teamCustomers: []
  143. }
  144. },
  145. onLoad() {
  146. this.loadData()
  147. },
  148. onShow() {
  149. this.loadData()
  150. },
  151. methods: {
  152. async loadData() {
  153. try {
  154. // 并发获取所有数据
  155. const [systemRes, hierarchyRes, membersRes, customersRes] = await Promise.all([
  156. this.fetchSystemInfo(),
  157. this.fetchHierarchyInfo(),
  158. this.fetchTeamMembers(),
  159. this.fetchTeamCustomers()
  160. ])
  161. if (systemRes) {
  162. this.systemInfo = systemRes
  163. }
  164. if (hierarchyRes) {
  165. this.hierarchyInfo = hierarchyRes
  166. }
  167. if (membersRes) {
  168. this.teamMembers = membersRes
  169. }
  170. if (customersRes) {
  171. this.teamCustomers = customersRes
  172. }
  173. // 更新统计
  174. this.updateStats()
  175. } catch (error) {
  176. console.error('加载团队数据失败:', error)
  177. }
  178. },
  179. // 获取体系信息
  180. async fetchSystemInfo() {
  181. try {
  182. const res = await getVendorSystemInfo()
  183. return res.data || null
  184. } catch (e) {
  185. return null
  186. }
  187. },
  188. // 获取层级关系
  189. async fetchHierarchyInfo() {
  190. try {
  191. const res = await getVendorHierarchyInfo()
  192. return res.data || null
  193. } catch (e) {
  194. return null
  195. }
  196. },
  197. // 获取团队成员
  198. async fetchTeamMembers() {
  199. try {
  200. const res = await getVendorTeamMembers(this.systemInfo?.id)
  201. return res.data || []
  202. } catch (e) {
  203. return []
  204. }
  205. },
  206. // 获取团队客户
  207. async fetchTeamCustomers() {
  208. try {
  209. const res = await getVendorTeamCustomers({
  210. systemId: this.systemInfo?.id,
  211. parentId: null,
  212. page: 1,
  213. size: 50
  214. })
  215. return res.data || []
  216. } catch (e) {
  217. return []
  218. }
  219. },
  220. // 更新统计数据
  221. updateStats() {
  222. this.teamStats.memberCount = this.teamMembers.length
  223. this.teamStats.customerCount = this.teamCustomers.length
  224. },
  225. // 跳转管理页面
  226. goToManage() {
  227. uni.navigateTo({
  228. url: '/pages/vendor/team-manage/team-manage'
  229. })
  230. },
  231. // 跳转客户列表
  232. goToCustomers() {
  233. uni.navigateTo({
  234. url: '/pages/vendor/team-customers/team-customers'
  235. })
  236. }
  237. }
  238. }
  239. </script>
  240. <style>
  241. .page-team-system {
  242. background-color: #FFF7ED;
  243. min-height: 100vh;
  244. padding-bottom: 100rpx;
  245. }
  246. /* 体系头部 */
  247. .system-header {
  248. background-color: #fff;
  249. padding: 30rpx;
  250. margin-bottom: 24rpx;
  251. display: flex;
  252. justify-content: space-between;
  253. align-items: center;
  254. box-shadow: 0 2rpx 12rpx rgba(249,115,22,0.08);
  255. }
  256. .system-info {
  257. display: flex;
  258. align-items: center;
  259. }
  260. .system-icon {
  261. font-size: 64rpx;
  262. margin-right: 20rpx;
  263. }
  264. .system-name {
  265. font-size: 32rpx;
  266. font-weight: bold;
  267. color: #333;
  268. }
  269. .system-desc {
  270. font-size: 24rpx;
  271. color: #94A3B8;
  272. margin-top: 4rpx;
  273. }
  274. .system-status {
  275. padding: 8rpx 20rpx;
  276. border-radius: 20rpx;
  277. font-size: 24rpx;
  278. }
  279. .system-status.active {
  280. background-color: #E6F7EE;
  281. color: #65C29A;
  282. }
  283. .system-status.inactive {
  284. background-color: #FFF7EE;
  285. color: #F97316;
  286. }
  287. /* 区块 */
  288. .section {
  289. background-color: #fff;
  290. border-radius: 20rpx;
  291. padding: 24rpx;
  292. margin: 0 30rpx 24rpx;
  293. box-shadow: 0 2rpx 12rpx rgba(249,115,22,0.08);
  294. }
  295. .section-header {
  296. display: flex;
  297. justify-content: space-between;
  298. align-items: center;
  299. margin-bottom: 24rpx;
  300. }
  301. .section-title {
  302. font-size: 28rpx;
  303. font-weight: bold;
  304. color: #333;
  305. }
  306. .section-action {
  307. font-size: 24rpx;
  308. color: #F97316;
  309. }
  310. /* 层级关系 */
  311. .hierarchy-grid {
  312. display: flex;
  313. flex-wrap: wrap;
  314. }
  315. .hierarchy-item {
  316. flex: 1;
  317. min-width: 48%;
  318. padding: 20rpx;
  319. background-color: #FFF7ED;
  320. border-radius: 12rpx;
  321. margin-bottom: 16rpx;
  322. }
  323. .hierarchy-label {
  324. font-size: 24rpx;
  325. color: #666;
  326. margin-bottom: 12rpx;
  327. }
  328. .hierarchy-person {
  329. display: flex;
  330. align-items: center;
  331. }
  332. .avatar-img {
  333. width: 64rpx;
  334. height: 64rpx;
  335. border-radius: 50%;
  336. margin-right: 16rpx;
  337. }
  338. .avatar-placeholder {
  339. width: 64rpx;
  340. height: 64rpx;
  341. border-radius: 50%;
  342. background-color: #F5FAFE;
  343. display: flex;
  344. align-items: center;
  345. justify-content: center;
  346. font-size: 32rpx;
  347. margin-right: 16rpx;
  348. }
  349. .person-info {
  350. flex: 1;
  351. }
  352. .person-name {
  353. font-size: 26rpx;
  354. color: #333;
  355. display: block;
  356. }
  357. .person-level {
  358. font-size: 20rpx;
  359. color: #94A3B8;
  360. }
  361. .hierarchy-empty {
  362. font-size: 24rpx;
  363. color: #94A3B8;
  364. }
  365. .hierarchy-stat {
  366. flex: 1;
  367. min-width: 48%;
  368. padding: 20rpx;
  369. background-color: #F5FAFE;
  370. border-radius: 12rpx;
  371. text-align: center;
  372. }
  373. .stat-value {
  374. font-size: 40rpx;
  375. font-weight: bold;
  376. color: #2F5496;
  377. display: block;
  378. }
  379. .stat-label {
  380. font-size: 22rpx;
  381. color: #666;
  382. }
  383. /* 统计网格 */
  384. .stats-grid {
  385. display: flex;
  386. flex-wrap: wrap;
  387. }
  388. .stat-card {
  389. width: 50%;
  390. padding: 20rpx;
  391. text-align: center;
  392. border-right: 1rpx solid #FED7AA;
  393. border-bottom: 1rpx solid #FED7AA;
  394. }
  395. .stat-num {
  396. font-size: 36rpx;
  397. font-weight: bold;
  398. color: #F97316;
  399. display: block;
  400. }
  401. .stat-name {
  402. font-size: 22rpx;
  403. color: #666;
  404. }
  405. /* 成员列表 */
  406. .member-item {
  407. display: flex;
  408. align-items: center;
  409. padding: 16rpx 0;
  410. border-bottom: 1rpx solid #FED7AA;
  411. }
  412. .member-item:last-child {
  413. border-bottom: none;
  414. }
  415. .member-avatar {
  416. width: 64rpx;
  417. height: 64rpx;
  418. border-radius: 50%;
  419. margin-right: 16rpx;
  420. }
  421. .member-avatar-placeholder {
  422. width: 64rpx;
  423. height: 64rpx;
  424. border-radius: 50%;
  425. background-color: #F5FAFE;
  426. display: flex;
  427. align-items: center;
  428. justify-content: center;
  429. font-size: 32rpx;
  430. margin-right: 16rpx;
  431. }
  432. .member-info {
  433. flex: 1;
  434. }
  435. .member-name {
  436. font-size: 26rpx;
  437. color: #333;
  438. display: block;
  439. }
  440. .member-role {
  441. font-size: 20rpx;
  442. color: #94A3B8;
  443. }
  444. .member-stats {
  445. text-align: right;
  446. }
  447. .member-count {
  448. font-size: 28rpx;
  449. font-weight: bold;
  450. color: #F97316;
  451. display: block;
  452. }
  453. .member-label {
  454. font-size: 20rpx;
  455. color: #666;
  456. }
  457. .empty-tip {
  458. text-align: center;
  459. padding: 40rpx;
  460. color: #94A3B8;
  461. font-size: 26rpx;
  462. }
  463. /* 客户列表 */
  464. .customer-item {
  465. display: flex;
  466. align-items: center;
  467. padding: 16rpx 0;
  468. border-bottom: 1rpx solid #FED7AA;
  469. }
  470. .customer-item:last-child {
  471. border-bottom: none;
  472. }
  473. .customer-avatar {
  474. width: 64rpx;
  475. height: 64rpx;
  476. border-radius: 50%;
  477. background-color: #F5FAFE;
  478. display: flex;
  479. align-items: center;
  480. justify-content: center;
  481. margin-right: 16rpx;
  482. }
  483. .customer-icon {
  484. font-size: 32rpx;
  485. }
  486. .customer-info {
  487. flex: 1;
  488. }
  489. .customer-name {
  490. font-size: 26rpx;
  491. color: #333;
  492. display: block;
  493. }
  494. .customer-meta {
  495. font-size: 20rpx;
  496. color: #94A3B8;
  497. }
  498. .customer-stats {
  499. text-align: right;
  500. }
  501. .customer-orders {
  502. font-size: 28rpx;
  503. font-weight: bold;
  504. color: #F97316;
  505. display: block;
  506. }
  507. .customer-label {
  508. font-size: 20rpx;
  509. color: #666;
  510. }
  511. /* 操作按钮 */
  512. .action-bar {
  513. position: fixed;
  514. bottom: 0;
  515. left: 0;
  516. right: 0;
  517. background-color: #fff;
  518. padding: 20rpx 30rpx;
  519. display: flex;
  520. gap: 20rpx;
  521. box-shadow: 0 -2rpx 12rpx rgba(0,0,0,0.05);
  522. }
  523. .btn-manage, .btn-customers {
  524. flex: 1;
  525. height: 80rpx;
  526. line-height: 80rpx;
  527. border-radius: 40rpx;
  528. font-size: 28rpx;
  529. border: none;
  530. }
  531. .btn-manage {
  532. background-color: #F97316;
  533. color: #fff;
  534. }
  535. .btn-customers {
  536. background-color: #fff;
  537. color: #F97316;
  538. border: 2rpx solid #F97316;
  539. }
  540. </style>