myTeam.vue 7.2 KB

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