team.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="status_bar">
  5. <!-- 这里是状态栏 -->
  6. </view>
  7. <view class="body-title">
  8. <view class="goback-box" @click="toBack">
  9. <image class="goback" src="../../static/icon/fanhui.png" mode=""></image>
  10. </view>
  11. <view class="header">我的推广</view>
  12. </view>
  13. <view class="content-bg">
  14. <image src="../../static/img/tg-bg.png" mode=""></image>
  15. </view>
  16. <view class="money-box">
  17. <view class="money">{{ all|| '0' }}</view>
  18. <view>我的推广人数</view>
  19. </view>
  20. <view class="money-box" style="padding-top: 20rpx;" v-if="order*1 > 0">
  21. <view>直推:{{zt_order}}单</view>
  22. <view>间推:{{jt_order}}单</view>
  23. </view>
  24. </view>
  25. <view class="flex buttom-box">
  26. <view class="buttom" @click="tabClick(0)">
  27. <view class="money">{{all || 0}}</view>
  28. <text class="text" :class="{ current: tabCurrentIndex === 0 }">一级推广</text>
  29. </view>
  30. <view class="buttom" @click="tabClick(1)">
  31. <view class="money">{{totalLevel || 0}}</view>
  32. <text class="text" :class="{ current: tabCurrentIndex === 1 }">二级推广</text>
  33. </view>
  34. </view>
  35. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300"
  36. @change="changeTab">
  37. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  38. <scroll-view class="list-scroll-content" :style="{ height: maxheight }" scroll-y
  39. @scrolltolower="loadData">
  40. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  41. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  42. <view class="title-box flex_item">
  43. <view class="title-avatar">
  44. <image :src="item.avatar"></image>
  45. </view>
  46. <view class="list_tpl">
  47. <view class="title">
  48. <view class="title-name clamp">{{ item.nickname }}</view>
  49. </view>
  50. <view class="time">
  51. <text>{{ item.time }}</text>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  57. </scroll-view>
  58. </swiper-item>
  59. </swiper>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. myspread
  65. } from '@/api/user.js';
  66. import empty from '@/components/empty';
  67. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  68. import {
  69. mapState,
  70. mapMutations
  71. } from 'vuex';
  72. export default {
  73. components: {
  74. empty,
  75. uniLoadMore
  76. },
  77. onReady(res) {
  78. var _this = this;
  79. uni.getSystemInfo({
  80. success: resu => {
  81. const query = uni.createSelectorQuery();
  82. query.select('.swiper-box').boundingClientRect();
  83. query.exec(function(res) {
  84. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  85. console.log('打印页面的剩余高度', _this.height);
  86. });
  87. },
  88. fail: res => {}
  89. });
  90. },
  91. data() {
  92. return {
  93. // 头部图高度
  94. maxheight: '',
  95. tabCurrentIndex: 0,
  96. navList: [{
  97. state: 0,
  98. text: '直接推荐',
  99. loadingType: 'more',
  100. orderList: [],
  101. page: 1, //当前页数
  102. limit: 10 //每次信息条数
  103. },
  104. {
  105. state: 1,
  106. text: '间接推荐',
  107. loadingType: 'more',
  108. orderList: [],
  109. page: 1, //当前页数
  110. limit: 10 //每次信息条数
  111. }],
  112. all: '',
  113. list: '',
  114. totalLevel: '',
  115. order: '',
  116. zt_order: '',
  117. jt_order: ''
  118. };
  119. },
  120. computed: {
  121. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  122. ...mapState(['baseURL'])
  123. },
  124. onLoad(options) {},
  125. onShow() {
  126. this.loadData();
  127. },
  128. methods: {
  129. // 页面跳转
  130. navto(e) {
  131. uni.navigateTo({
  132. url: e
  133. });
  134. },
  135. //获取收入支出信息
  136. async loadData(source) {
  137. //这里是将订单挂载到tab列表下
  138. let index = this.tabCurrentIndex;
  139. let navItem = this.navList[index];
  140. let state = navItem.state;
  141. if (source === 'tabChange' && navItem.loaded === true) {
  142. //tab切换只有第一次需要加载数据
  143. return;
  144. }
  145. if (navItem.loadingType === 'loading') {
  146. //防止重复加载
  147. return;
  148. }
  149. if (navItem.loadingType === 'noMore') {
  150. //防止重复加载
  151. return;
  152. }
  153. // 修改当前对象状态为加载中
  154. navItem.loadingType = 'loading';
  155. myspread({
  156. page: navItem.page,
  157. limit: navItem.limit,
  158. grade:state,
  159. uid: this.userInfo.uid
  160. })
  161. .then(({
  162. data
  163. }) => {
  164. console.log(data);
  165. this.order = data.order
  166. this.zt_order = data.zt_order
  167. this.jt_order = data.jt_order
  168. this.all = data.total;
  169. this.totalLevel = data.totalLevel
  170. if (data.list.length > 0) {
  171. this.list = data.list;
  172. navItem.orderList = navItem.orderList.concat(data.list);
  173. navItem.page++;
  174. }
  175. this.$nextTick(function() {
  176. if (navItem.limit == data.list.length) {
  177. //判断是否还有数据, 有改为 more, 没有改为noMore
  178. navItem.loadingType = 'more';
  179. return;
  180. } else {
  181. //判断是否还有数据, 有改为 more, 没有改为noMore
  182. navItem.loadingType = 'noMore';
  183. }
  184. });
  185. this.$set(navItem, 'loaded', true);
  186. })
  187. .catch(e => {
  188. console.log(e);
  189. });
  190. },
  191. //swiper 切换
  192. changeTab(e) {
  193. this.tabCurrentIndex = e.target.current;
  194. this.loadData('tabChange');
  195. },
  196. //顶部tab点击
  197. tabClick(index) {
  198. this.tabCurrentIndex = index;
  199. },
  200. // 点击返回 我的页面
  201. toBack() {
  202. uni.switchTab({
  203. url: '/pages/user/user'
  204. });
  205. }
  206. }
  207. };
  208. </script>
  209. <style lang="scss">
  210. page {
  211. background: #f8f8f8;
  212. height: 100%;
  213. }
  214. .status_bar {
  215. height: var(--status-bar-height);
  216. width: 100%;
  217. background: #5dbc7c;
  218. }
  219. .content-money {
  220. position: relative;
  221. height: 480rpx;
  222. .content-bg {
  223. position: absolute;
  224. top: 0;
  225. left: 0;
  226. right: 0;
  227. width: 750rpx;
  228. height: 480rpx;
  229. image {
  230. width: 100%;
  231. height: 100%;
  232. }
  233. }
  234. .body-title {
  235. height: 80rpx;
  236. text-align: center;
  237. font-size: 35rpx;
  238. position: relative;
  239. .header {
  240. position: absolute;
  241. left: 0;
  242. top: 0;
  243. width: 100%;
  244. font-size: 36rpx;
  245. font-family: PingFang SC;
  246. font-weight: bold;
  247. color: #fffeff;
  248. height: 80rpx;
  249. font-size: 36rpx;
  250. font-weight: 700;
  251. z-index: 9;
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. }
  256. .goback-box {
  257. position: absolute;
  258. left: 18rpx;
  259. top: 0;
  260. height: 80rpx;
  261. display: flex;
  262. align-items: center;
  263. }
  264. .goback {
  265. z-index: 100;
  266. width: 34rpx;
  267. height: 34rpx;
  268. }
  269. }
  270. }
  271. .money-box {
  272. position: relative;
  273. z-index: 2;
  274. padding-top: 90rpx;
  275. color: #ffffff;
  276. text-align: center;
  277. .money {
  278. font-size: 72rpx;
  279. font-family: PingFang SC;
  280. font-weight: bold;
  281. color: #ffffff;
  282. }
  283. .text {
  284. font-size: 30rpx;
  285. }
  286. }
  287. .order-item {
  288. padding: 20rpx 30rpx;
  289. line-height: 1.5;
  290. background-color: #fff;
  291. .title-box {
  292. width: 100%;
  293. .title-avatar {
  294. flex-shrink: 0;
  295. width: 100rpx;
  296. height: 100rpx;
  297. margin-right: 25rpx;
  298. border-radius: 100%;
  299. image {
  300. width: 100%;
  301. height: 100%;
  302. border-radius: 100%;
  303. }
  304. }
  305. .list_tpl {
  306. width: 85%;
  307. .title {
  308. display: flex;
  309. justify-content: flex-start;
  310. font-size: $font-lg;
  311. color: $font-color-base;
  312. overflow: hidden; //超出的文本隐藏
  313. text-overflow: ellipsis; //溢出用省略号显示
  314. white-space: nowrap;
  315. line-height: 1;
  316. text-align: center;
  317. .title-name {
  318. max-width: 40%;
  319. }
  320. .dl {
  321. margin-left: 10rpx;
  322. width: 93rpx;
  323. height: 32rpx;
  324. border-radius: 16rpx;
  325. image {
  326. width: 93rpx;
  327. height: 32rpx;
  328. border-radius: 16rpx;
  329. }
  330. }
  331. .class {
  332. display: inline-block;
  333. margin-left: 10rpx;
  334. padding: 6rpx;
  335. text-align: center;
  336. border: 1px solid #2e58ff;
  337. border-radius: 16rpx;
  338. font-size: 20rpx;
  339. font-family: PingFang SC;
  340. font-weight: 500;
  341. color: #2e58ff;
  342. }
  343. }
  344. .time {
  345. font-size: $font-lg;
  346. color: $font-color-light;
  347. }
  348. }
  349. }
  350. .money {
  351. width: 50%;
  352. text-align: right;
  353. color: #db1935;
  354. font-size: $font-lg;
  355. }
  356. }
  357. .yeji {
  358. position: relative;
  359. margin: -72rpx auto 0;
  360. width: 690rpx;
  361. height: 143rpx;
  362. background: #ffffff;
  363. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  364. border-radius: 10rpx;
  365. display: flex;
  366. align-items: center;
  367. .yeji-a {
  368. width: 50%;
  369. display: flex;
  370. flex-direction: column;
  371. justify-content: center;
  372. align-items: center;
  373. .yeji-top {
  374. font-size: 28rpx;
  375. font-family: PingFang SC;
  376. font-weight: bold;
  377. color: #333333;
  378. }
  379. .yeji-buttom {
  380. font-size: 42rpx;
  381. font-family: PingFang SC;
  382. font-weight: bold;
  383. color: #333333;
  384. }
  385. }
  386. .border {
  387. width: 1rpx;
  388. height: 51rpx;
  389. background: #dddddd;
  390. }
  391. }
  392. .navbar {
  393. margin-top: 20rpx;
  394. display: flex;
  395. height: 88rpx;
  396. padding: 0 5px;
  397. background: #fff;
  398. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  399. position: relative;
  400. z-index: 10;
  401. .nav-item {
  402. flex: 1;
  403. display: flex;
  404. justify-content: center;
  405. align-items: center;
  406. height: 100%;
  407. font-size: 15px;
  408. color: #999999;
  409. position: relative;
  410. &.current {
  411. color: #000;
  412. &:after {
  413. content: '';
  414. position: absolute;
  415. left: 50%;
  416. bottom: 0;
  417. transform: translateX(-50%);
  418. width: 44px;
  419. height: 0;
  420. border-bottom: 2px solid #fe5b38;
  421. }
  422. }
  423. }
  424. }
  425. .buttom-box {
  426. position: relative;
  427. background-color: #ffffff;
  428. text-align: center;
  429. padding: 30rpx 0;
  430. .buttom {
  431. flex-grow: 1;
  432. }
  433. .money{
  434. font-size: 32rpx;
  435. font-weight: bold;
  436. color: #ff4173;
  437. }
  438. .text {
  439. padding-bottom: 26rpx;
  440. font-size: 28rpx;
  441. font-weight: 500;
  442. color: #666666;
  443. &.current {
  444. border-bottom: 2px solid #ff4173;
  445. }
  446. }
  447. .icon {
  448. height: 50rpx;
  449. width: 48rpx;
  450. margin: 0 auto;
  451. .icon-img {
  452. width: 100%;
  453. height: 100%;
  454. }
  455. }
  456. }
  457. </style>