index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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==="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" :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. <home></home>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. getBillList
  42. } from '@/api/user.js';
  43. import {
  44. toLogin
  45. } from '@/libs/login.js';
  46. import {
  47. mapGetters
  48. } from "vuex";
  49. // #ifdef MP
  50. import authorize from '@/components/Authorize';
  51. // #endif
  52. import emptyPage from '@/components/emptyPage.vue';
  53. import home from '@/components/home';
  54. export default {
  55. components: {
  56. // #ifdef MP
  57. authorize,
  58. // #endif
  59. emptyPage,
  60. home
  61. },
  62. data() {
  63. return {
  64. loadTitle: '加载更多',
  65. loading: false,
  66. loadend: false,
  67. page: 1,
  68. limit: 10,
  69. type: 'all',
  70. userBillList: [],
  71. isAuto: false, //没有授权的不会自动授权
  72. isShowAuth: false //是否隐藏授权
  73. };
  74. },
  75. computed: mapGetters(['isLogin']),
  76. onShow() {
  77. if (this.isLogin) {
  78. this.getUserBillList();
  79. } else {
  80. toLogin();
  81. }
  82. },
  83. /**
  84. * 生命周期函数--监听页面加载
  85. */
  86. onLoad: function(options) {
  87. this.type = options.type;
  88. },
  89. /**
  90. * 页面上拉触底事件的处理函数
  91. */
  92. onReachBottom: function() {
  93. this.getUserBillList();
  94. },
  95. methods: {
  96. /**
  97. * 授权回调
  98. */
  99. onLoadFun: function() {
  100. this.getUserBillList();
  101. },
  102. // 授权关闭
  103. authColse: function(e) {
  104. this.isShowAuth = e
  105. },
  106. /**
  107. * 获取账户明细
  108. */
  109. getUserBillList: function() {
  110. let that = this;
  111. if (that.loadend) return;
  112. if (that.loading) return;
  113. that.loading = true;
  114. that.loadTitle = "";
  115. let data = {
  116. page: that.page,
  117. limit: that.limit,
  118. type: that.type
  119. }
  120. getBillList(data).then(function(res) {
  121. let list = res.data.list?res.data.list:[],
  122. loadend = res.data.list < res.data.limit;
  123. that.userBillList = that.$util.SplitArray(list, that.userBillList);
  124. that.$set(that, 'userBillList', that.userBillList);
  125. that.loadend = loadend;
  126. that.loading = false;
  127. that.loadTitle = loadend ? "哼😕~我也是有底线的~" : "加载更多";
  128. that.page = that.page + 1;
  129. }, function(res) {
  130. that.loading = false;
  131. that.loadTitle = '加载更多';
  132. });
  133. },
  134. /**
  135. * 切换导航
  136. */
  137. changeType: function(type) {
  138. this.type = type;
  139. this.loadend = false;
  140. this.page = 1;
  141. this.$set(this, 'userBillList', []);
  142. this.getUserBillList();
  143. },
  144. }
  145. }
  146. </script>
  147. <style scoped lang='scss'>
  148. .sign-record{
  149. }
  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: $theme-color;
  164. border-bottom: 3rpx solid $theme-color;
  165. }
  166. </style>