teachingList.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="teachingList">
  3. <statusBar :item="navbarData"></statusBar>
  4. <!-- 消息提示 -->
  5. <msgPop></msgPop>
  6. <view>
  7. <listBlock1 ref="listBlock1" :classList='classList'></listBlock1>
  8. </view>
  9. <view class="loading">
  10. <view v-if="Loading==1">数据加载中...</view>
  11. <view v-if="Loading==2">没有更多了~~</view>
  12. </view>
  13. <!-- <view class="list">
  14. <scroll-view style="height: 100%;" scroll-y="true" refresher-enabled='true' :refresher-triggered="trigger"
  15. @refresherrefresh='pulling'>
  16. </scroll-view>
  17. </view> -->
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. navbarData: {
  25. title: '推荐列表',
  26. btn: 1
  27. },
  28. // 控制刷新
  29. trigger: false,
  30. // 渲染数据
  31. classList: [],
  32. // 触底加载动画提示
  33. Loading: 0, //0默认值 1加载中 2没有更多了
  34. currentPage: 1,
  35. };
  36. },
  37. onUnload() {
  38. this.$store.dispatch('asyncDelAll')
  39. },
  40. methods: {
  41. // 资源库下拉刷新
  42. pulling() {
  43. this.trigger = true
  44. // this.isrepulling = true
  45. setTimeout(() => {
  46. this.trigger = false;
  47. }, 1000);
  48. // 资源库
  49. this.classList = []
  50. this.Loading = 0 //0默认值 1加载中 2没有更多了
  51. this.currentPage = 1 //页数
  52. this.getData()
  53. },
  54. // // 触底
  55. // lower() {
  56. // console.log('没触底?');
  57. // if (this.Loading == 2) return
  58. // this.Loading = 1
  59. // this.currentPage++
  60. // setTimeout(this.getData, 1000)
  61. // },
  62. // 获取页面数据
  63. getData() {
  64. let data = {
  65. openid: uni.getStorageSync('oId'),
  66. ty: 3,
  67. page: this.currentPage, //下拉获取更多的备用字段
  68. lim: 30 //一次获取多少数据
  69. }
  70. this.$request('/selectActivity', "POST", data).then(res => {
  71. // console.log('获取数据', res[0]);
  72. if (this.currentPage == 1) {
  73. this.classList = []
  74. }
  75. if (!res[0].length) {
  76. this.Loading = 2
  77. } else {
  78. this.Loading = 0
  79. }
  80. // return
  81. this.classList = [...this.classList, ...res[0]]
  82. // this.trigger = false;
  83. // this.activeList = res[0]
  84. })
  85. },
  86. },
  87. // 触底加载更多
  88. onReachBottom() {
  89. // if (this.newsLoading == 2) {
  90. // return
  91. // }
  92. // this.newsLoading = 1
  93. // this.currentPage++
  94. // setTimeout(this.getData, 1000)
  95. console.log('没触底?');
  96. if (this.Loading == 2) return
  97. this.Loading = 1
  98. this.currentPage++
  99. setTimeout(this.getData, 1000)
  100. },
  101. onLoad() {
  102. // this.getData()
  103. },
  104. onShow() {
  105. // 一进页面就加载数据
  106. this.getData()
  107. this.$refs.listBlock1.getdata()
  108. // this.$refs.listBlock1.getSub()
  109. }
  110. }
  111. </script>
  112. <style lang="scss">
  113. .teachingList {
  114. height: 100%;
  115. display: flex;
  116. flex-direction: column;
  117. .list {
  118. flex: 1;
  119. }
  120. .list1btn {
  121. z-index: 5;
  122. border: none;
  123. padding: 0;
  124. text-align: center;
  125. // padding: 8px, 24px, 8px, 24px;
  126. background-color: rgba(48, 129, 232, 1);
  127. color: #fff;
  128. border-radius: 100rpx;
  129. float: right;
  130. width: 144rpx;
  131. height: 48rpx;
  132. line-height: 48rpx;
  133. letter-spacing: 1px;
  134. }
  135. }
  136. </style>