en-list.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="list">
  3. <Blank v-if="list.length<0"></Blank>
  4. <view class="scroll-view" v-else>
  5. <scroll-view class="scroll-list" scroll-y="true" style="height: 100%;" @scrolltolower="onReachScollBottom" :scroll-top="scrollTop" @scroll="scroll">
  6. <slot name="listInfo" v-bind:pagingData="list" ></slot>
  7. <view class="toMore" v-show="isAjax">加载中-----</view>
  8. </scroll-view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import Blank from 'components/en-utils/en-blank/en-blank'
  14. export default {
  15. components: {Blank},
  16. data() {
  17. return {
  18. list: [],
  19. scrollTop: 0,
  20. page: 1,
  21. total: null,
  22. isAjax: false,
  23. }
  24. },
  25. mounted() {
  26. this.getList()
  27. },
  28. methods: {
  29. scroll: function(e) {
  30. this.scrollTop = e.detail.scrollTop
  31. },
  32. onReachScollBottom() {
  33. if (this.isAjax || this.list.length === this.total) {
  34. return
  35. }
  36. this.getList()
  37. },
  38. getList() {
  39. this.isAjax = true
  40. this.$emit('getList',this.page)
  41. },
  42. startList() {
  43. this.list = []
  44. this.page = 1
  45. this.isAjax = false
  46. },
  47. setList(list, total) {
  48. list.forEach((item) => {
  49. this.list.push(item)
  50. })
  51. this.total = total
  52. this.isAjax = false
  53. ++this.page;
  54. }
  55. },
  56. }
  57. </script>
  58. <style scoped lang="scss">
  59. .list {
  60. height: 100%;
  61. .scroll-view {
  62. flex: 1;
  63. overflow: auto;
  64. .scroll-list {
  65. width: 100%;
  66. max-height: 100vh;
  67. }
  68. }
  69. .toMore {
  70. color: #999;
  71. font-size: 20rpx;
  72. margin: 25rpx 0;
  73. text-align: center;
  74. }
  75. ::-webkit-scrollbar {
  76. display: none;
  77. width: 0;
  78. height: 0;
  79. background-color: transparent;
  80. }
  81. }
  82. </style>