team.vue 11 KB

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