jifen.vue 9.3 KB

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