index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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)'>全部</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.child" :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. <home v-if="navigation"></home>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. getCommissionInfo,
  39. moneyList
  40. } from '@/api/user.js';
  41. import {
  42. toLogin
  43. } from '@/libs/login.js';
  44. import {
  45. mapGetters
  46. } from "vuex";
  47. import emptyPage from '@/components/emptyPage.vue';
  48. import home from '@/components/home';
  49. import colors from "@/mixins/color";
  50. export default {
  51. components: {
  52. emptyPage,
  53. home
  54. },
  55. mixins: [colors],
  56. data() {
  57. return {
  58. loadTitle: '加载更多',
  59. loading: false,
  60. loadend: false,
  61. page: 1,
  62. limit: 15,
  63. type: 0,
  64. userBillList: [],
  65. times:[],
  66. isAuto: false, //没有授权的不会自动授权
  67. isShowAuth: false //是否隐藏授权
  68. };
  69. },
  70. computed: mapGetters(['isLogin']),
  71. onShow() {
  72. uni.removeStorageSync('form_type_cart');
  73. if (this.isLogin) {
  74. this.getUserBillList();
  75. } else {
  76. toLogin();
  77. }
  78. },
  79. /**
  80. * 生命周期函数--监听页面加载
  81. */
  82. onLoad: function(options) {
  83. this.type = options.type || 0;
  84. },
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom: function() {
  89. this.getUserBillList();
  90. },
  91. methods: {
  92. /**
  93. * 授权回调
  94. */
  95. onLoadFun: function() {
  96. this.getUserBillList();
  97. },
  98. // 授权关闭
  99. authColse: function(e) {
  100. this.isShowAuth = e
  101. },
  102. /**
  103. * 获取账户明细
  104. */
  105. getUserBillList: function() {
  106. let that = this;
  107. let page = that.page;
  108. let limit = that.limit;
  109. if (that.loading) return;
  110. if (that.loadend) return;
  111. that.loading = true;
  112. that.loadTitle = '';
  113. moneyList({
  114. page: page,
  115. limit: limit
  116. },that.type).then(res => {
  117. for (let i = 0; i < res.data.time.length; i++) {
  118. if (!this.times.includes(res.data.time[i])) {
  119. this.times.push(res.data.time[i])
  120. this.userBillList.push({
  121. time: res.data.time[i],
  122. child: []
  123. })
  124. }
  125. }
  126. for (let x = 0; x < this.times.length; x++) {
  127. for (let j = 0; j < res.data.list.length; j++) {
  128. if (this.times[x] === res.data.list[j].time_key) {
  129. this.userBillList[x].child.push(res.data.list[j])
  130. }
  131. }
  132. }
  133. let loadend = res.data.list.length < that.limit;
  134. that.loadend = loadend;
  135. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  136. that.page += 1;
  137. that.loading = false;
  138. }).catch(err=>{
  139. that.loading = false;
  140. that.loadTitle = '加载更多';
  141. })
  142. },
  143. // getUserBillList: function() {
  144. // let that = this;
  145. // if (that.loadend) return;
  146. // if (that.loading) return;
  147. // that.loading = true;
  148. // that.loadTitle = "";
  149. // let data = {
  150. // page: that.page,
  151. // limit: that.limit
  152. // }
  153. // getCommissionInfo(data, that.type).then(function(res) {
  154. // let list = res.data,
  155. // loadend = list.length < that.limit;
  156. // that.userBillList = that.$util.SplitArray(list, that.userBillList);
  157. // that.$set(that, 'userBillList', that.userBillList);
  158. // that.loadend = loadend;
  159. // that.loading = false;
  160. // that.loadTitle = loadend ? "没有更多内容啦~" : "加载更多";
  161. // that.page = that.page + 1;
  162. // }, function(res) {
  163. // that.loading = false;
  164. // that.loadTitle = '加载更多';
  165. // });
  166. // },
  167. /**
  168. * 切换导航
  169. */
  170. changeType: function(type) {
  171. this.type = type;
  172. this.loadend = false;
  173. this.page = 1;
  174. this.times = [];
  175. this.$set(this, 'userBillList', []);
  176. this.getUserBillList();
  177. },
  178. }
  179. }
  180. </script>
  181. <style scoped lang='scss'>
  182. .bill-details .nav {
  183. background-color: #fff;
  184. height: 90rpx;
  185. width: 100%;
  186. line-height: 90rpx;
  187. }
  188. .bill-details .nav .item {
  189. flex: 1;
  190. text-align: center;
  191. font-size: 30rpx;
  192. color: #282828;
  193. }
  194. .bill-details .nav .item.on {
  195. color: var(--view-theme);
  196. border-bottom: 3rpx solid var(--view-theme);
  197. }
  198. </style>