index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. toLogin()
  80. }
  81. },
  82. /**
  83. * 生命周期函数--监听页面加载
  84. */
  85. onLoad: function(options) {
  86. this.type = options.type || 0;
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. onReachBottom: function() {
  92. this.getUserBillList();
  93. },
  94. methods: {
  95. /**
  96. * 授权回调
  97. */
  98. onLoadFun: function() {
  99. this.getUserBillList();
  100. this.isShowAuth = false;
  101. },
  102. // 授权关闭
  103. authColse: function(e) {
  104. this.isShowAuth = e
  105. },
  106. /**
  107. * 获取账户明细
  108. */
  109. getUserBillList: function() {
  110. let that = this;
  111. let page = that.page;
  112. let limit = that.limit;
  113. if (that.loading) return;
  114. if (that.loadend) return;
  115. that.loading = true;
  116. that.loadTitle = '';
  117. moneyList({
  118. page: page,
  119. limit: limit
  120. },that.type).then(res => {
  121. for (let i = 0; i < res.data.time.length; i++) {
  122. if (!this.times.includes(res.data.time[i])) {
  123. this.times.push(res.data.time[i])
  124. this.userBillList.push({
  125. time: res.data.time[i],
  126. child: []
  127. })
  128. }
  129. }
  130. for (let x = 0; x < this.times.length; x++) {
  131. for (let j = 0; j < res.data.list.length; j++) {
  132. if (this.times[x] === res.data.list[j].time_key) {
  133. this.userBillList[x].child.push(res.data.list[j])
  134. }
  135. }
  136. }
  137. let loadend = res.data.list.length < that.limit;
  138. that.loadend = loadend;
  139. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  140. that.page += 1;
  141. that.loading = false;
  142. }).catch(err=>{
  143. that.loading = false;
  144. that.loadTitle = '加载更多';
  145. })
  146. },
  147. // getUserBillList: function() {
  148. // let that = this;
  149. // if (that.loadend) return;
  150. // if (that.loading) return;
  151. // that.loading = true;
  152. // that.loadTitle = "";
  153. // let data = {
  154. // page: that.page,
  155. // limit: that.limit
  156. // }
  157. // getCommissionInfo(data, that.type).then(function(res) {
  158. // let list = res.data,
  159. // loadend = list.length < that.limit;
  160. // that.userBillList = that.$util.SplitArray(list, that.userBillList);
  161. // that.$set(that, 'userBillList', that.userBillList);
  162. // that.loadend = loadend;
  163. // that.loading = false;
  164. // that.loadTitle = loadend ? "没有更多内容啦~" : "加载更多";
  165. // that.page = that.page + 1;
  166. // }, function(res) {
  167. // that.loading = false;
  168. // that.loadTitle = '加载更多';
  169. // });
  170. // },
  171. /**
  172. * 切换导航
  173. */
  174. changeType: function(type) {
  175. this.type = type;
  176. this.loadend = false;
  177. this.page = 1;
  178. this.times = [];
  179. this.$set(this, 'userBillList', []);
  180. this.getUserBillList();
  181. },
  182. }
  183. }
  184. </script>
  185. <style scoped lang='scss'>
  186. .bill-details .nav {
  187. background-color: #fff;
  188. height: 90rpx;
  189. width: 100%;
  190. line-height: 90rpx;
  191. }
  192. .bill-details .nav .item {
  193. flex: 1;
  194. text-align: center;
  195. font-size: 30rpx;
  196. color: #282828;
  197. }
  198. .bill-details .nav .item.on {
  199. color: var(--view-theme);
  200. border-bottom: 3rpx solid var(--view-theme);
  201. }
  202. </style>