my-balance.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="p-0-30 bg-white">
  3. <!--列表-->
  4. <view class="d-b-c border-b p-30-0" v-for="(item, index) in tableData" :key="index">
  5. <view class="d-s-s f-w d-c flex-1">
  6. <text class="30">{{ item.scene.text }}</text>
  7. <text class="pt10 gray9 f22">{{ item.create_time }}</text>
  8. </view>
  9. <view class="red" v-if="item.money > 0">+{{ item.money }}元</view>
  10. <view class="red" v-else="">{{ item.money }}元</view>
  11. </view>
  12. <!-- 没有记录 -->
  13. <view class="d-c-c p30" v-if="tableData.length == 0 && !loading">
  14. <text class="iconfont icon-wushuju"></text>
  15. <text class="cont">亲,暂无相关记录哦</text>
  16. </view>
  17. <uni-load-more v-else :loadingType="loadingType"></uni-load-more>
  18. </view>
  19. </template>
  20. <script>
  21. import uniLoadMore from '@/components/uni-load-more.vue';
  22. export default {
  23. components: {
  24. uniLoadMore
  25. },
  26. data() {
  27. return {
  28. /*是否加载完成*/
  29. loading: true,
  30. /*顶部刷新*/
  31. topRefresh: false,
  32. /*手机高度*/
  33. phoneHeight: 0,
  34. /*可滚动视图区域高度*/
  35. scrollviewHigh: 0,
  36. /*数据列表*/
  37. tableData: [],
  38. /*最后一页码数*/
  39. last_page: 0,
  40. /*当前页面*/
  41. page: 1,
  42. /*每页条数*/
  43. list_rows: 20,
  44. no_more: false,
  45. type: 'all'
  46. };
  47. },
  48. computed: {
  49. /*加载中状态*/
  50. loadingType() {
  51. if (this.loading) {
  52. return 1;
  53. } else {
  54. if (this.tableData.length != 0 && this.no_more) {
  55. return 2;
  56. } else {
  57. return 0;
  58. }
  59. }
  60. }
  61. },
  62. onLoad(e) {
  63. this.type = e.type;
  64. /*获取数据*/
  65. this.getData();
  66. },
  67. onReachBottom() {
  68. let self = this;
  69. if (self.page < self.last_page) {
  70. self.page++;
  71. self.getData();
  72. }
  73. self.no_more = true;
  74. },
  75. methods: {
  76. /*获取数据*/
  77. getData() {
  78. let self = this;
  79. let page = self.page;
  80. let list_rows = self.list_rows;
  81. self.loading = true;
  82. self._get(
  83. 'balance.log/lists', {
  84. page: page || 1,
  85. list_rows: list_rows,
  86. type: self.type
  87. },
  88. function(data) {
  89. self.loading = false;
  90. self.tableData = self.tableData.concat(data.data.list.data);
  91. self.last_page = data.data.list.last_page;
  92. if (data.data.list.last_page <= 1) {
  93. self.no_more = true;
  94. return false;
  95. }
  96. }
  97. );
  98. }
  99. }
  100. };
  101. </script>
  102. <style></style>