team.vue 10 KB

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