index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view>
  3. <view class='bill-details'>
  4. <view class='nav acea-row'>
  5. <view class='item' :class='type=="all" ? "on":""' @click='changeType("all")'>全部</view>
  6. <view class='item' :class='type=="recharge" ? "on":""' @click='changeType("recharge")'>充值</view>
  7. <view class='item' :class='type=="consumption" ? "on":""' @click='changeType("consumption")'>消费</view>
  8. </view>
  9. <view class='sign-record'>
  10. <view class='list' v-for="(item,index) in recordList" :key="index">
  11. <view class='item'>
  12. <view class='listn'>
  13. <view class='itemn acea-row row-between-wrapper'>
  14. <view>
  15. <view class='name line1'>{{item.title}}</view>
  16. <view>{{item.time}}</view>
  17. </view>
  18. <view class='num' v-if="item.code=='recharge'">+{{item.v}}</view>
  19. <view class='num font-color' v-else>-{{item.v}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class='loadingicon acea-row row-center-wrapper' v-if="recordList.length>0">
  25. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  26. </view>
  27. <view v-if="recordList.length == 0">
  28. <emptyPage title="暂无账单的记录哦~"></emptyPage>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. mapGetters
  37. } from "vuex";
  38. import {
  39. toLogin
  40. } from '@/libs/login.js';
  41. import {
  42. recordList
  43. } from '@/api/api.js';
  44. import emptyPage from '@/components/emptyPage.vue'
  45. export default {
  46. components: {
  47. emptyPage
  48. },
  49. data() {
  50. return {
  51. loadTitle: '加载更多',
  52. loading: false,
  53. loadend: false,
  54. page: 1,
  55. limit: 10,
  56. type: 'all',
  57. recordList: []
  58. };
  59. },
  60. computed: mapGetters(['isLogin']),
  61. onLoad: function(options) {
  62. this.type = options.type || 'all';
  63. if (this.isLogin) {
  64. this.getRecordList();
  65. } else {
  66. toLogin();
  67. }
  68. },
  69. onReachBottom: function() {
  70. this.getRecordList();
  71. },
  72. methods: {
  73. getRecordList: function() {
  74. let that = this;
  75. if (that.loadend) return;
  76. if (that.loading) return;
  77. that.loading = true;
  78. that.loadTitle = "";
  79. let data = {
  80. page: that.page,
  81. tabType: that.type
  82. }
  83. recordList(data).then(function(res) {
  84. let list = res.data.list,
  85. loadend = list.length < that.limit;
  86. that.recordList = that.$util.SplitArray(list, that.recordList);
  87. that.loadend = loadend;
  88. that.loading = false;
  89. that.loadTitle = loadend ? "哼~我也是有底线的~" : "加载更多";
  90. that.page = that.page + 1;
  91. }, function(res) {
  92. that.loading = false;
  93. that.loadTitle = '加载更多';
  94. });
  95. },
  96. changeType: function(type) {
  97. this.type = type;
  98. this.loadend = false;
  99. this.page = 1;
  100. this.$set(this, 'recordList', []);
  101. this.getRecordList();
  102. }
  103. }
  104. }
  105. </script>
  106. <style scoped lang='scss'>
  107. .bill-details .nav {
  108. background-color: #fff;
  109. height: 90rpx;
  110. width: 100%;
  111. line-height: 90rpx;
  112. margin-bottom: 2rpx;
  113. }
  114. .bill-details .nav .item {
  115. flex: 1;
  116. text-align: center;
  117. font-size: 30rpx;
  118. color: #282828;
  119. }
  120. .bill-details .nav .item.on {
  121. color: #e93323;
  122. border-bottom: 3rpx solid #e93323;
  123. }
  124. .font-color {
  125. color: #e93323!important;
  126. }
  127. </style>