team.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <view>
  3. <view class="top-container">
  4. <view class="top-tabbar">
  5. <view v-for="(item,index) in tabList" :key="index" :class="state_active == index ? 'tab-item active' : 'tab-item'"
  6. @click="stateFunc(index)">
  7. {{item.text}}( {{item.total}})
  8. </view>
  9. </view>
  10. <view class="total p-0-30 d-s-c f24 gray9">
  11. 团队总人数:
  12. <text class="red">{{teamTotal}}</text>
  13. </view>
  14. </view>
  15. <!--列表-->
  16. <scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50"
  17. @scrolltolower="scrolltolowerFunc">
  18. <view class="p-0-30 bg-white">
  19. <view class="border-b p-20-0" v-for="(item,index) in tableData" :key="index">
  20. <view class="d-b-c">
  21. <view class="agent-team-photo">
  22. <image :src="item.user.avatarUrl" mode="aspectFill"></image>
  23. </view>
  24. <view class="flex-1 ml20 f24">
  25. <view class="d-b-c">
  26. <text class="f28 gray3">{{ item.user.nickName }}</text>
  27. <text class="gray9">{{ item.create_time }}</text>
  28. </view>
  29. <view class="d-b-c">
  30. <text class="gray9">¥{{ item.user.expend_money }}</text>
  31. <text class="gray9" v-if="item.agent"> {{ item.agent.first_num + item.agent.second_num + item.agent.third_num }}个成员</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 没有记录 -->
  37. <view class="d-c-c p30" v-if="tableData.length==0 && !loading">
  38. <text class="iconfont icon-wushuju"></text>
  39. <text class="cont">亲,暂无相关记录哦</text>
  40. </view>
  41. <uni-load-more v-else :loadingType="loadingType"></uni-load-more>
  42. </view>
  43. </scroll-view>
  44. </view>
  45. </template>
  46. <script>
  47. import uniLoadMore from "@/components/uni-load-more.vue";
  48. export default {
  49. components: {
  50. uniLoadMore
  51. },
  52. data() {
  53. return {
  54. /*手机高度*/
  55. phoneHeight: 0,
  56. /*可滚动视图区域高度*/
  57. scrollviewHigh: 0,
  58. /*状态选中*/
  59. state_active: 0,
  60. /*数据列表*/
  61. tableData: [],
  62. setting: [],
  63. teamTotal: 0,
  64. page: 1,
  65. no_more: false,
  66. tabList: [],
  67. list_rows: 15,
  68. loading: true,
  69. }
  70. },
  71. computed: {
  72. /*加载中状态*/
  73. loadingType() {
  74. if (this.loading) {
  75. return 1;
  76. } else {
  77. if (this.tableData.length != 0 && this.no_more) {
  78. return 2;
  79. } else {
  80. return 0;
  81. }
  82. }
  83. }
  84. },
  85. mounted() {
  86. /*初始化*/
  87. this.init();
  88. /*获取数据*/
  89. this.getData();
  90. },
  91. methods: {
  92. /*初始化*/
  93. init() {
  94. let self = this;
  95. uni.getSystemInfo({
  96. success(res) {
  97. self.phoneHeight = res.windowHeight;
  98. // 计算组件的高度
  99. let view = uni.createSelectorQuery().select('.top-container');
  100. view.boundingClientRect(data => {
  101. let h = self.phoneHeight - data.height;
  102. self.scrollviewHigh = h;
  103. }).exec();
  104. }
  105. });
  106. },
  107. /*获取数据*/
  108. getData() {
  109. let self = this;
  110. self.loading = true;
  111. self._get('plus.agent.team/lists', {
  112. level: self.state_active + 1,
  113. page: self.page || 1,
  114. list_rows: self.list_rows,
  115. }, function(res) {
  116. self.loading = false;
  117. self.teamTotal = res.data.agent.first_num;
  118. let data = res.data;
  119. // 导航栏数据
  120. self.tabList = [{
  121. value: 1,
  122. text: data.words.team.words.first.value,
  123. total: data.agent.first_num
  124. }];
  125. if (data.setting.level >= 2) {
  126. self.tabList.push({
  127. value: 2,
  128. text: data.words.team.words.second.value,
  129. total: data.agent.second_num
  130. });
  131. self.teamTotal += data.agent.second_num;
  132. }
  133. if (data.setting.level == 3) {
  134. self.tabList.push({
  135. value: 3,
  136. text: data.words.team.words.third.value,
  137. total: data.agent.third_num
  138. });
  139. self.teamTotal += data.agent.third_num;
  140. }
  141. self.tableData = self.tableData.concat(data.list.data);
  142. self.last_page = data.list.last_page;
  143. if (self.last_page <= 1) {
  144. self.no_more = true;
  145. }
  146. },null,function(){
  147. self.loading = false;
  148. });
  149. },
  150. /*切换类别*/
  151. stateFunc(e) {
  152. let self = this;
  153. if(e!=self.state_active){
  154. self.tableData = [];
  155. self.page = 1;
  156. self.state_active = e;
  157. self.getData();
  158. }
  159. },
  160. /*可滚动视图区域到底触发*/
  161. scrolltolowerFunc() {
  162. let self = this;
  163. if (self.no_more) {
  164. return;
  165. }
  166. self.page++;
  167. if (self.page <= self.last_page) {
  168. self.getData();
  169. } else {
  170. self.no_more = true;
  171. }
  172. }
  173. }
  174. }
  175. </script>
  176. <style>
  177. .top-container .total {
  178. height: 80rpx;
  179. }
  180. .agent-team-photo,
  181. .agent-team-photo image {
  182. width: 80rpx;
  183. height: 80rpx;
  184. border-radius: 50%;
  185. }
  186. </style>