|
@@ -30,7 +30,12 @@ Component({
|
|
|
//搜索
|
|
|
value: '',
|
|
|
start:'',
|
|
|
- end:''
|
|
|
+ end:'',
|
|
|
+
|
|
|
+ //触底加载
|
|
|
+ loadedItems:0,
|
|
|
+ pageSize:5,
|
|
|
+ noMoreItems:false,
|
|
|
},
|
|
|
lifetimes: {
|
|
|
detached: function () {},
|
|
@@ -156,7 +161,8 @@ Component({
|
|
|
ShopStore.equalTo('company', company);
|
|
|
ShopStore.equalTo('type', "stay");
|
|
|
ShopStore.notEqualTo('isDeleted', "true");
|
|
|
-
|
|
|
+ ShopStore.limit(this.data.pageSize);
|
|
|
+ ShopStore.skip(this.data.loadedItems);
|
|
|
let store = await ShopStore.find();
|
|
|
let storeListPromises = store.map(async item => {
|
|
|
let storeItem = item.toJSON();
|
|
@@ -167,9 +173,18 @@ Component({
|
|
|
});
|
|
|
|
|
|
let storeList = await Promise.all(storeListPromises); // 等待所有的Promise完成
|
|
|
-
|
|
|
+ if(storeList.length<this.data.pageSize){
|
|
|
+ this.setData({
|
|
|
+ noMoreItems:true
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setData({
|
|
|
+ noMoreItems:false
|
|
|
+ })
|
|
|
+ }
|
|
|
this.setData({
|
|
|
- storeList
|
|
|
+ storeList:this.data.storeList.concat(storeList),
|
|
|
+ loadedItems:this.data.loadedItems+storeList.length,
|
|
|
});
|
|
|
|
|
|
console.log(this.data.storeList);
|
|
@@ -348,28 +363,12 @@ Component({
|
|
|
} catch (error) {
|
|
|
console.error("查询商店时出现错误:", error);
|
|
|
}
|
|
|
+ },
|
|
|
+ //触底加载
|
|
|
+ async loadMoreData(){
|
|
|
+ if(!this.data.noMoreItems){
|
|
|
+ await this.gethomestar()
|
|
|
+ }
|
|
|
}
|
|
|
- //添加后台经纬度
|
|
|
- // async setadd() {
|
|
|
- // let ShopStore = new Parse.Query('ShopStore');
|
|
|
- // ShopStore.equalTo('company', company);
|
|
|
- // ShopStore.equalTo('objectId', "GyeSIi3zwL");
|
|
|
-
|
|
|
- // let store = await ShopStore.first();
|
|
|
-
|
|
|
- // // 创建 GeoPoint 对象
|
|
|
- // let location = new Parse.GeoPoint(28.679224,117.818856); // 注意:GeoPoint 的参数是 (latitude, longitude)
|
|
|
-
|
|
|
- // // 设置 location 字段
|
|
|
- // store.set('location', location);
|
|
|
-
|
|
|
- // try {
|
|
|
- // let saveDate = await store.save();
|
|
|
- // console.log(saveDate);
|
|
|
- // console.log("上传地址成功");
|
|
|
- // } catch (error) {
|
|
|
- // console.error("保存数据时出现错误:", error);
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|
|
|
});
|