team.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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">{{ fen2yuan(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. import { fen2yuan } from '../../sheep/hooks/useGoods';
  260. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  261. // const agentInfo = computed(() => sheep.$store('user').agentInfo);
  262. const userInfo = computed(() => sheep.$store('user').userInfo);
  263. const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
  264. onPageScroll((e) => {
  265. state.scrollTop = e.scrollTop <= 100;
  266. });
  267. let sort = ref();
  268. const state = reactive({
  269. summary: {},
  270. pagination: {
  271. pageNo: 1,
  272. pageSize: 8,
  273. list: [],
  274. total: 0,
  275. },
  276. loadStatus: '',
  277. // ↓ 新 ui 逻辑
  278. level: 1,
  279. nickname: ref(''),
  280. sortKey: '',
  281. isAsc: '',
  282. });
  283. function filterUserNum(num) {
  284. if (_.isNil(num)) {
  285. return '';
  286. }
  287. return `下级团队${num}人`;
  288. }
  289. function submitForm() {
  290. state.pagination.list = [];
  291. getTeamList();
  292. }
  293. async function getTeamList() {
  294. state.loadStatus = 'loading';
  295. let { code, data } = await BrokerageApi.getBrokerageUserChildSummaryPage({
  296. pageNo: state.pagination.pageNo,
  297. pageSize: state.pagination.pageSize,
  298. level: state.level,
  299. 'sortingField.order': state.isAsc,
  300. 'sortingField.field': state.sortKey,
  301. nickname: state.nickname,
  302. });
  303. if (code !== 0) {
  304. return;
  305. }
  306. state.pagination.list = _.concat(state.pagination.list, data.list);
  307. state.pagination.total = data.total;
  308. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  309. }
  310. function setType(e) {
  311. state.pagination.list = [];
  312. state.level = e + '';
  313. getTeamList();
  314. }
  315. function setSort(sortKey, isAsc) {
  316. state.pagination.list = [];
  317. sort = sortKey + isAsc.toUpperCase();
  318. state.isAsc = isAsc;
  319. state.sortKey = sortKey;
  320. getTeamList();
  321. }
  322. onLoad(async () => {
  323. await getTeamList();
  324. // 概要数据
  325. let { data } = await BrokerageApi.getBrokerageUserSummary();
  326. state.summary = data;
  327. });
  328. // 加载更多
  329. function loadMore() {
  330. if (state.loadStatus === 'noMore') {
  331. return;
  332. }
  333. state.pagination.pageNo++;
  334. getTeamList();
  335. }
  336. // 上拉加载更多
  337. onReachBottom(() => {
  338. loadMore();
  339. });
  340. </script>
  341. <style lang="scss" scoped>
  342. .l1 {
  343. background-color: #fff;
  344. height: 86rpx;
  345. line-height: 86rpx;
  346. font-size: 28rpx;
  347. color: #282828;
  348. border-bottom: 1rpx solid #eee;
  349. border-top-left-radius: 14rpx;
  350. border-top-right-radius: 14rpx;
  351. display: flex;
  352. justify-content: space-around;
  353. }
  354. .header-box {
  355. box-sizing: border-box;
  356. padding: 0 20rpx 20rpx 20rpx;
  357. width: 750rpx;
  358. z-index: 3;
  359. position: relative;
  360. background: v-bind(headerBg) no-repeat,
  361. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  362. background-size: 750rpx 100%;
  363. // 团队信息总览
  364. .team-data-box {
  365. .data-card {
  366. width: 305rpx;
  367. background: #ffffff;
  368. border-radius: 20rpx;
  369. padding: 20rpx;
  370. .item-title {
  371. font-size: 22rpx;
  372. font-weight: 500;
  373. color: #999999;
  374. line-height: 30rpx;
  375. margin-bottom: 10rpx;
  376. }
  377. .total-item {
  378. margin-bottom: 30rpx;
  379. }
  380. .total-num {
  381. font-size: 38rpx;
  382. font-weight: 500;
  383. color: #333333;
  384. font-family: OPPOSANS;
  385. }
  386. .category-num {
  387. font-size: 26rpx;
  388. font-weight: 500;
  389. color: #333333;
  390. font-family: OPPOSANS;
  391. }
  392. }
  393. }
  394. }
  395. .list-box {
  396. z-index: 3;
  397. position: relative;
  398. }
  399. .chat-custom-right {
  400. .time-text {
  401. font-size: 22rpx;
  402. font-weight: 400;
  403. color: #999999;
  404. }
  405. .tag-box {
  406. background: rgba(0, 0, 0, 0.2);
  407. border-radius: 21rpx;
  408. line-height: 30rpx;
  409. padding: 5rpx 10rpx;
  410. width: 140rpx;
  411. .tag-img {
  412. width: 34rpx;
  413. height: 34rpx;
  414. margin-right: 6rpx;
  415. border-radius: 50%;
  416. }
  417. .tag-title {
  418. font-size: 18rpx;
  419. font-weight: 500;
  420. color: rgba(255, 255, 255, 1);
  421. line-height: 20rpx;
  422. }
  423. }
  424. }
  425. // 推荐人
  426. .referrer-box {
  427. font-size: 28rpx;
  428. font-weight: 500;
  429. color: #ffffff;
  430. padding: 20rpx;
  431. .referrer-avatar {
  432. width: 34rpx;
  433. height: 34rpx;
  434. border-radius: 50%;
  435. }
  436. }
  437. .promoter-list .nav {
  438. background-color: #fff;
  439. height: 86rpx;
  440. line-height: 86rpx;
  441. font-size: 28rpx;
  442. color: #282828;
  443. border-bottom: 1rpx solid #eee;
  444. border-top-left-radius: 14rpx;
  445. border-top-right-radius: 14rpx;
  446. margin-top: -30rpx;
  447. }
  448. .promoter-list .nav .item.on {
  449. border-bottom: 5rpx solid;
  450. // $theme-color
  451. color: var(--ui-BG-Main);
  452. // $theme-color
  453. }
  454. .promoter-list .search {
  455. width: 100%;
  456. background-color: #fff;
  457. height: 100rpx;
  458. padding: 0 24rpx;
  459. box-sizing: border-box;
  460. border-bottom-left-radius: 14rpx;
  461. border-bottom-right-radius: 14rpx;
  462. }
  463. .promoter-list .search .input {
  464. width: 592rpx;
  465. height: 60rpx;
  466. border-radius: 50rpx;
  467. background-color: #f5f5f5;
  468. text-align: center;
  469. position: relative;
  470. }
  471. .promoter-list .search .input input {
  472. height: 100%;
  473. font-size: 26rpx;
  474. width: 610rpx;
  475. text-align: center;
  476. }
  477. .promoter-list .search .input .placeholder {
  478. color: #bbb;
  479. }
  480. .promoter-list .search .input .iconfont {
  481. position: absolute;
  482. right: 28rpx;
  483. color: #999;
  484. font-size: 28rpx;
  485. top: 50%;
  486. transform: translateY(-50%);
  487. }
  488. .promoter-list .search .iconfont {
  489. font-size: 32rpx;
  490. color: #515151;
  491. height: 60rpx;
  492. line-height: 60rpx;
  493. }
  494. .promoter-list .list {
  495. margin-top: 20rpx;
  496. }
  497. .promoter-list .list .sortNav {
  498. background-color: #fff;
  499. height: 76rpx;
  500. border-bottom: 1rpx solid #eee;
  501. color: #333;
  502. font-size: 28rpx;
  503. border-top-left-radius: 14rpx;
  504. border-top-right-radius: 14rpx;
  505. }
  506. .promoter-list .list .sortNav .sortItem {
  507. text-align: center;
  508. flex: 1;
  509. }
  510. .promoter-list .list .sortNav .sortItem image {
  511. width: 24rpx;
  512. height: 24rpx;
  513. margin-left: 6rpx;
  514. vertical-align: -3rpx;
  515. }
  516. .promoter-list .list .item {
  517. background-color: #fff;
  518. border-bottom: 1rpx solid #eee;
  519. height: 152rpx;
  520. padding: 0 24rpx;
  521. font-size: 24rpx;
  522. color: #666;
  523. }
  524. .promoter-list .list .item .picTxt .pictrue {
  525. width: 106rpx;
  526. height: 106rpx;
  527. border-radius: 50%;
  528. }
  529. .promoter-list .list .item .picTxt .pictrue image {
  530. width: 100%;
  531. height: 100%;
  532. border-radius: 50%;
  533. border: 3rpx solid #fff;
  534. box-shadow: 0 0 10rpx #aaa;
  535. box-sizing: border-box;
  536. }
  537. .promoter-list .list .item .picTxt .text {
  538. // width: 304rpx;
  539. font-size: 24rpx;
  540. color: #666;
  541. margin-left: 14rpx;
  542. }
  543. .promoter-list .list .item .picTxt .text .name {
  544. font-size: 28rpx;
  545. color: #333;
  546. margin-bottom: 13rpx;
  547. }
  548. .promoter-list .list .item .right {
  549. text-align: right;
  550. font-size: 22rpx;
  551. color: #333;
  552. }
  553. .promoter-list .list .item .right .num {
  554. margin-right: 7rpx;
  555. }
  556. </style>