index.vue 5.8 KB

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