team.vue 10 KB

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