user_bill.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!-- 账户明细 -->
  2. <template>
  3. <view class="user-bill">
  4. <mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" :up="upOption" @down="downCallback">
  5. <u-tabs :list="tabsList" :is-scroll="false" :current="currentTab" :bold="false" :active-color="colorConfig.primary"
  6. @change="changeTab" />
  7. <view class="p-t-20" >
  8. <view class="bg-white" v-for="(item, index) in list" :key="index" >
  9. <record-cell :remark="item.source_type" :date="item.create_time_format" :money="item.change_amount_format" :type="item.change_type" />
  10. </view>
  11. </view>
  12. </mescroll-body>
  13. </view>
  14. </template>
  15. <script>
  16. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  17. import {getAccountLog} from "@/api/user"
  18. export default {
  19. mixins: [MescrollMixin], // 使用mixin
  20. data() {
  21. return {
  22. // Tabs 列表
  23. tabsList: [{
  24. name: '全部'
  25. }, {
  26. name: '收入'
  27. }, {
  28. name: '支出'
  29. }],
  30. upOption: {
  31. empty: {
  32. icon: '/static/images/order_null.png',
  33. tip: '暂无记录', // 提示
  34. }
  35. },
  36. currentTab: 0,
  37. list: [], // 列表数据--全部
  38. };
  39. },
  40. methods: {
  41. // 改变当前的Tabs位置
  42. changeTab(index) {
  43. this.currentTab = index;
  44. this.list = []
  45. this.mescroll.resetUpScroll();
  46. },
  47. // 上拉加载
  48. upCallback(page) {
  49. const pageNum = page.num; // 页码, 默认从1开始
  50. const pageSize = page.size; // 页长, 默认每页10条
  51. getAccountLog({
  52. page_size: pageSize,
  53. page_no: pageNum,
  54. source: 1,
  55. type: this.currentTab
  56. }).then(({
  57. data
  58. }) => {
  59. if (page.num == 1) this.list = [];
  60. const curPageData = data.list;
  61. const curPageLen = curPageData.length;
  62. const hasNext = !!data.more;
  63. this.list = this.list.concat(curPageData);
  64. this.mescroll.endSuccess(curPageLen, hasNext);
  65. }).catch(() => {
  66. this.mescroll.endErr()
  67. })
  68. }
  69. },
  70. onLoad(options) {
  71. console.log(options, "option")
  72. this.currentTab = options.mode || 0;
  73. }
  74. }
  75. </script>
  76. <style scoped>
  77. </style>