mygx.vue 9.5 KB

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