team.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <!-- 页面 -->
  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 v-if="userInfo.parent_user" class="referrer-box ss-flex ss-col-center">
  15. 推荐人:
  16. <image
  17. class="referrer-avatar ss-m-r-10"
  18. :src="sheep.$url.cdn(userInfo.parent_user.avatar)"
  19. mode="aspectFill"
  20. >
  21. </image>
  22. {{ userInfo.parent_user.nickname }}
  23. </view>
  24. <!-- 团队数据总览 -->
  25. <view class="team-data-box ss-flex ss-col-center ss-row-between">
  26. <view class="data-card">
  27. <view class="total-item">
  28. <view class="item-title">团队总人数(人)</view>
  29. <view class="total-num">{{ agentInfo.child_user_count_all || 0 }}</view>
  30. </view>
  31. <view class="category-item ss-flex">
  32. <view class="ss-flex-1">
  33. <view class="item-title">一级成员</view>
  34. <view class="category-num">{{ agentInfo.child_user_count_1 || 0 }}</view>
  35. </view>
  36. <view class="ss-flex-1">
  37. <view class="item-title">二级成员</view>
  38. <view class="category-num">{{ agentInfo.child_user_count_2 || 0 }}</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="data-card">
  43. <view class="total-item">
  44. <view class="item-title">团队分销商人数(人)</view>
  45. <view class="total-num">{{ agentInfo.child_agent_count_all || 0 }}</view>
  46. </view>
  47. <view class="category-item ss-flex">
  48. <view class="ss-flex-1">
  49. <view class="item-title">一级分销商</view>
  50. <view class="category-num">{{ agentInfo.child_agent_count_1 || 0 }}</view>
  51. </view>
  52. <view class="ss-flex-1">
  53. <view class="item-title">二级分销商</view>
  54. <view class="category-num">{{ agentInfo.child_agent_count_2 || 0 }}</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="list-box">
  61. <uni-list :border="false">
  62. <uni-list-chat
  63. v-for="item in state.pagination.data"
  64. :key="item.id"
  65. :avatar-circle="true"
  66. :title="item.nickname"
  67. :avatar="sheep.$url.cdn(item.avatar)"
  68. :note="filterUserNum(item.agent?.child_user_count_1)"
  69. >
  70. <view class="chat-custom-right">
  71. <view v-if="item.agent?.level_info" class="tag-box ss-flex ss-col-center">
  72. <image
  73. class="tag-img"
  74. :src="sheep.$url.cdn(item.agent.level_info.image)"
  75. mode="aspectFill"
  76. >
  77. </image>
  78. <text class="tag-title">{{ item.agent.level_info.name }}</text>
  79. </view>
  80. <text class="time-text">{{ item.create_time }}</text>
  81. </view>
  82. </uni-list-chat>
  83. </uni-list>
  84. </view>
  85. <s-empty v-if="state.pagination.total === 0" icon="/static/data-empty.png" text="暂无团队信息">
  86. </s-empty>
  87. </s-layout>
  88. </template>
  89. <script setup>
  90. import sheep from '@/sheep';
  91. import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  92. import { computed, reactive } from 'vue';
  93. import _ from 'lodash';
  94. import { onPageScroll } from '@dcloudio/uni-app';
  95. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  96. const agentInfo = computed(() => sheep.$store('user').agentInfo);
  97. const userInfo = computed(() => sheep.$store('user').userInfo);
  98. const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
  99. onPageScroll((e) => {
  100. if (e.scrollTop > 100) {
  101. state.scrollTop = false;
  102. } else {
  103. state.scrollTop = true;
  104. }
  105. });
  106. const state = reactive({
  107. pagination: {
  108. data: [],
  109. current_page: 1,
  110. total: 1,
  111. last_page: 1,
  112. },
  113. loadStatus: '',
  114. });
  115. function filterUserNum(num) {
  116. if (_.isNil(num)) {
  117. return '';
  118. }
  119. return `下级团队${num}人`;
  120. }
  121. async function getTeamList(page = 1, list_rows = 8) {
  122. state.loadStatus = 'loading';
  123. let res = await sheep.$api.commission.team({
  124. list_rows,
  125. page,
  126. });
  127. if (res.error === 0) {
  128. let orderList = _.concat(state.pagination.data, res.data.data);
  129. state.pagination = {
  130. ...res.data,
  131. data: orderList,
  132. };
  133. if (state.pagination.current_page < state.pagination.last_page) {
  134. state.loadStatus = 'more';
  135. } else {
  136. state.loadStatus = 'noMore';
  137. }
  138. }
  139. }
  140. onLoad(async () => {
  141. getTeamList();
  142. });
  143. // 加载更多
  144. function loadmore() {
  145. if (state.loadStatus !== 'noMore') {
  146. getTeamList(state.pagination.current_page + 1);
  147. }
  148. }
  149. // 上拉加载更多
  150. onReachBottom(() => {
  151. loadmore();
  152. });
  153. </script>
  154. <style lang="scss" scoped>
  155. .header-box {
  156. box-sizing: border-box;
  157. padding: 0 20rpx 20rpx 20rpx;
  158. width: 750rpx;
  159. z-index: 3;
  160. position: relative;
  161. background: v-bind(headerBg) no-repeat,
  162. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  163. background-size: 750rpx 100%;
  164. // 团队信息总览
  165. .team-data-box {
  166. .data-card {
  167. width: 305rpx;
  168. background: #ffffff;
  169. border-radius: 20rpx;
  170. padding: 20rpx;
  171. .item-title {
  172. font-size: 22rpx;
  173. font-weight: 500;
  174. color: #999999;
  175. line-height: 30rpx;
  176. margin-bottom: 10rpx;
  177. }
  178. .total-item {
  179. margin-bottom: 30rpx;
  180. }
  181. .total-num {
  182. font-size: 38rpx;
  183. font-weight: 500;
  184. color: #333333;
  185. font-family: OPPOSANS;
  186. }
  187. .category-num {
  188. font-size: 26rpx;
  189. font-weight: 500;
  190. color: #333333;
  191. font-family: OPPOSANS;
  192. }
  193. }
  194. }
  195. }
  196. .list-box {
  197. z-index: 3;
  198. position: relative;
  199. }
  200. .chat-custom-right {
  201. .time-text {
  202. font-size: 22rpx;
  203. font-weight: 400;
  204. color: #999999;
  205. }
  206. .tag-box {
  207. background: rgba(0, 0, 0, 0.2);
  208. border-radius: 21rpx;
  209. line-height: 30rpx;
  210. padding: 5rpx 10rpx;
  211. width: 140rpx;
  212. .tag-img {
  213. width: 34rpx;
  214. height: 34rpx;
  215. margin-right: 6rpx;
  216. border-radius: 50%;
  217. }
  218. .tag-title {
  219. font-size: 18rpx;
  220. font-weight: 500;
  221. color: rgba(255, 255, 255, 1);
  222. line-height: 20rpx;
  223. }
  224. }
  225. }
  226. // 推荐人
  227. .referrer-box {
  228. font-size: 28rpx;
  229. font-weight: 500;
  230. color: #ffffff;
  231. padding: 20rpx;
  232. .referrer-avatar {
  233. width: 34rpx;
  234. height: 34rpx;
  235. border-radius: 50%;
  236. }
  237. }
  238. </style>