index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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==="recharge" ? "on":""' @click='changeType("recharge")'>充值</view>
  8. <view class='item' :class='type==="income" ? "on":""' @click='changeType("income")'>收入</view>
  9. </view>
  10. <view class='sign-record'>
  11. <view class='list borderPad' v-for="(item,index) in userBillList" :key="index">
  12. <view class='item'>
  13. <view class='data'>{{item.month}}</view>
  14. <view class='listn borRadius14'>
  15. <view class="itemn" v-for="(vo,indexn) in item.list" :key="indexn">
  16. <view class='acea-row row-between-wrapper'>
  17. <view>
  18. <view class='name line1'>{{vo.balance}}</view>
  19. <view>{{vo.createTime}}</view>
  20. </view>
  21. <view class='num font_color' v-if="vo.type == 1">+{{vo.amount}}</view>
  22. <view class='num' v-else>-{{vo.amount}}</view>
  23. </view>
  24. <view class="remark">说明:{{vo.remark}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class='loadingicon acea-row row-center-wrapper'>
  30. <text class='loading iconfont icon-jiazai'
  31. :hidden='loading==false'></text>{{userBillList.length > 0?loadTitle:''}}
  32. </view>
  33. <view v-if="userBillList.length == 0 && !loading">
  34. <emptyPage title="暂无账单的记录哦~" :imgSrc="urlDomain+'crmebimage/presets/noJilu.png'"></emptyPage>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. // +----------------------------------------------------------------------
  42. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  43. // +----------------------------------------------------------------------
  44. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  45. // +----------------------------------------------------------------------
  46. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  47. // +----------------------------------------------------------------------
  48. // | Author: CRMEB Team <admin@crmeb.com>
  49. // +----------------------------------------------------------------------
  50. import {
  51. getBillList
  52. } from '@/api/user.js';
  53. import {
  54. toLogin
  55. } from '@/libs/login.js';
  56. import {
  57. mapGetters
  58. } from "vuex";
  59. import emptyPage from '@/components/emptyPage.vue';
  60. let app = getApp();
  61. export default {
  62. components: {
  63. emptyPage
  64. },
  65. data() {
  66. return {
  67. urlDomain: this.$Cache.get("imgHost"),
  68. loadTitle: '加载更多',
  69. loading: true,
  70. loadend: false,
  71. page: 1,
  72. limit: 12,
  73. type: 'all',
  74. userBillList: [],
  75. theme: app.globalData.theme,
  76. };
  77. },
  78. computed: mapGetters(['isLogin']),
  79. onShow() {
  80. if (this.isLogin) {
  81. this.getUserBillList();
  82. } else {
  83. toLogin();
  84. }
  85. },
  86. /**
  87. * 生命周期函数--监听页面加载
  88. */
  89. onLoad: function(options) {
  90. this.type = options.type;
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function() {
  96. this.getUserBillList();
  97. },
  98. methods: {
  99. /**
  100. * 获取账户明细
  101. */
  102. getUserBillList: function() {
  103. let that = this;
  104. if (that.loadend) return;
  105. that.loading = true;
  106. that.loadTitle = "";
  107. let data = {
  108. page: that.page,
  109. limit: that.limit,
  110. type: that.type
  111. }
  112. getBillList(data).then(function(res) {
  113. let list = res.data.list ? res.data.list : [],
  114. loadend = res.data.totalPage <= that.page;
  115. for (let i = 0; i < list.length; i++) {
  116. let time1 = list[i].month;
  117. let array1 = list[i].list;
  118. let isEquals = false;
  119. for (let j = 0; j < that.userBillList.length; j++) {
  120. let time2 = that.userBillList[j].month;
  121. let array2 = that.userBillList[j].list;
  122. if (time1 == time2) {
  123. array2.push.apply(array2, array1);
  124. that.userBillList[j].list = array2;
  125. isEquals = true;
  126. break;
  127. }
  128. }
  129. if (!isEquals) {
  130. that.userBillList.push({
  131. month: time1,
  132. list: array1
  133. })
  134. }
  135. }
  136. that.$set(that, 'userBillList', that.userBillList);
  137. that.page += 1;
  138. that.loadend = loadend;
  139. that.loadTitle = loadend ? "哼??~我也是有底线的~" : "加载更多";
  140. that.loading = false;
  141. }, function(res) {
  142. that.loadTitle = '加载更多';
  143. that.loading = false;
  144. });
  145. },
  146. /**
  147. * 切换导航
  148. */
  149. changeType: function(type) {
  150. this.type = type;
  151. this.loadend = false;
  152. this.page = 1;
  153. this.$set(this, 'userBillList', []);
  154. this.getUserBillList();
  155. },
  156. }
  157. }
  158. </script>
  159. <style scoped lang='scss'>
  160. .remark {
  161. font-size: 24rpx;
  162. margin-top: 10rpx;
  163. }
  164. .bill-details .nav {
  165. background-color: #fff;
  166. height: 90rpx;
  167. width: 100%;
  168. line-height: 90rpx;
  169. }
  170. .bill-details .nav .item {
  171. flex: 1;
  172. text-align: center;
  173. font-size: 30rpx;
  174. color: #282828;
  175. }
  176. .bill-details .nav .item.on {
  177. @include main_color(theme);
  178. @include tab_border_bottom(theme);
  179. }
  180. .font_color {
  181. color: #E93323 !important;
  182. }
  183. </style>