team.vue 10 KB

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