collect.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view class="collect">
  3. <mescroll-body top="30" bottom="40" @init="mescrollInit" @down="downCallback" @up="upCallback" :option="{}">
  4. <view class="house-list">
  5. <house-item v-for="(item,index) in list" :house="item" :key="item.id"></house-item>
  6. </view>
  7. </mescroll-body>
  8. </view>
  9. </template>
  10. <script>
  11. import {
  12. getCollectionHouseListByPage
  13. } from '@/request/api/house.js'
  14. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  15. import houseItem from "@/components/house/houseItem.vue";
  16. export default {
  17. mixins: [MescrollMixin], // 使用mixin
  18. data() {
  19. return {
  20. list: []
  21. }
  22. },
  23. onLoad() {
  24. },
  25. methods: {
  26. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  27. upCallback(page) {
  28. getCollectionHouseListByPage(page.num, 10).then(res => {
  29. if (res.code === 200) {
  30. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  31. if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
  32. let data = res.data.dataList;
  33. this.list = this.list.concat(data); //追加新数据
  34. } else {
  35. this.mescroll.endErr();
  36. }
  37. }).catch(() => {
  38. //联网失败, 结束加载
  39. this.mescroll.endErr();
  40. })
  41. }
  42. },
  43. components: {
  44. houseItem
  45. }
  46. }
  47. </script>
  48. <style lang="scss">
  49. .collect {
  50. .house-list {
  51. padding: 0 30rpx;
  52. }
  53. }
  54. </style>