index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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'>
  15. <view>
  16. <view class='name line1'>{{item.title}}</view>
  17. <view>{{item.create_time}}</view>
  18. </view>
  19. <view class='num' v-if="item.pm ==1">+{{item.number}}</view>
  20. <view class='num font-color' v-else>-{{item.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: 15,
  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.isShowAuth = false;
  104. this.getUserBillList();
  105. },
  106. // 授权关闭
  107. authColse: function(e) {
  108. this.isShowAuth = e
  109. },
  110. /**
  111. * 获取账户明细
  112. */
  113. getUserBillList: function() {
  114. let that = this;
  115. if (that.loadend) return;
  116. if (that.loading) return;
  117. that.loading = true;
  118. that.loadTitle = "";
  119. let data = {
  120. page: that.page,
  121. limit: that.limit,
  122. type:that.type
  123. }
  124. getCommissionInfo(data).then(function(res) {
  125. let list = res.data.list,
  126. loadend = list.length < that.limit;
  127. that.userBillList = that.$util.SplitArray(list, that.userBillList);
  128. that.$set(that, 'userBillList', that.userBillList);
  129. that.loadend = loadend;
  130. that.loading = false;
  131. that.loadTitle = loadend ? "哼😕~我也是有底线的~" : "加载更多";
  132. that.page = that.page + 1;
  133. }, function(res) {
  134. that.loading = false;
  135. that.loadTitle = '加载更多';
  136. });
  137. },
  138. /**
  139. * 切换导航
  140. */
  141. changeType: function(type) {
  142. this.type = type;
  143. this.loadend = false;
  144. this.page = 1;
  145. this.$set(this, 'userBillList', []);
  146. this.getUserBillList();
  147. },
  148. }
  149. }
  150. </script>
  151. <style scoped lang='scss'>
  152. .bill-details .nav {
  153. background-color: #fff;
  154. height: 90rpx;
  155. width: 100%;
  156. line-height: 90rpx;
  157. }
  158. .bill-details .nav .item {
  159. flex: 1;
  160. text-align: center;
  161. font-size: 30rpx;
  162. color: #282828;
  163. }
  164. .bill-details .nav .item.on {
  165. color: #e93323;
  166. border-bottom: 3rpx solid #e93323;
  167. }
  168. </style>