index.vue 5.4 KB

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