index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view>
  3. <view class='bill-details'>
  4. <view class='nav acea-row'>
  5. <view class='item' :class='type==0 ? "on":""' @click='changeType(0)'>全部</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='data'>{{item.time}}</view>
  13. <view class='listn'>
  14. <view class='itemn acea-row row-between-wrapper' v-for="(vo,indexn) in item.list" :key="indexn">
  15. <view>
  16. <view class='name line1'>{{vo.title}}</view>
  17. <view>{{vo.add_time}}</view>
  18. </view>
  19. <view class='num' v-if="vo.pm">+{{vo.number}}</view>
  20. <view class='num font-color' v-else>-{{vo.number}}</view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class='loadingicon acea-row row-center-wrapper' v-if="userBillList.length>0">
  26. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  27. </view>
  28. <view v-if="userBillList.length == 0">
  29. <emptyPage title="暂无账单的记录哦~"></emptyPage>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- #ifdef MP -->
  34. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  35. <!-- #endif -->
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. getCommissionInfo
  41. } from '@/api/user.js';
  42. import {
  43. toLogin
  44. } from '@/libs/login.js';
  45. import {
  46. mapGetters
  47. } from "vuex";
  48. // #ifdef MP
  49. import authorize from '@/components/Authorize';
  50. // #endif
  51. import emptyPage from '@/components/emptyPage.vue'
  52. export default {
  53. components: {
  54. // #ifdef MP
  55. authorize,
  56. // #endif
  57. emptyPage
  58. },
  59. data() {
  60. return {
  61. loadTitle: '加载更多',
  62. loading: false,
  63. loadend: false,
  64. page: 1,
  65. limit: 10,
  66. type: 0,
  67. userBillList: [],
  68. isAuto: false, //没有授权的不会自动授权
  69. isShowAuth: false //是否隐藏授权
  70. };
  71. },
  72. computed: mapGetters(['isLogin']),
  73. onShow() {
  74. if (this.isLogin) {
  75. this.getUserBillList();
  76. } else {
  77. // #ifdef H5 || APP-PLUS
  78. toLogin();
  79. // #endif
  80. // #ifdef MP
  81. this.isAuto = true;
  82. this.$set(this, 'isShowAuth', true)
  83. // #endif
  84. }
  85. },
  86. /**
  87. * 生命周期函数--监听页面加载
  88. */
  89. onLoad: function(options) {
  90. this.type = options.type || 0;
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function() {
  96. this.getUserBillList();
  97. },
  98. methods: {
  99. /**
  100. * 授权回调
  101. */
  102. onLoadFun: function() {
  103. this.getUserBillList();
  104. },
  105. // 授权关闭
  106. authColse: function(e) {
  107. this.isShowAuth = e
  108. },
  109. /**
  110. * 获取账户明细
  111. */
  112. getUserBillList: function() {
  113. let that = this;
  114. if (that.loadend) return;
  115. if (that.loading) return;
  116. that.loading = true;
  117. that.loadTitle = "";
  118. let data = {
  119. page: that.page,
  120. limit: that.limit
  121. }
  122. getCommissionInfo(data, that.type).then(function(res) {
  123. let list = res.data,
  124. loadend = list.length < that.limit;
  125. that.userBillList = that.$util.SplitArray(list, that.userBillList);
  126. that.$set(that, 'userBillList', that.userBillList);
  127. that.loadend = loadend;
  128. that.loading = false;
  129. that.loadTitle = loadend ? "哼😕~我也是有底线的~" : "加载更多";
  130. that.page = that.page + 1;
  131. }, function(res) {
  132. that.loading = false;
  133. that.loadTitle = '加载更多';
  134. });
  135. },
  136. /**
  137. * 切换导航
  138. */
  139. changeType: function(type) {
  140. this.type = type;
  141. this.loadend = false;
  142. this.page = 1;
  143. this.$set(this, 'userBillList', []);
  144. this.getUserBillList();
  145. },
  146. }
  147. }
  148. </script>
  149. <style scoped lang='scss'>
  150. .bill-details .nav {
  151. background-color: #fff;
  152. height: 90rpx;
  153. width: 100%;
  154. line-height: 90rpx;
  155. }
  156. .bill-details .nav .item {
  157. flex: 1;
  158. text-align: center;
  159. font-size: 30rpx;
  160. color: #282828;
  161. }
  162. .bill-details .nav .item.on {
  163. color: #e93323;
  164. border-bottom: 3rpx solid #e93323;
  165. }
  166. </style>