team.vue 11 KB

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