12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <template>
- <view class="collect">
- <mescroll-body top="30" bottom="40" @init="mescrollInit" @down="downCallback" @up="upCallback" :option="{}">
- <view class="house-list">
- <house-item v-for="(item,index) in list" :house="item" :key="item.id"></house-item>
- </view>
- </mescroll-body>
- </view>
- </template>
- <script>
- import {
- getCollectionHouseListByPage
- } from '@/request/api/house.js'
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- import houseItem from "@/components/house/houseItem.vue";
- export default {
- mixins: [MescrollMixin], // 使用mixin
- data() {
- return {
- list: [],
- coordinates: ''
- }
- },
- onLoad() {
- this.coordinates = this.$store.getters.coordinates;
- },
- methods: {
- /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
- upCallback(page) {
- getCollectionHouseListByPage(page.num, 10, this.coordinates).then(res => {
- if (res.code === 200) {
- this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
- if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
- let data = res.data.dataList;
- this.list = this.list.concat(data); //追加新数据
- } else {
- this.mescroll.endErr();
- }
- }).catch(() => {
- //联网失败, 结束加载
- this.mescroll.endErr();
- })
- }
- },
- components: {
- houseItem
- }
- }
- </script>
- <style lang="scss">
- .collect {
- .house-list {
- padding: 0 30rpx;
- }
- }
- </style>
|