index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='bill-details'>
  4. <view class='nav acea-row'>
  5. <view class='item' :class='type==0 ? "on":""' @click='changeType(0)'>{{$t(`全部`)}}</view>
  6. <view class='item' :class='type==1 ? "on":""' @click='changeType(1)'>{{$t(`消费`)}}</view>
  7. <view class='item' :class='type==2 ? "on":""' @click='changeType(2)'>{{$t(`充值`)}}</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.child" :key="indexn">
  15. <view>
  16. <view class='name line1'>{{$t(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="$t(`暂无账单的记录哦~`)"></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 v-if="navigation"></home>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. getCommissionInfo
  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. import colors from "@/mixins/color";
  55. export default {
  56. components: {
  57. // #ifdef MP
  58. authorize,
  59. // #endif
  60. emptyPage,
  61. home
  62. },
  63. mixins: [colors],
  64. data() {
  65. return {
  66. loadTitle: this.$t(`加载更多`),
  67. loading: false,
  68. loadend: false,
  69. page: 1,
  70. limit: 15,
  71. type: 0,
  72. userBillList: [],
  73. times:[],
  74. isAuto: false, //没有授权的不会自动授权
  75. isShowAuth: false //是否隐藏授权
  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 || 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. let page = that.page;
  115. let limit = that.limit;
  116. if (that.loading) return;
  117. if (that.loadend) return;
  118. that.loading = true;
  119. that.loadTitle = '';
  120. getCommissionInfo({
  121. page: page,
  122. limit: limit
  123. },that.type).then(res => {
  124. for (let i = 0; i < res.data.time.length; i++) {
  125. if (!this.times.includes(res.data.time[i])) {
  126. this.times.push(res.data.time[i])
  127. this.userBillList.push({
  128. time: res.data.time[i],
  129. child: []
  130. })
  131. }
  132. }
  133. for (let x = 0; x < this.times.length; x++) {
  134. for (let j = 0; j < res.data.list.length; j++) {
  135. if (this.times[x] === res.data.list[j].time_key) {
  136. this.userBillList[x].child.push(res.data.list[j])
  137. }
  138. }
  139. }
  140. let loadend = res.data.list.length < that.limit;
  141. that.loadend = loadend;
  142. that.loadTitle = loadend ? that.$t(`我也是有底线的`) : that.$t(`加载更多`);
  143. that.page += 1;
  144. that.loading = false;
  145. }).catch(err=>{
  146. that.loading = false;
  147. that.loadTitle = that.$t(`加载更多`);
  148. })
  149. },
  150. /**
  151. * 切换导航
  152. */
  153. changeType: function(type) {
  154. this.type = type;
  155. this.loadend = false;
  156. this.page = 1;
  157. this.times = [];
  158. this.$set(this, 'userBillList', []);
  159. this.getUserBillList();
  160. },
  161. }
  162. }
  163. </script>
  164. <style scoped lang='scss'>
  165. .bill-details .nav {
  166. background-color: #fff;
  167. height: 90rpx;
  168. width: 100%;
  169. line-height: 90rpx;
  170. }
  171. .bill-details .nav .item {
  172. flex: 1;
  173. text-align: center;
  174. font-size: 30rpx;
  175. color: #282828;
  176. }
  177. .bill-details .nav .item.on {
  178. color: var(--view-theme);
  179. border-bottom: 3rpx solid var(--view-theme);
  180. }
  181. </style>