collect.vue 1.6 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. coordinates: ''
  22. }
  23. },
  24. onLoad() {
  25. this.coordinates = this.$store.getters.coordinates;
  26. },
  27. methods: {
  28. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  29. upCallback(page) {
  30. getCollectionHouseListByPage(page.num, 10, this.coordinates).then(res => {
  31. if (res.code === 200) {
  32. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  33. if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
  34. let data = res.data.dataList;
  35. this.list = this.list.concat(data); //追加新数据
  36. } else {
  37. this.mescroll.endErr();
  38. }
  39. }).catch(() => {
  40. //联网失败, 结束加载
  41. this.mescroll.endErr();
  42. })
  43. }
  44. },
  45. components: {
  46. houseItem
  47. }
  48. }
  49. </script>
  50. <style lang="scss">
  51. .collect {
  52. .house-list {
  53. padding: 0 30rpx;
  54. }
  55. }
  56. </style>