team.vue 12 KB

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