team.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <!-- 我的团队 -->
  2. <template>
  3. <view class="page_box team-wrap">
  4. <view class="head_box">
  5. <!-- 标题栏 -->
  6. <shopro-navbar back-icon-color="#fff" :background="{}" :backTextStyle="{ color: '#fff', fontSize: '40rpx', fontWeight: '500' }" backText="我的团队"></shopro-navbar>
  7. <!-- 推荐人 -->
  8. <view class="referrer-box u-flex u-p-x-20" v-if="referrerInfo && referrerInfo.avatar">
  9. 推荐人:
  10. <image class="referrer-avatar u-m-r-10" :src="referrerInfo.avatar" mode=""></image>
  11. {{ referrerInfo.nickname }}
  12. </view>
  13. <!-- 团队数据总览 -->
  14. <view class="team-data-box u-flex u-row-between">
  15. <view class="data-card">
  16. <view class="total-item">
  17. <view class="item-title">团队总人数(人)</view>
  18. <view class="total-num">{{ userInfo.child_user_count || 0 }}</view>
  19. </view>
  20. <view class="category-item u-flex">
  21. <view class=" u-flex-1">
  22. <view class="item-title">一级成员</view>
  23. <view class="category-num">{{ userInfo.child_user_count_1 || 0 }}</view>
  24. </view>
  25. <view class=" u-flex-1">
  26. <view class="item-title">二级成员</view>
  27. <view class="category-num">{{ userInfo.child_user_count_2 || 0 }}</view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="data-card">
  32. <view class="total-item">
  33. <view class="item-title">团队分销商人数(人)</view>
  34. <view class="total-num">{{ agentInfo.child_agent_count || 0 }}</view>
  35. </view>
  36. <view class="category-item u-flex">
  37. <view class=" u-flex-1">
  38. <view class="item-title">一级分销商</view>
  39. <view class="category-num">{{ agentInfo.child_agent_count_1 || 0 }}</view>
  40. </view>
  41. <view class="u-flex-1 ">
  42. <view class="item-title">二级分销商</view>
  43. <view class="category-num">{{ agentInfo.child_agent_count_2 || 0 }}</view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="content_box">
  50. <scroll-view scroll-y="true" @scrolltolower="loadMore" class="scroll-box">
  51. <!-- 团队列表 -->
  52. <view class="team-box">
  53. <view class="team-list" v-for="(item, index) in teamList" :key="item.id">
  54. <sh-collapse-item
  55. :avatar="item.avatar"
  56. :dateTime="item.createtime"
  57. :level="item.agent ? item.agent.level : null"
  58. :name="item.nickname"
  59. :isUnfold="item.isUnfold"
  60. :childNum="item.child_user_count_1"
  61. @click="onTeamList(item.id, index)"
  62. >
  63. <view slot="collapse-children" v-if="childrenTeamList.length">
  64. <view class="team-children u-flex" v-for="children in childrenTeamList" :key="children.id">
  65. <image class="head-img" :src="children.avatar" mode=""></image>
  66. <view class="head-info">
  67. <view class="name-box u-flex">
  68. <view class="name-text">{{ children.nickname }}</view>
  69. <view class="grade-tag tag-box u-flex" v-if="children.agent">
  70. <image class="tag-img" :src="children.agent ? children.agent.level.image : ''" mode=""></image>
  71. <text class="tag-title">{{ children.agent ? children.agent.level.name : '' }}</text>
  72. </view>
  73. </view>
  74. <view class="head-time">{{ $u.timeFormat(children.createtime, 'yyyy年mm月dd日') }}</view>
  75. </view>
  76. </view>
  77. <button class="cu-btn refresh-btn u-flex u-row-center u-col-center" @tap.stop="childrenLoadMore(item.id)">
  78. <view
  79. v-if="childrenCurrentPage < childrenLastPage"
  80. class="u-iconfont uicon-reload u-m-r-10"
  81. :class="{ 'refresh-active': isRefresh }"
  82. style="color: #999;font-size: 26rpx;"
  83. ></view>
  84. {{ childrenLoad ? '点击加载更多' : '没有更多~' }}
  85. </button>
  86. </view>
  87. </sh-collapse-item>
  88. </view>
  89. </view>
  90. <!-- 缺省页 -->
  91. <shopro-empty v-if="isEmpty" marginTop="50rpx" :image="$IMG_URL + '/imgs/empty/no_team.png'" tipText="暂无团队人员"></shopro-empty>
  92. <!-- 更多 -->
  93. <u-loadmore v-if="teamList.length" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
  94. </scroll-view>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import shCollapseItem from '../components/sh-collapse-item.vue';
  100. import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
  101. export default {
  102. components: {
  103. shCollapseItem
  104. },
  105. data() {
  106. return {
  107. isEmpty: false,
  108. referrerInfo: {}, //推荐人信息
  109. twoTeamCount: 0, //二级成员
  110. teamList: [], //团队列表
  111. loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
  112. currentPage: 1,
  113. lastPage: 1,
  114. // 二级
  115. childrenTeamList: [],
  116. childrenCurrentPage: 1,
  117. childrenLastPage: 1,
  118. childrenLoad: false,
  119. isRefresh: false
  120. };
  121. },
  122. computed: {
  123. ...mapGetters(['userInfo', 'agentInfo'])
  124. },
  125. onLoad() {
  126. this.getTeam();
  127. this.getAgent();
  128. },
  129. methods: {
  130. ...mapActions(['getAgent']),
  131. // 点击队员项
  132. onTeamList(id, current) {
  133. this.childrenTeamList = [];
  134. this.childrenCurrentPage = 1;
  135. this.childrenLastPage = 1;
  136. this.childrenLoad = false;
  137. this.isRefresh = false;
  138. !this.teamList[current].isUnfold && this.teamList[current].child_user_count_1 && this.getChildrenTeam(id);
  139. this.teamList.map((item, index) => {
  140. if (index === current) {
  141. item.isUnfold ? (item.isUnfold = false) : (item.isUnfold = true);
  142. } else {
  143. item.isUnfold = false;
  144. }
  145. });
  146. },
  147. // 团队列表
  148. getTeam() {
  149. let that = this;
  150. that.loadStatus = 'loadmore';
  151. that.$http('commission.team', {
  152. page: that.currentPage
  153. }).then(res => {
  154. if (res.code === 1) {
  155. that.referrerInfo = res.data.parent_user;
  156. let arr = res.data.teams.data;
  157. arr.map(item => {
  158. item.isUnfold = false;
  159. });
  160. that.teamList = [...that.teamList, ...arr];
  161. that.isEmpty = !that.teamList.length;
  162. that.lastPage = res.data.teams.last_page;
  163. that.loadStatus = that.currentPage < res.data.teams.last_page ? 'loadmore' : 'nomore';
  164. }
  165. });
  166. },
  167. // 二级队员
  168. getChildrenTeam(id) {
  169. let that = this;
  170. that.$http(
  171. 'commission.team',
  172. {
  173. id: id,
  174. page: that.childrenCurrentPage
  175. },
  176. '加载中...'
  177. ).then(res => {
  178. if (res.code === 1) {
  179. that.childrenTeamList = [...that.childrenTeamList, ...res.data.teams.data];
  180. that.childrenLastPage = res.data.teams.last_page;
  181. that.childrenLoad = that.childrenCurrentPage < res.data.teams.last_page;
  182. }
  183. });
  184. },
  185. // 二级加载更多
  186. childrenLoadMore(id) {
  187. if (!this.isRefresh) {
  188. // 加载更多
  189. if (this.childrenCurrentPage < this.childrenLastPage) {
  190. this.isRefresh = true;
  191. this.childrenCurrentPage += 1;
  192. this.getChildrenTeam(id);
  193. }
  194. }
  195. },
  196. // 加载更多
  197. loadMore() {
  198. if (this.currentPage < this.lastPage) {
  199. this.currentPage += 1;
  200. this.getTeam();
  201. }
  202. }
  203. }
  204. };
  205. </script>
  206. <style lang="scss">
  207. // 推荐人
  208. .referrer-box {
  209. font-size: 28rpx;
  210. font-weight: 500;
  211. color: #ffffff;
  212. margin-top: 10rpx;
  213. .referrer-avatar {
  214. width: 34rpx;
  215. height: 34rpx;
  216. border-radius: 50%;
  217. }
  218. }
  219. // 二级加载更多按钮
  220. .refresh-btn {
  221. width: 100%;
  222. line-height: 100rpx;
  223. background: #ffffff;
  224. border-radius: 25rpx;
  225. font-size: 22rpx;
  226. font-weight: 500;
  227. color: #999999;
  228. white-space: nowrap;
  229. }
  230. .refresh-active {
  231. transform: rotate(360deg);
  232. transition: all linear 0.5s;
  233. }
  234. // 头部卡片
  235. .head_box {
  236. background: url($IMG_URL+'/imgs/commission/card_bg.png') no-repeat;
  237. background-size: 100% 100%;
  238. padding-bottom: 30rpx;
  239. }
  240. // 团队信息总览
  241. .team-data-box {
  242. margin: 30rpx 20rpx 0;
  243. .data-card {
  244. width: 340rpx;
  245. background: #ffffff;
  246. border-radius: 20rpx;
  247. padding: 20rpx;
  248. .item-title {
  249. font-size: 22rpx;
  250. font-weight: 500;
  251. color: #999999;
  252. line-height: 30rpx;
  253. margin-bottom: 10rpx;
  254. }
  255. .total-item {
  256. margin-bottom: 20rpx;
  257. }
  258. .total-num {
  259. font-size: 38rpx;
  260. font-weight: 500;
  261. color: #333333;
  262. }
  263. .category-num {
  264. font-size: 26rpx;
  265. font-weight: 500;
  266. color: #333333;
  267. }
  268. }
  269. }
  270. // 团队列表
  271. .team-box {
  272. .team-list {
  273. .team-children {
  274. margin-left: 80rpx;
  275. margin-right: 20rpx;
  276. height: 132rpx;
  277. border-bottom: 1rpx solid #eee;
  278. .head-img {
  279. width: 60rpx;
  280. height: 60rpx;
  281. border-radius: 50%;
  282. margin-right: 38rpx;
  283. }
  284. .head-info {
  285. .head-time {
  286. font-size: 22rpx;
  287. font-weight: 400;
  288. color: #999999;
  289. }
  290. .name-box {
  291. margin-bottom: 12rpx;
  292. .name-text {
  293. font-size: 24rpx;
  294. font-weight: 500;
  295. color: #666;
  296. }
  297. .tag-box {
  298. background: rgba(0, 0, 0, 0.2);
  299. border-radius: 21rpx;
  300. line-height: 30rpx;
  301. padding-right: 10rpx;
  302. margin-left: 10rpx;
  303. .tag-img {
  304. width: 34rpx;
  305. height: 34rpx;
  306. margin-right: 6rpx;
  307. border-radius: 50%;
  308. }
  309. .tag-title {
  310. font-size: 18rpx;
  311. font-weight: 500;
  312. color: rgba(255, 255, 255, 1);
  313. line-height: 20rpx;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. </style>