team.vue 10 KB

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