money.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="">
  3. <!-- 顶部导航 -->
  4. <fa-navbar title="余额日志"></fa-navbar>
  5. <view class="u-p-t-30 u-p-l-30 u-p-r-30" v-for="(item, index) in list" :key="index">
  6. <view class="u-bg-white fa-cell">
  7. <u-cell-item
  8. center
  9. :title="'¥ ' + item.money"
  10. :title-style="item.titleColor"
  11. :label="item.createtime"
  12. :value-style="item.valueColor"
  13. :value="item.memo"
  14. :arrow="false"
  15. ></u-cell-item>
  16. </view>
  17. </view>
  18. <!-- 加载更多 -->
  19. <view class="u-p-t-30 u-p-b-30" v-if="list.length"><u-loadmore bg-color="#f4f6f8" :status="has_more ? status : 'nomore'" /></view>
  20. <!-- 空数据 -->
  21. <view class="fa-empty" v-if="!list.length"><u-empty></u-empty></view>
  22. <!-- 回到顶部 -->
  23. <u-back-top :scroll-top="scrollTop" :icon-style="{color:theme.bgColor}" :custom-style="{backgroundColor:lightColor}"></u-back-top>
  24. <!-- 底部导航 -->
  25. <fa-tabbar></fa-tabbar>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. onLoad() {
  31. this.getMoneyLogs();
  32. },
  33. data() {
  34. return {
  35. scrollTop: 0,
  36. list: [],
  37. status: 'loadmore',
  38. has_more: false,
  39. page: 1
  40. };
  41. },
  42. methods: {
  43. getMoneyLogs: async function() {
  44. let res = await this.$api.getMoneyLogs({ page: this.page });
  45. this.status = 'loadmore';
  46. if (!res.code) {
  47. this.$u.toast(res.msg);
  48. return;
  49. }
  50. let data = res.data.data;
  51. if(!data || !data.length){
  52. return;
  53. }
  54. data.forEach(item => {
  55. item.titleColor = { fontSize: '40rpx', color: item.money < 0 ? '#fb8080' : this.theme ? this.theme.bgColor : '#2979ff' };
  56. item.valueColor = { color: item.score < 0 ? '#fb8080' : '#999999' };
  57. });
  58. this.list = this.list.concat(data);
  59. this.has_more = res.data.last_page > res.data.current_page;
  60. }
  61. },
  62. onPageScroll(e) {
  63. this.scrollTop = e.scrollTop;
  64. },
  65. onReachBottom() {
  66. if (this.has_more) {
  67. this.status = 'loading';
  68. this.page++;
  69. this.getMoneyLogs();
  70. }
  71. }
  72. };
  73. </script>
  74. <style>
  75. page {
  76. background-color: #f4f6f8;
  77. }
  78. .fa-cell {
  79. box-shadow: 0px 0px 3px 0px rgba(0, 78, 255, 0.1);
  80. border-radius: 10rpx;
  81. }
  82. </style>