myteam.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="bg">
  6. <image src="../../static/img/team.png" mode=""></image>
  7. </view>
  8. <view class="body-title">
  9. <view class="goback-box" @click="toBack">
  10. <image class="goback" src="../../static/icon/fanhui.png" mode=""></image>
  11. </view>
  12. <view class="header">我的团队</view>
  13. </view>
  14. <view>
  15. <view class="money">共<text>{{ all }}</text>人</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="navbar">
  20. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  21. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">
  22. <text>{{ item.num }}</text>
  23. <text>{{ item.text }}</text>
  24. </view>
  25. </view>
  26. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300"
  27. @change="changeTab">
  28. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  29. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  30. <!-- 空白页 -->
  31. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  32. <!-- 订单列表 -->
  33. <view v-for="(item, index) in tabItem.orderList" :key="item.uid" class="andr-mt-flex andr-mt-lBox">
  34. <!-- 订单列表 -->
  35. <image :src="item.avatar" class="andr-mt-avatar andr-mt-marR20"></image>
  36. <view class="andr-mt-flex andr-mt-fdC">
  37. <text class="andr-mt-lname">{{ item.nickname || 'null' }}</text>
  38. <text class="andr-mt-ltime">{{ item.time }}</text>
  39. </view>
  40. </view>
  41. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  42. </scroll-view>
  43. </swiper-item>
  44. </swiper>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. spreadPeople
  50. } from '@/api/myteam.js';
  51. import {
  52. userinfo
  53. } from '@/api/user.js';
  54. import {
  55. mapState,
  56. mapMutations
  57. } from 'vuex';
  58. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  59. import empty from '@/components/empty';
  60. export default {
  61. components: {
  62. empty,
  63. uniLoadMore
  64. },
  65. onReady(res) {
  66. var _this = this;
  67. uni.getSystemInfo({
  68. success: resu => {
  69. console.log(resu, '11111');
  70. const query = uni.createSelectorQuery();
  71. query.select('.swiper-box').boundingClientRect();
  72. query.exec(function(res) {
  73. console.log(res, 'ddddddddddddd');
  74. _this.maxheight = resu.windowHeight - res[0].top;
  75. console.log('打印页面的剩余高度', _this.maxheight);
  76. });
  77. },
  78. fail: res => {}
  79. });
  80. },
  81. data() {
  82. return {
  83. userInfo: {},
  84. // 头部图高度
  85. maxheight: '',
  86. tabCurrentIndex: 0,
  87. navList: [{
  88. state: 0,
  89. text: '一级推广',
  90. loadingType: 'more',
  91. num: 0, //人数
  92. orderList: [],
  93. page: 1, //当前页数
  94. limit: 10 //每次信息条数
  95. },
  96. {
  97. state: 1,
  98. text: '二级推广',
  99. num: 0, //团队人数
  100. loadingType: 'more',
  101. orderList: [],
  102. page: 1, //当前页数
  103. limit: 10 //每次信息条数
  104. }
  105. ],
  106. all: 0
  107. };
  108. },
  109. onLoad(options) {},
  110. onShow() {
  111. this.loadData();
  112. // 获取用户积分
  113. let obj = this;
  114. userinfo({})
  115. .then(({
  116. data
  117. }) => {
  118. console.log(data);
  119. obj.userInfo = data;
  120. })
  121. .catch(e => {});
  122. },
  123. methods: {
  124. // 页面跳转
  125. navto(e) {
  126. uni.navigateTo({
  127. url: e
  128. });
  129. },
  130. //返回上一页面
  131. toBack() {
  132. console.log(111);
  133. uni.navigateBack({});
  134. },
  135. //获取收入支出信息
  136. async loadData(source) {
  137. let obj = this;
  138. //这里是将订单挂载到tab列表下
  139. let index = obj.tabCurrentIndex;
  140. let navItem = obj.navList[index];
  141. let state = navItem.state;
  142. if (source === 'tabChange' && navItem.loaded === true) {
  143. //tab切换只有第一次需要加载数据
  144. return;
  145. }
  146. if (navItem.loadingType === 'loading') {
  147. //防止重复加载
  148. return;
  149. }
  150. // 修改当前对象状态为加载中
  151. navItem.loadingType = 'loading';
  152. spreadPeople({
  153. page: navItem.page,
  154. limit: navItem.limit,
  155. grade: state,
  156. keyword: '',
  157. sort: ''
  158. })
  159. .then(({
  160. data
  161. }) => {
  162. obj.navList[0].num = data.total;
  163. obj.navList[1].num = data.totalLevel;
  164. if (data.list.length > 0) {
  165. navItem.orderList = navItem.orderList.concat(data.list);
  166. console.log(navItem.orderList);
  167. navItem.page++;
  168. }
  169. obj.all = data.total * 1 + data.totalLevel * 1
  170. if (navItem.limit == data.list.length) {
  171. //判断是否还有数据, 有改为 more, 没有改为noMore
  172. navItem.loadingType = 'more';
  173. return;
  174. } else {
  175. //判断是否还有数据, 有改为 more, 没有改为noMore
  176. navItem.loadingType = 'noMore';
  177. }
  178. uni.hideLoading();
  179. obj.$set(navItem, 'loaded', true);
  180. })
  181. .catch(e => {
  182. console.log(e);
  183. });
  184. },
  185. //swiper 切换
  186. changeTab(e) {
  187. this.tabCurrentIndex = e.target.current;
  188. this.loadData('tabChange');
  189. },
  190. //顶部tab点击
  191. tabClick(index) {
  192. this.tabCurrentIndex = index;
  193. }
  194. }
  195. };
  196. </script>
  197. <style lang="scss">
  198. page {
  199. background: #ffffff;
  200. height: 100%;
  201. }
  202. .content-money {
  203. background: $page-color-base;
  204. }
  205. .money-box {
  206. background-color: $base-color;
  207. padding-top: var(--status-bar-height);
  208. height: 468rpx;
  209. color: #ffffff;
  210. text-align: center;
  211. justify-content: center;
  212. position: relative;
  213. .body-title {
  214. height: 80rpx;
  215. text-align: center;
  216. font-size: 35rpx;
  217. position: relative;
  218. .header {
  219. position: absolute;
  220. left: 0;
  221. top: 0;
  222. width: 100%;
  223. font-size: 36rpx;
  224. font-family: PingFang SC;
  225. font-weight: bold;
  226. color: #fffeff;
  227. height: 80rpx;
  228. font-size: 32rpx;
  229. font-weight: 700;
  230. z-index: 9;
  231. display: flex;
  232. justify-content: center;
  233. align-items: center;
  234. }
  235. .goback-box {
  236. position: absolute;
  237. z-index: 10;
  238. left: 24rpx;
  239. top: 0;
  240. height: 80rpx;
  241. display: flex;
  242. align-items: center;
  243. }
  244. .goback {
  245. width: 30rpx;
  246. height: 36rpx;
  247. }
  248. }
  249. .bg {
  250. position: absolute;
  251. top: 0;
  252. left: 0;
  253. width: 100%;
  254. height: 100%;
  255. image {
  256. width: 100%;
  257. height: 100%;
  258. }
  259. }
  260. .money {
  261. position: relative;
  262. z-index: 10;
  263. font-size: 36rpx;
  264. height: 388rpx;
  265. line-height: 288rpx;
  266. text {
  267. font-size: 82rpx;
  268. }
  269. }
  270. }
  271. .navbar {
  272. width: 700rpx;
  273. margin: -60rpx auto 0;
  274. display: flex;
  275. height: 120rpx;
  276. padding: 0 5px;
  277. background: #fff;
  278. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  279. position: relative;
  280. z-index: 10;
  281. .nav-item {
  282. flex: 1;
  283. display: flex;
  284. flex-direction: column;
  285. justify-content: center;
  286. align-items: center;
  287. height: 100%;
  288. font-size: 15px;
  289. color: $font-color-dark;
  290. position: relative;
  291. &.current {
  292. color: $base-color;
  293. &:after {
  294. content: '';
  295. position: absolute;
  296. left: 50%;
  297. bottom: 0;
  298. transform: translateX(-50%);
  299. width: 44px;
  300. height: 0;
  301. border-bottom: 2px solid $base-color;
  302. }
  303. }
  304. }
  305. }
  306. // 列表
  307. .swiper-box {
  308. padding-top: 30rpx;
  309. .order-item {
  310. padding: 20rpx 30rpx;
  311. line-height: 1.5;
  312. .title-box {
  313. .title {
  314. font-size: $font-lg;
  315. color: $font-color-base;
  316. }
  317. .time {
  318. font-size: $font-base;
  319. color: $font-color-light;
  320. }
  321. }
  322. .money {
  323. color: #fd5b23;
  324. font-size: $font-lg;
  325. }
  326. }
  327. }
  328. .list-scroll-content {
  329. height: 100%;
  330. }
  331. .content {
  332. height: 100%;
  333. .empty-content {
  334. background-color: #ffffff;
  335. }
  336. }
  337. .andr-mt-avatar {
  338. width: 78rpx;
  339. height: 78rpx;
  340. border-radius: 50rpx;
  341. }
  342. .andr-mt-avatarBd {
  343. border: 2px solid #ffffff;
  344. }
  345. .andr-mt-cname {
  346. font-size: 28rpx;
  347. color: #ffffff;
  348. }
  349. .andr-mt-flex {
  350. display: flex;
  351. }
  352. .andr-mt-lBox {
  353. background-color: #ffffff;
  354. height: 130rpx;
  355. padding: 20rpx 20rpx;
  356. border-bottom: 1px solid #f0f0f0;
  357. }
  358. .andr-mt-marR20 {
  359. margin-right: 20rpx;
  360. }
  361. .andr-mt-fdC {
  362. flex-direction: column;
  363. }
  364. .andr-mt-lname {
  365. font-size: 30rpx;
  366. color: #3f454b;
  367. }
  368. .andr-mt-ltime {
  369. font-size: 22rpx;
  370. color: #999999;
  371. }
  372. </style>