Browse Source

// 添加了好房源向右加载 ,房源推荐上拉加载和下拉刷新的限制

master
xjw123456 1 year ago
parent
commit
b3a07c4fa2
1 changed files with 65 additions and 9 deletions
  1. +65
    -9
      pages/index/index.vue

+ 65
- 9
pages/index/index.vue View File

@ -55,14 +55,17 @@
<view class="ant-page-span">品质保障</view> <view class="ant-page-span">品质保障</view>
</view> </view>
<view class="ant-flex-line">
<view class="ant-page-image-item" v-for="(item,index) in hotList">
<image class="ant-page-image-item" mode="aspectFill" :src="item.image === null? image:item.image"/>
<view class="ant-img-tags">
<!-- <view class="ant-tags-title">{{item.title}}</view> -->
<view class="ant-tags-text">{{item.price}}元起</view>
<view class="ant-flex-line scroll-view_H_x">
<scroll-view class="scroll-view_H" scroll-x="true" lower-threshold="51" @scrolltolower="scrollTolowerHotList" >
<view class="ant-page-image-item" v-for="(item,index) in hotList">
<image class="ant-page-image-item" mode="aspectFill" :src="item.image === null? image:item.image"/>
<view class="ant-img-tags">
<!-- <view class="ant-tags-title">{{item.title}}</view> -->
<view class="ant-tags-text">{{item.price}}元起</view>
</view>
</view> </view>
</view>
</scroll-view>
</view> </view>
</view> </view>
@ -114,6 +117,9 @@
page: 1, page: 1,
total: null, total: null,
is_pull: 1, // 1 2 is_pull: 1, // 1 2
scrollPage: 1, //
scrollSize:20,
scrollTotal:null,
} }
}, },
onLoad() { onLoad() {
@ -131,9 +137,18 @@
// //
onReachBottom() { onReachBottom() {
this.is_pull = 2; this.is_pull = 2;
const page = this.page;
const size = this.size;
const total = this.total;
// //
if(page * size > total) {
this.$functions.showToast('没有更多了')
return;
}
this.getHouseListPage() this.getHouseListPage()
}, },
//
// h5 // h5
onReady() { onReady() {
@ -178,10 +193,35 @@
// console.log(res.records) // console.log(res.records)
// }) // })
}, },
//
scrollTolowerHotList () {
//
const scrollPage = this.scrollPage;
const scrollSize = this.scrollSize;
const scrollTotal = this.scrollTotal;
if(scrollPage* scrollSize > scrollTotal) {
this.$functions.showToast('没有更多了');
return;
}
this.$functions.showLoading();
this.getHotList();
},
// //
getHotList(){ getHotList(){
this.$api.getHotList().then(res => { this.$api.getHotList().then(res => {
if(this.scrollTotal !== null){
this.scrollPage+=1;
const hotList = this.hotList;
this.hotList = hotList.concat(res.result.records);
this.$functions.hideLoading();
}else if(this.scrollTotal === null) {
this.scrollSize = res.result.size;
this.scrollTotal = res.result.total;
this.hotList = res.result.records; this.hotList = res.result.records;
}
}).catch(err => { }).catch(err => {
console.log(err,"错误信息") console.log(err,"错误信息")
}); });
@ -194,10 +234,17 @@
getHouseListPage() { getHouseListPage() {
// is_pull 1 2 // is_pull 1 2
const is_pull = this.is_pull; const is_pull = this.is_pull;
this.$functions.showLoading();
this.$api.getHouseListPage().then(res => { this.$api.getHouseListPage().then(res => {
this.list = res.result;
// this.list = res.result;
if(this.page === 1 || this.total == null || is_pull === 1) {
this.total = res.result.total;
this.size = res.result.size;
}
console.log(is_pull)
if(is_pull === 1) { if(is_pull === 1) {
// //
console.log(123132)
this.page = 1; this.page = 1;
this.list = res.result.records; this.list = res.result.records;
}else { }else {
@ -205,7 +252,9 @@
this.page +=1; this.page +=1;
this.list = this.list.concat(res.result.records); this.list = this.list.concat(res.result.records);
} }
this.$functions.hideLoading();
}).catch(err => { }).catch(err => {
this.$functions.hideLoading();
console.log(err,"错误信息") console.log(err,"错误信息")
}); });
// this.$request('/job-dev/house/applet/indexListPage',{},'GET', (res) => { // this.$request('/job-dev/house/applet/indexListPage',{},'GET', (res) => {
@ -361,6 +410,12 @@
padding: 24rpx 0; padding: 24rpx 0;
margin-bottom: 24rpx; margin-bottom: 24rpx;
.scroll-view_H{
// width: 100%;
white-space: nowrap;
width: 100%;
height: 300rpx;
}
.ant-page-title{ .ant-page-title{
color: #000; color: #000;
font-size: 32rpx; font-size: 32rpx;
@ -382,6 +437,7 @@
} }
.ant-page-image-item{ .ant-page-image-item{
display: inline-block;
border-radius: 4rpx; border-radius: 4rpx;
width: 240rpx; width: 240rpx;
height: 300rpx; height: 300rpx;
@ -476,7 +532,7 @@
} }
</style> </style>


Loading…
Cancel
Save