index.vue 5.4 KB

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