You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.2 KiB

3 months ago
  1. <template>
  2. <view :data-theme="theme">
  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==="expenditure" ? "on":""' @click='changeType("expenditure")'>消费</view>
  7. <view class='item' :class='type==="income" ? "on":""' @click='changeType("income")'>充值</view>
  8. </view>
  9. <view class='sign-record'>
  10. <view class='list pad30' v-for="(item,index) in userBillList" :key="index">
  11. <view class='item'>
  12. <view class='data'>{{item.date}}</view>
  13. <view class='listn borRadius14'>
  14. <view class='itemn acea-row row-between-wrapper' v-for="(vo,indexn) in item.list"
  15. :key="indexn">
  16. <view>
  17. <view class='name line1'>{{vo.title}}</view>
  18. <view>{{vo.add_time}}</view>
  19. </view>
  20. <view class='num font_color' v-if="vo.pm">+{{vo.number}}</view>
  21. <view class='num' v-else>-{{vo.number}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class='loadingicon acea-row row-center-wrapper' v-if="userBillList.length>0">
  27. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  28. </view>
  29. <view v-if="userBillList.length == 0">
  30. <emptyPage title="暂无账单的记录哦~"></emptyPage>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. getBillList
  39. } from '@/api/user.js';
  40. import {
  41. toLogin
  42. } from '@/libs/login.js';
  43. import {
  44. mapGetters
  45. } from "vuex";
  46. import emptyPage from '@/components/emptyPage.vue';
  47. let app = getApp();
  48. export default {
  49. components: {
  50. emptyPage
  51. },
  52. data() {
  53. return {
  54. loadTitle: '加载更多',
  55. loading: false,
  56. loadend: false,
  57. page: 1,
  58. limit: 12,
  59. type: 'all',
  60. userBillList: [],
  61. theme:app.globalData.theme,
  62. };
  63. },
  64. computed: mapGetters(['isLogin']),
  65. onShow() {
  66. if (this.isLogin) {
  67. this.getUserBillList();
  68. } else {
  69. toLogin();
  70. }
  71. },
  72. /**
  73. * 生命周期函数--监听页面加载
  74. */
  75. onLoad: function(options) {
  76. this.type = options.type?options.type:'all';
  77. },
  78. /**
  79. * 页面上拉触底事件的处理函数
  80. */
  81. onReachBottom: function() {
  82. this.getUserBillList();
  83. },
  84. methods: {
  85. /**
  86. * 获取账户明细
  87. */
  88. getUserBillList: function() {
  89. let that = this;
  90. if (that.loadend) return;
  91. if (that.loading) return;
  92. that.loading = true;
  93. that.loadTitle = "";
  94. let data = {
  95. page: that.page,
  96. limit: that.limit,
  97. type: that.type
  98. }
  99. getBillList(data).then(function(res) {
  100. let list = res.data.list ? res.data.list : [],
  101. loadend = res.data.totalPage <= that.page;
  102. for (let i = 0; i < list.length; i++) {
  103. let time1 = list[i].date;
  104. let array1 = list[i].list;
  105. let isEquals = false;
  106. for (let j = 0; j < that.userBillList.length; j++) {
  107. let time2 = that.userBillList[j].date;
  108. let array2 = that.userBillList[j].list;
  109. if (time1 == time2) {
  110. array2.push.apply(array2, array1);
  111. that.userBillList[j].list = array2;
  112. isEquals = true;
  113. break;
  114. }
  115. }
  116. if (!isEquals) {
  117. that.userBillList.push({
  118. date: time1,
  119. list: array1
  120. })
  121. }
  122. }
  123. that.$set(that, 'userBillList', that.userBillList);
  124. that.page += 1;
  125. that.loadend = loadend;
  126. that.loading = false;
  127. that.loadTitle = loadend ? "我也是有底线的~" : "加载更多";
  128. }, function(res) {
  129. that.loading = false;
  130. that.loadTitle = '加载更多';
  131. });
  132. },
  133. /**
  134. * 切换导航
  135. */
  136. changeType: function(type) {
  137. this.type = type;
  138. this.loadend = false;
  139. this.page = 1;
  140. this.$set(this, 'userBillList', []);
  141. this.getUserBillList();
  142. },
  143. }
  144. }
  145. </script>
  146. <style scoped lang='scss'>
  147. .sign-record {}
  148. .bill-details .nav {
  149. background-color: #fff;
  150. height: 90rpx;
  151. width: 100%;
  152. line-height: 90rpx;
  153. }
  154. .bill-details .nav .item {
  155. flex: 1;
  156. text-align: center;
  157. font-size: 30rpx;
  158. color: #282828;
  159. }
  160. .bill-details .nav .item.on {
  161. @include main_color(theme);
  162. @include tab_border_bottom(theme);
  163. }
  164. .font_color{
  165. color: #E93323 !important;
  166. }
  167. </style>