log.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="container">
  3. <mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ use: false }" :up="upOption"
  4. @up="upCallback">
  5. <view class="log-list">
  6. <view v-for="(item, index) in list.content" :key="index" class="log-item">
  7. <view class="item-left flex-box">
  8. <view class="rec-status">
  9. <text>{{ item.description ? item.description : '' }}</text>
  10. <text v-if="!item.description">{{ item.amount > 0 ? '增加金额' : '减少金额' }}</text>
  11. </view>
  12. <view class="rec-time">
  13. <text>{{ item.createTime | timeFormat('yyyy-mm-dd hh:MM') }}</text>
  14. </view>
  15. </view>
  16. <view class="item-right">
  17. <text>{{ item.amount > 0 ? '+' : '' }}{{ item.amount }}元</text>
  18. </view>
  19. </view>
  20. </view>
  21. </mescroll-body>
  22. </view>
  23. </template>
  24. <script>
  25. import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
  26. import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
  27. import * as LogApi from '@/api/balance'
  28. import { getEmptyPaginateObj, getMoreListData } from '@/utils/app'
  29. const pageSize = 20
  30. export default {
  31. components: {
  32. MescrollBody
  33. },
  34. mixins: [MescrollMixin],
  35. data() {
  36. return {
  37. // 余额账单明细列表
  38. list: getEmptyPaginateObj(),
  39. // 上拉加载配置
  40. upOption: {
  41. // 首次自动执行
  42. auto: true,
  43. // 每页数据的数量; 默认20
  44. page: { size: pageSize },
  45. // 数量要大于12条才显示无更多数据
  46. noMoreSize: 20,
  47. // 空布局
  48. empty: {
  49. tip: '亲,暂无账单明细.'
  50. }
  51. }
  52. }
  53. },
  54. /**
  55. * 生命周期函数--监听页面加载
  56. */
  57. onLoad(options) {},
  58. methods: {
  59. /**
  60. * 上拉加载的回调 (页面初始化时也会执行一次)
  61. * 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
  62. * @param {Object} page
  63. */
  64. upCallback(page) {
  65. const app = this
  66. // 设置列表数据
  67. app.getLogList(page.num)
  68. .then(list => {
  69. const curPageLen = list.content.length
  70. const totalSize = list.totalElements
  71. app.mescroll.endBySize(curPageLen, totalSize)
  72. })
  73. .catch(() => app.mescroll.endErr())
  74. },
  75. // 获取余额账单明细列表
  76. getLogList(pageNo = 1) {
  77. const app = this
  78. return new Promise((resolve, reject) => {
  79. LogApi.list({ page: pageNo })
  80. .then(result => {
  81. // 合并新数据
  82. const newList = result.data.data
  83. app.list.content = getMoreListData(newList, app.list, pageNo)
  84. resolve(newList)
  85. })
  86. })
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. page,
  93. .container {
  94. background: #fff;
  95. }
  96. .log-list {
  97. padding: 0 30rpx;
  98. }
  99. .log-item {
  100. font-size: 28rpx;
  101. padding: 20rpx 20rpx;
  102. line-height: 1.8;
  103. border-bottom: 1rpx solid rgb(238, 238, 238);
  104. display: flex;
  105. justify-content: center;
  106. align-items: center;
  107. }
  108. .item-right {
  109. color: #000;
  110. font-weight: bold;
  111. }
  112. .rec-status {
  113. color: #333;
  114. .rec-time {
  115. color: rgb(160, 160, 160);
  116. font-size: 26rpx;
  117. }
  118. }
  119. </style>