team.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. <!-- 页面 TODO 芋艿:该页面的实现代码需要优化,包括 js 和 css,以及相关的样式设计 -->
  2. <template>
  3. <s-layout title="我的团队" :class="state.scrollTop ? 'team-wrap' : ''" navbar="inner">
  4. <view
  5. class="header-box"
  6. :style="[
  7. {
  8. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  9. paddingTop: Number(statusBarHeight + 108) + 'rpx',
  10. },
  11. ]"
  12. >
  13. <!-- 推广数据总览 -->
  14. <view class="team-data-box ss-flex ss-col-center ss-row-between" style="width: 100%">
  15. <view class="data-card" style="width: 100%">
  16. <view class="total-item" style="width: 100%">
  17. <view class="item-title" style="text-align: center">推广人数</view>
  18. <view class="total-num" style="text-align: center">
  19. {{ state.summary.firstBrokerageUserCount + state.summary.secondBrokerageUserCount || 0 }}
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="promoter-list">
  26. <!--<view
  27. class="promoterHeader bg-color"
  28. style="backgroundcolor: #e93323 !important; height: 218rpx; color: #fff"
  29. >
  30. <view class="headerCon acea-row row-between" style="padding: 28px 29px 0 29px">
  31. <view>
  32. <view class="name" style="color: #fff">推广人数</view>
  33. <view>
  34. <text class="num" style="color: #fff">
  35. {{
  36. state.summary.firstBrokerageUserCount + state.summary.secondBrokerageUserCount ||
  37. 0
  38. }}
  39. </text>
  40. </view>
  41. </view>
  42. <view class="iconfont icon-tuandui" />
  43. </view>
  44. </view>-->
  45. <view style="padding: 0 20rpx">
  46. <view class="nav acea-row row-around l1" style="margin-top:20rpx;">
  47. <view :class="state.level == 1 ? 'item on' : 'item'" @click="setType(1)">
  48. 一级({{ state.summary.firstBrokerageUserCount || 0 }})
  49. </view>
  50. <view :class="state.level == 2 ? 'item on' : 'item'" @click="setType(2)">
  51. 二级({{ state.summary.secondBrokerageUserCount || 0 }})
  52. </view>
  53. </view>
  54. <view
  55. class="search acea-row row-between-wrapper"
  56. style="display: flex; height: 100rpx; align-items: center"
  57. >
  58. <view class="input">
  59. <input
  60. placeholder="点击搜索会员名称"
  61. v-model="state.nickname"
  62. confirm-type="search"
  63. name="search"
  64. @confirm="submitForm"
  65. />
  66. </view>
  67. <image
  68. src="/static/images/search.png"
  69. mode=""
  70. style="width: 60rpx; height: 64rpx"
  71. @click="submitForm"
  72. />
  73. </view>
  74. <view class="list">
  75. <view class="sortNav acea-row row-middle" style="display: flex; align-items: center">
  76. <view
  77. class="sortItem"
  78. @click="setSort('userCount', 'asc')"
  79. v-if="sort === 'userCountDESC'"
  80. >
  81. 团队排序
  82. <!-- TODO 芋艿:看看怎么从项目里拿出去 -->
  83. <image src="/static/images/sort1.png" />
  84. </view>
  85. <view
  86. class="sortItem"
  87. @click="setSort('userCount', 'desc')"
  88. v-else-if="sort === 'userCountASC'"
  89. >
  90. 团队排序
  91. <image src="/static/images/sort3.png" />
  92. </view>
  93. <view class="sortItem" @click="setSort('userCount', 'desc')" v-else>
  94. 团队排序
  95. <image src="/static/images/sort2.png" />
  96. </view>
  97. <view class="sortItem" @click="setSort('price', 'asc')" v-if="sort === 'priceDESC'">
  98. 金额排序
  99. <image src="/static/images/sort1.png" />
  100. </view>
  101. <view
  102. class="sortItem"
  103. @click="setSort('price', 'desc')"
  104. v-else-if="sort === 'priceASC'"
  105. >
  106. 金额排序
  107. <image src="/static/images/sort3.png" />
  108. </view>
  109. <view class="sortItem" @click="setSort('price', 'desc')" v-else>
  110. 金额排序
  111. <image src="/static/images/sort2.png" />
  112. </view>
  113. <view
  114. class="sortItem"
  115. @click="setSort('orderCount', 'asc')"
  116. v-if="sort === 'orderCountDESC'"
  117. >
  118. 订单排序
  119. <image src="/static/images/sort1.png" />
  120. </view>
  121. <view
  122. class="sortItem"
  123. @click="setSort('orderCount', 'desc')"
  124. v-else-if="sort === 'orderCountASC'"
  125. >
  126. 订单排序
  127. <image src="/static/images/sort3.png" />
  128. </view>
  129. <view class="sortItem" @click="setSort('orderCount', 'desc')" v-else>
  130. 订单排序
  131. <image src="/static/images/sort2.png" />
  132. </view>
  133. </view>
  134. <block v-for="(item, index) in state.pagination.list" :key="index">
  135. <view class="item acea-row row-between-wrapper" style="display: flex">
  136. <view
  137. class="picTxt acea-row row-between-wrapper"
  138. style="display: flex; align-items: center"
  139. >
  140. <view class="pictrue">
  141. <image :src="item.avatar" />
  142. </view>
  143. <view class="text">
  144. <view class="name line1">{{ item.nickname }}</view>
  145. <view>
  146. 加入时间:
  147. {{ sheep.$helper.timeFormat(item.brokerageTime, 'yyyy-mm-dd hh:MM:ss') }}
  148. </view>
  149. </view>
  150. </view>
  151. <view
  152. class="right"
  153. style="
  154. justify-content: center;
  155. flex-direction: column;
  156. display: flex;
  157. margin-left: auto;
  158. "
  159. >
  160. <view>
  161. <text class="num font-color">{{ item.brokerageUserCount || 0 }} </text>人
  162. </view>
  163. <view>
  164. <text class="num">{{ item.orderCount || 0 }}</text
  165. >单</view
  166. >
  167. <view>
  168. <text class="num">{{ item.brokeragePrice || 0 }}</text
  169. >元
  170. </view>
  171. </view>
  172. </view>
  173. </block>
  174. <block v-if="state.pagination.list.length === 0">
  175. <view style="text-align: center;margin-top:30rpx;">暂无推广人数</view>
  176. </block>
  177. </view>
  178. </view>
  179. </view>
  180. <!-- <home></home> -->
  181. <!-- <view class="header-box" :style="[
  182. {
  183. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  184. paddingTop: Number(statusBarHeight + 108) + 'rpx',
  185. },
  186. ]">
  187. <view v-if="userInfo.parent_user" class="referrer-box ss-flex ss-col-center">
  188. 推荐人:
  189. <image class="referrer-avatar ss-m-r-10" :src="sheep.$url.cdn(userInfo.parent_user.avatar)"
  190. mode="aspectFill">
  191. </image>
  192. {{ userInfo.parent_user.nickname }}
  193. </view>
  194. <view class="team-data-box ss-flex ss-col-center ss-row-between">
  195. <view class="data-card">
  196. <view class="total-item">
  197. <view class="item-title">团队总人数(人)</view>
  198. <view class="total-num">
  199. {{ (state.summary.firstBrokerageUserCount+ state.summary.secondBrokerageUserCount)|| 0 }}
  200. </view>
  201. </view>
  202. <view class="category-item ss-flex">
  203. <view class="ss-flex-1">
  204. <view class="item-title">一级成员</view>
  205. <view class="category-num">{{ state.summary.firstBrokerageUserCount || 0 }}</view>
  206. </view>
  207. <view class="ss-flex-1">
  208. <view class="item-title">二级成员</view>
  209. <view class="category-num">{{ state.summary.secondBrokerageUserCount || 0 }}</view>
  210. </view>
  211. </view>
  212. </view>
  213. <view class="data-card">
  214. <view class="total-item">
  215. <view class="item-title">团队分销商人数(人)</view>
  216. <view class="total-num">{{ agentInfo?.child_agent_count_all || 0 }}</view>
  217. </view>
  218. <view class="category-item ss-flex">
  219. <view class="ss-flex-1">
  220. <view class="item-title">一级分销商</view>
  221. <view class="category-num">{{ agentInfo?.child_agent_count_1 || 0 }}</view>
  222. </view>
  223. <view class="ss-flex-1">
  224. <view class="item-title">二级分销商</view>
  225. <view class="category-num">{{ agentInfo?.child_agent_count_2 || 0 }}</view>
  226. </view>
  227. </view>
  228. </view>
  229. </view>
  230. </view>
  231. <view class="list-box">
  232. <uni-list :border="false">
  233. <uni-list-chat v-for="item in state.pagination.data" :key="item.id" :avatar-circle="true"
  234. :title="item.nickname" :avatar="sheep.$url.cdn(item.avatar)"
  235. :note="filterUserNum(item.agent?.child_user_count_1)">
  236. <view class="chat-custom-right">
  237. <view v-if="item.avatar" class="tag-box ss-flex ss-col-center">
  238. <image class="tag-img" :src="sheep.$url.cdn(item.avatar)" mode="aspectFill">
  239. </image>
  240. <text class="tag-title">{{ item.nickname }}</text>
  241. </view>
  242. <text
  243. class="time-text">{{ sheep.$helper.timeFormat(item.brokerageTime, 'yyyy-mm-dd hh:MM:ss') }}</text>
  244. </view>
  245. </uni-list-chat>
  246. </uni-list>
  247. </view>
  248. <s-empty v-if="state.pagination.total === 0" icon="/static/data-empty.png" text="暂无团队信息">
  249. </s-empty> -->
  250. </s-layout>
  251. </template>
  252. <script setup>
  253. import sheep from '@/sheep';
  254. import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  255. import { computed, reactive, ref } from 'vue';
  256. import _ from 'lodash-es';
  257. import { onPageScroll } from '@dcloudio/uni-app';
  258. import BrokerageApi from '@/sheep/api/trade/brokerage';
  259. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  260. // const agentInfo = computed(() => sheep.$store('user').agentInfo);
  261. const userInfo = computed(() => sheep.$store('user').userInfo);
  262. const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
  263. onPageScroll((e) => {
  264. state.scrollTop = e.scrollTop <= 100;
  265. });
  266. let sort = ref();
  267. const state = reactive({
  268. summary: {},
  269. pagination: {
  270. pageNo: 1,
  271. pageSize: 8,
  272. list: [],
  273. total: 0,
  274. },
  275. loadStatus: '',
  276. // ↓ 新 ui 逻辑
  277. level: 1,
  278. nickname: ref(''),
  279. sortKey: '',
  280. isAsc: '',
  281. });
  282. function filterUserNum(num) {
  283. if (_.isNil(num)) {
  284. return '';
  285. }
  286. return `下级团队${num}人`;
  287. }
  288. function submitForm() {
  289. state.pagination.list = [];
  290. getTeamList();
  291. }
  292. async function getTeamList() {
  293. state.loadStatus = 'loading';
  294. let { code, data } = await BrokerageApi.getBrokerageUserChildSummaryPage({
  295. pageNo: state.pagination.pageNo,
  296. pageSize: state.pagination.pageSize,
  297. level: state.level,
  298. 'sortingField.order': state.isAsc,
  299. 'sortingField.field': state.sortKey,
  300. nickname: state.nickname,
  301. });
  302. if (code !== 0) {
  303. return;
  304. }
  305. state.pagination.list = _.concat(state.pagination.list, data.list);
  306. state.pagination.total = data.total;
  307. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  308. }
  309. function setType(e) {
  310. state.pagination.list = [];
  311. state.level = e + '';
  312. getTeamList();
  313. }
  314. function setSort(sortKey, isAsc) {
  315. state.pagination.list = [];
  316. sort = sortKey + isAsc.toUpperCase();
  317. state.isAsc = isAsc;
  318. state.sortKey = sortKey;
  319. getTeamList();
  320. }
  321. onLoad(async () => {
  322. await getTeamList();
  323. // 概要数据
  324. let { data } = await BrokerageApi.getBrokerageUserSummary();
  325. state.summary = data;
  326. });
  327. // 加载更多
  328. function loadMore() {
  329. if (state.loadStatus === 'noMore') {
  330. return;
  331. }
  332. state.pagination.pageNo++;
  333. getTeamList();
  334. }
  335. // 上拉加载更多
  336. onReachBottom(() => {
  337. loadMore();
  338. });
  339. </script>
  340. <style lang="scss" scoped>
  341. .l1 {
  342. background-color: #fff;
  343. height: 86rpx;
  344. line-height: 86rpx;
  345. font-size: 28rpx;
  346. color: #282828;
  347. border-bottom: 1rpx solid #eee;
  348. border-top-left-radius: 14rpx;
  349. border-top-right-radius: 14rpx;
  350. display: flex;
  351. justify-content: space-around;
  352. }
  353. .header-box {
  354. box-sizing: border-box;
  355. padding: 0 20rpx 20rpx 20rpx;
  356. width: 750rpx;
  357. z-index: 3;
  358. position: relative;
  359. background: v-bind(headerBg) no-repeat,
  360. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  361. background-size: 750rpx 100%;
  362. // 团队信息总览
  363. .team-data-box {
  364. .data-card {
  365. width: 305rpx;
  366. background: #ffffff;
  367. border-radius: 20rpx;
  368. padding: 20rpx;
  369. .item-title {
  370. font-size: 22rpx;
  371. font-weight: 500;
  372. color: #999999;
  373. line-height: 30rpx;
  374. margin-bottom: 10rpx;
  375. }
  376. .total-item {
  377. margin-bottom: 30rpx;
  378. }
  379. .total-num {
  380. font-size: 38rpx;
  381. font-weight: 500;
  382. color: #333333;
  383. font-family: OPPOSANS;
  384. }
  385. .category-num {
  386. font-size: 26rpx;
  387. font-weight: 500;
  388. color: #333333;
  389. font-family: OPPOSANS;
  390. }
  391. }
  392. }
  393. }
  394. .list-box {
  395. z-index: 3;
  396. position: relative;
  397. }
  398. .chat-custom-right {
  399. .time-text {
  400. font-size: 22rpx;
  401. font-weight: 400;
  402. color: #999999;
  403. }
  404. .tag-box {
  405. background: rgba(0, 0, 0, 0.2);
  406. border-radius: 21rpx;
  407. line-height: 30rpx;
  408. padding: 5rpx 10rpx;
  409. width: 140rpx;
  410. .tag-img {
  411. width: 34rpx;
  412. height: 34rpx;
  413. margin-right: 6rpx;
  414. border-radius: 50%;
  415. }
  416. .tag-title {
  417. font-size: 18rpx;
  418. font-weight: 500;
  419. color: rgba(255, 255, 255, 1);
  420. line-height: 20rpx;
  421. }
  422. }
  423. }
  424. // 推荐人
  425. .referrer-box {
  426. font-size: 28rpx;
  427. font-weight: 500;
  428. color: #ffffff;
  429. padding: 20rpx;
  430. .referrer-avatar {
  431. width: 34rpx;
  432. height: 34rpx;
  433. border-radius: 50%;
  434. }
  435. }
  436. .promoter-list .nav {
  437. background-color: #fff;
  438. height: 86rpx;
  439. line-height: 86rpx;
  440. font-size: 28rpx;
  441. color: #282828;
  442. border-bottom: 1rpx solid #eee;
  443. border-top-left-radius: 14rpx;
  444. border-top-right-radius: 14rpx;
  445. margin-top: -30rpx;
  446. }
  447. .promoter-list .nav .item.on {
  448. border-bottom: 5rpx solid;
  449. // $theme-color
  450. color: var(--ui-BG-Main);
  451. // $theme-color
  452. }
  453. .promoter-list .search {
  454. width: 100%;
  455. background-color: #fff;
  456. height: 100rpx;
  457. padding: 0 24rpx;
  458. box-sizing: border-box;
  459. border-bottom-left-radius: 14rpx;
  460. border-bottom-right-radius: 14rpx;
  461. }
  462. .promoter-list .search .input {
  463. width: 592rpx;
  464. height: 60rpx;
  465. border-radius: 50rpx;
  466. background-color: #f5f5f5;
  467. text-align: center;
  468. position: relative;
  469. }
  470. .promoter-list .search .input input {
  471. height: 100%;
  472. font-size: 26rpx;
  473. width: 610rpx;
  474. text-align: center;
  475. }
  476. .promoter-list .search .input .placeholder {
  477. color: #bbb;
  478. }
  479. .promoter-list .search .input .iconfont {
  480. position: absolute;
  481. right: 28rpx;
  482. color: #999;
  483. font-size: 28rpx;
  484. top: 50%;
  485. transform: translateY(-50%);
  486. }
  487. .promoter-list .search .iconfont {
  488. font-size: 32rpx;
  489. color: #515151;
  490. height: 60rpx;
  491. line-height: 60rpx;
  492. }
  493. .promoter-list .list {
  494. margin-top: 20rpx;
  495. }
  496. .promoter-list .list .sortNav {
  497. background-color: #fff;
  498. height: 76rpx;
  499. border-bottom: 1rpx solid #eee;
  500. color: #333;
  501. font-size: 28rpx;
  502. border-top-left-radius: 14rpx;
  503. border-top-right-radius: 14rpx;
  504. }
  505. .promoter-list .list .sortNav .sortItem {
  506. text-align: center;
  507. flex: 1;
  508. }
  509. .promoter-list .list .sortNav .sortItem image {
  510. width: 24rpx;
  511. height: 24rpx;
  512. margin-left: 6rpx;
  513. vertical-align: -3rpx;
  514. }
  515. .promoter-list .list .item {
  516. background-color: #fff;
  517. border-bottom: 1rpx solid #eee;
  518. height: 152rpx;
  519. padding: 0 24rpx;
  520. font-size: 24rpx;
  521. color: #666;
  522. }
  523. .promoter-list .list .item .picTxt .pictrue {
  524. width: 106rpx;
  525. height: 106rpx;
  526. border-radius: 50%;
  527. }
  528. .promoter-list .list .item .picTxt .pictrue image {
  529. width: 100%;
  530. height: 100%;
  531. border-radius: 50%;
  532. border: 3rpx solid #fff;
  533. box-shadow: 0 0 10rpx #aaa;
  534. box-sizing: border-box;
  535. }
  536. .promoter-list .list .item .picTxt .text {
  537. // width: 304rpx;
  538. font-size: 24rpx;
  539. color: #666;
  540. margin-left: 14rpx;
  541. }
  542. .promoter-list .list .item .picTxt .text .name {
  543. font-size: 28rpx;
  544. color: #333;
  545. margin-bottom: 13rpx;
  546. }
  547. .promoter-list .list .item .right {
  548. text-align: right;
  549. font-size: 22rpx;
  550. color: #333;
  551. }
  552. .promoter-list .list .item .right .num {
  553. margin-right: 7rpx;
  554. }
  555. </style>