myTeam.vue 7.3 KB

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