team.vue 16 KB

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