score.vue 2.1 KB

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