index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view>
  3. <view class='bill-details'>
  4. <view class='nav acea-row'>
  5. <view class='item' :class='type === undefined ? "on":""' @click='changeType(undefined)'>全部</view>
  6. <view class='item' :class='type === "1" ? "on":""' @click='changeType("1")'>收入</view>
  7. <view class='item' :class='type === "2" ? "on":""' @click='changeType("2")'>支出</view>
  8. </view>
  9. <view class='sign-record'>
  10. <view class='list' v-for="(item,index) in userBillList" :key="index">
  11. <view class='item'>
  12. <view class='listn borRadius14'>
  13. <view class='itemn acea-row row-between-wrapper'>
  14. <view>
  15. <view class='name line1'>{{ item.title }}</view>
  16. <view>{{ formatDate(item.createTime) }}</view>
  17. </view>
  18. <view class='num' v-if="item.price > 0">+{{ fen2yuan(item.price) }}</view>
  19. <view class='num font-color' v-else>{{ fen2yuan(item.price) }}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class='loadingicon acea-row row-center-wrapper' v-if="userBillList.length > 0">
  25. <text class='loading iconfont icon-jiazai' :hidden='loading === false'></text>{{loadTitle}}
  26. </view>
  27. <view v-if="userBillList.length === 0">
  28. <emptyPage title="暂无账单的记录哦~"></emptyPage>
  29. </view>
  30. </view>
  31. </view>
  32. <home></home>
  33. </view>
  34. </template>
  35. <script>
  36. import { toLogin } from '@/libs/login.js';
  37. import { mapGetters } from "vuex";
  38. import emptyPage from '@/components/emptyPage.vue';
  39. import home from '@/components/home';
  40. import * as WalletApi from '@/api/pay/wallet.js';
  41. import dayjs from '@/plugin/dayjs/dayjs.min.js';
  42. import * as Util from '@/utils/util.js';
  43. export default {
  44. components: {
  45. emptyPage,
  46. home
  47. },
  48. data() {
  49. return {
  50. loadTitle: '加载更多',
  51. loading: false,
  52. loadend: false,
  53. page: 1,
  54. limit: 10,
  55. type: undefined,
  56. userBillList: [],
  57. };
  58. },
  59. computed: mapGetters(['isLogin']),
  60. onShow() {
  61. if (!this.isLogin) {
  62. toLogin();
  63. return;
  64. }
  65. this.getUserBillList();
  66. },
  67. /**
  68. * 生命周期函数--监听页面加载
  69. */
  70. onLoad: function(options) {
  71. this.type = options.type;
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom: function() {
  77. this.getUserBillList();
  78. },
  79. methods: {
  80. /**
  81. * 获取账户明细
  82. */
  83. getUserBillList: function() {
  84. if (this.loadend || this.loading) {
  85. return;
  86. }
  87. this.loading = true;
  88. this.loadTitle = "";
  89. WalletApi.getWalletTransactionPage({
  90. pageNo: this.page,
  91. pageSize: this.limit,
  92. type: this.type
  93. }).then(res => {
  94. const list = res.data.list ? res.data.list : [];
  95. const loadend = res.data.list < res.data.limit;
  96. this.userBillList = this.$util.SplitArray(list, this.userBillList);
  97. this.$set(this, 'userBillList', this.userBillList);
  98. this.loadend = loadend;
  99. this.loading = false;
  100. this.loadTitle = loadend ? "哼😕~我也是有底线的~" : "加载更多";
  101. this.page = this.page + 1;
  102. }).catch(err => {
  103. this.loading = false;
  104. this.loadTitle = '加载更多';
  105. });
  106. },
  107. /**
  108. * 切换导航
  109. */
  110. changeType: function(type) {
  111. this.type = type;
  112. this.loadend = false;
  113. this.page = 1;
  114. this.$set(this, 'userBillList', []);
  115. this.getUserBillList();
  116. },
  117. fen2yuan(price) {
  118. return Util.fen2yuan(price)
  119. },
  120. formatDate: function(date) {
  121. return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
  122. }
  123. }
  124. }
  125. </script>
  126. <style scoped lang='scss'>
  127. .sign-record{
  128. }
  129. .bill-details .nav {
  130. background-color: #fff;
  131. height: 90rpx;
  132. width: 100%;
  133. line-height: 90rpx;
  134. }
  135. .bill-details .nav .item {
  136. flex: 1;
  137. text-align: center;
  138. font-size: 30rpx;
  139. color: #282828;
  140. }
  141. .bill-details .nav .item.on {
  142. color: $theme-color;
  143. border-bottom: 3rpx solid $theme-color;
  144. }
  145. </style>