team-system.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. this._onLoadFired = true
  148. },
  149. onShow() {
  150. if (this._onLoadFired) {
  151. // 首次进入:onLoad 已加载,跳过避免双发
  152. this._onLoadFired = false
  153. } else {
  154. this.loadData()
  155. }
  156. },
  157. methods: {
  158. async loadData() {
  159. try {
  160. // 并发获取所有数据
  161. const [systemRes, hierarchyRes, membersRes, customersRes] = await Promise.all([
  162. this.fetchSystemInfo(),
  163. this.fetchHierarchyInfo(),
  164. this.fetchTeamMembers(),
  165. this.fetchTeamCustomers()
  166. ])
  167. if (systemRes) {
  168. this.systemInfo = systemRes
  169. }
  170. if (hierarchyRes) {
  171. this.hierarchyInfo = hierarchyRes
  172. }
  173. if (membersRes) {
  174. this.teamMembers = membersRes
  175. }
  176. if (customersRes) {
  177. this.teamCustomers = customersRes
  178. }
  179. // 更新统计
  180. this.updateStats()
  181. } catch (error) {
  182. console.error('加载团队数据失败:', error)
  183. }
  184. },
  185. // 获取体系信息
  186. async fetchSystemInfo() {
  187. try {
  188. const res = await getVendorSystemInfo()
  189. return res.data || null
  190. } catch (e) {
  191. return null
  192. }
  193. },
  194. // 获取层级关系
  195. async fetchHierarchyInfo() {
  196. try {
  197. const res = await getVendorHierarchyInfo()
  198. return res.data || null
  199. } catch (e) {
  200. return null
  201. }
  202. },
  203. // 获取团队成员
  204. async fetchTeamMembers() {
  205. try {
  206. const res = await getVendorTeamMembers(this.systemInfo?.id)
  207. return res.data || []
  208. } catch (e) {
  209. return []
  210. }
  211. },
  212. // 获取团队客户
  213. async fetchTeamCustomers() {
  214. try {
  215. const res = await getVendorTeamCustomers({
  216. systemId: this.systemInfo?.id,
  217. parentId: null,
  218. page: 1,
  219. size: 50
  220. })
  221. return res.data || []
  222. } catch (e) {
  223. return []
  224. }
  225. },
  226. // 更新统计数据
  227. updateStats() {
  228. this.teamStats.memberCount = this.teamMembers.length
  229. this.teamStats.customerCount = this.teamCustomers.length
  230. },
  231. // 跳转管理页面
  232. goToManage() {
  233. uni.navigateTo({
  234. url: '/pages/vendor/team-manage/team-manage'
  235. })
  236. },
  237. // 跳转客户列表
  238. goToCustomers() {
  239. uni.navigateTo({
  240. url: '/pages/vendor/team-customers/team-customers'
  241. })
  242. }
  243. }
  244. }
  245. </script>
  246. <style>
  247. .page-team-system {
  248. background-color: #FFF7ED;
  249. min-height: 100vh;
  250. padding-bottom: 100rpx;
  251. }
  252. /* 体系头部 */
  253. .system-header {
  254. background-color: #fff;
  255. padding: 30rpx;
  256. margin-bottom: 24rpx;
  257. display: flex;
  258. justify-content: space-between;
  259. align-items: center;
  260. box-shadow: 0 2rpx 12rpx rgba(249,115,22,0.08);
  261. }
  262. .system-info {
  263. display: flex;
  264. align-items: center;
  265. }
  266. .system-icon {
  267. font-size: 64rpx;
  268. margin-right: 20rpx;
  269. }
  270. .system-name {
  271. font-size: 32rpx;
  272. font-weight: bold;
  273. color: #333;
  274. }
  275. .system-desc {
  276. font-size: 24rpx;
  277. color: #94A3B8;
  278. margin-top: 4rpx;
  279. }
  280. .system-status {
  281. padding: 8rpx 20rpx;
  282. border-radius: 20rpx;
  283. font-size: 24rpx;
  284. }
  285. .system-status.active {
  286. background-color: #E6F7EE;
  287. color: #65C29A;
  288. }
  289. .system-status.inactive {
  290. background-color: #FFF7EE;
  291. color: #F97316;
  292. }
  293. /* 区块 */
  294. .section {
  295. background-color: #fff;
  296. border-radius: 20rpx;
  297. padding: 24rpx;
  298. margin: 0 30rpx 24rpx;
  299. box-shadow: 0 2rpx 12rpx rgba(249,115,22,0.08);
  300. }
  301. .section-header {
  302. display: flex;
  303. justify-content: space-between;
  304. align-items: center;
  305. margin-bottom: 24rpx;
  306. }
  307. .section-title {
  308. font-size: 28rpx;
  309. font-weight: bold;
  310. color: #333;
  311. }
  312. .section-action {
  313. font-size: 24rpx;
  314. color: #F97316;
  315. }
  316. /* 层级关系 */
  317. .hierarchy-grid {
  318. display: flex;
  319. flex-wrap: wrap;
  320. }
  321. .hierarchy-item {
  322. flex: 1;
  323. min-width: 48%;
  324. padding: 20rpx;
  325. background-color: #FFF7ED;
  326. border-radius: 12rpx;
  327. margin-bottom: 16rpx;
  328. }
  329. .hierarchy-label {
  330. font-size: 24rpx;
  331. color: #666;
  332. margin-bottom: 12rpx;
  333. }
  334. .hierarchy-person {
  335. display: flex;
  336. align-items: center;
  337. }
  338. .avatar-img {
  339. width: 64rpx;
  340. height: 64rpx;
  341. border-radius: 50%;
  342. margin-right: 16rpx;
  343. }
  344. .avatar-placeholder {
  345. width: 64rpx;
  346. height: 64rpx;
  347. border-radius: 50%;
  348. background-color: #F5FAFE;
  349. display: flex;
  350. align-items: center;
  351. justify-content: center;
  352. font-size: 32rpx;
  353. margin-right: 16rpx;
  354. }
  355. .person-info {
  356. flex: 1;
  357. }
  358. .person-name {
  359. font-size: 26rpx;
  360. color: #333;
  361. display: block;
  362. }
  363. .person-level {
  364. font-size: 20rpx;
  365. color: #94A3B8;
  366. }
  367. .hierarchy-empty {
  368. font-size: 24rpx;
  369. color: #94A3B8;
  370. }
  371. .hierarchy-stat {
  372. flex: 1;
  373. min-width: 48%;
  374. padding: 20rpx;
  375. background-color: #F5FAFE;
  376. border-radius: 12rpx;
  377. text-align: center;
  378. }
  379. .stat-value {
  380. font-size: 40rpx;
  381. font-weight: bold;
  382. color: #2F5496;
  383. display: block;
  384. }
  385. .stat-label {
  386. font-size: 22rpx;
  387. color: #666;
  388. }
  389. /* 统计网格 */
  390. .stats-grid {
  391. display: flex;
  392. flex-wrap: wrap;
  393. }
  394. .stat-card {
  395. width: 50%;
  396. padding: 20rpx;
  397. text-align: center;
  398. border-right: 1rpx solid #FED7AA;
  399. border-bottom: 1rpx solid #FED7AA;
  400. }
  401. .stat-num {
  402. font-size: 36rpx;
  403. font-weight: bold;
  404. color: #F97316;
  405. display: block;
  406. }
  407. .stat-name {
  408. font-size: 22rpx;
  409. color: #666;
  410. }
  411. /* 成员列表 */
  412. .member-item {
  413. display: flex;
  414. align-items: center;
  415. padding: 16rpx 0;
  416. border-bottom: 1rpx solid #FED7AA;
  417. }
  418. .member-item:last-child {
  419. border-bottom: none;
  420. }
  421. .member-avatar {
  422. width: 64rpx;
  423. height: 64rpx;
  424. border-radius: 50%;
  425. margin-right: 16rpx;
  426. }
  427. .member-avatar-placeholder {
  428. width: 64rpx;
  429. height: 64rpx;
  430. border-radius: 50%;
  431. background-color: #F5FAFE;
  432. display: flex;
  433. align-items: center;
  434. justify-content: center;
  435. font-size: 32rpx;
  436. margin-right: 16rpx;
  437. }
  438. .member-info {
  439. flex: 1;
  440. }
  441. .member-name {
  442. font-size: 26rpx;
  443. color: #333;
  444. display: block;
  445. }
  446. .member-role {
  447. font-size: 20rpx;
  448. color: #94A3B8;
  449. }
  450. .member-stats {
  451. text-align: right;
  452. }
  453. .member-count {
  454. font-size: 28rpx;
  455. font-weight: bold;
  456. color: #F97316;
  457. display: block;
  458. }
  459. .member-label {
  460. font-size: 20rpx;
  461. color: #666;
  462. }
  463. .empty-tip {
  464. text-align: center;
  465. padding: 40rpx;
  466. color: #94A3B8;
  467. font-size: 26rpx;
  468. }
  469. /* 客户列表 */
  470. .customer-item {
  471. display: flex;
  472. align-items: center;
  473. padding: 16rpx 0;
  474. border-bottom: 1rpx solid #FED7AA;
  475. }
  476. .customer-item:last-child {
  477. border-bottom: none;
  478. }
  479. .customer-avatar {
  480. width: 64rpx;
  481. height: 64rpx;
  482. border-radius: 50%;
  483. background-color: #F5FAFE;
  484. display: flex;
  485. align-items: center;
  486. justify-content: center;
  487. margin-right: 16rpx;
  488. }
  489. .customer-icon {
  490. font-size: 32rpx;
  491. }
  492. .customer-info {
  493. flex: 1;
  494. }
  495. .customer-name {
  496. font-size: 26rpx;
  497. color: #333;
  498. display: block;
  499. }
  500. .customer-meta {
  501. font-size: 20rpx;
  502. color: #94A3B8;
  503. }
  504. .customer-stats {
  505. text-align: right;
  506. }
  507. .customer-orders {
  508. font-size: 28rpx;
  509. font-weight: bold;
  510. color: #F97316;
  511. display: block;
  512. }
  513. .customer-label {
  514. font-size: 20rpx;
  515. color: #666;
  516. }
  517. /* 操作按钮 */
  518. .action-bar {
  519. position: fixed;
  520. bottom: 0;
  521. left: 0;
  522. right: 0;
  523. background-color: #fff;
  524. padding: 20rpx 30rpx;
  525. display: flex;
  526. gap: 20rpx;
  527. box-shadow: 0 -2rpx 12rpx rgba(0,0,0,0.05);
  528. }
  529. .btn-manage, .btn-customers {
  530. flex: 1;
  531. height: 80rpx;
  532. line-height: 80rpx;
  533. border-radius: 40rpx;
  534. font-size: 28rpx;
  535. border: none;
  536. }
  537. .btn-manage {
  538. background-color: #F97316;
  539. color: #fff;
  540. }
  541. .btn-customers {
  542. background-color: #fff;
  543. color: #F97316;
  544. border: 2rpx solid #F97316;
  545. }
  546. </style>