|
@@ -29,13 +29,13 @@ Component({
|
|
|
price: 211,
|
|
|
//搜索
|
|
|
value: '',
|
|
|
- start:'',
|
|
|
- end:'',
|
|
|
+ start: '',
|
|
|
+ end: '',
|
|
|
|
|
|
//触底加载
|
|
|
- loadedItems:0,
|
|
|
- pageSize:5,
|
|
|
- noMoreItems:false,
|
|
|
+ loadedItems: 0,
|
|
|
+ pageSize: 3,
|
|
|
+ noMoreItems: false,
|
|
|
|
|
|
},
|
|
|
lifetimes: {
|
|
@@ -75,8 +75,8 @@ Component({
|
|
|
date_end: this.formatDate(tomorrow),
|
|
|
date_start1: this.formatDate(today),
|
|
|
date_end1: this.formatDate(tomorrow),
|
|
|
- start:today,
|
|
|
- end:tomorrow
|
|
|
+ start: today,
|
|
|
+ end: tomorrow
|
|
|
});
|
|
|
console.log(this.data.start, this.data.end);
|
|
|
},
|
|
@@ -106,7 +106,7 @@ Component({
|
|
|
return `${date.getMonth() + 1}月${date.getDate()}日`;
|
|
|
},
|
|
|
//选好日期点击完成后
|
|
|
- async onConfirm(event) {
|
|
|
+ async onConfirm(event) {
|
|
|
const [start, end] = event.detail;
|
|
|
const daysBetween = this.calculateDaysBetween(start, end); // 计算天数差
|
|
|
this.setData({
|
|
@@ -129,11 +129,11 @@ Component({
|
|
|
console.log(this.data.istoday);
|
|
|
}
|
|
|
this.setData({
|
|
|
- loadedItems:0,
|
|
|
- noMoreItems:false,
|
|
|
- storeList:[]
|
|
|
+ loadedItems: 0,
|
|
|
+ noMoreItems: false,
|
|
|
+ storeList: []
|
|
|
})
|
|
|
- await this.gethomestar()
|
|
|
+ await this.gethomestar()
|
|
|
console.log(`入住日期: ${this.data.date_start}, 离店日期: ${this.data.date_end}, 天数差: ${daysBetween}天`);
|
|
|
},
|
|
|
gourl(e) {
|
|
@@ -147,8 +147,8 @@ Component({
|
|
|
date_end: this.data.date_end,
|
|
|
daysBetween: this.data.daysBetween,
|
|
|
istoday: this.data.istoday,
|
|
|
- start:this.data.start,
|
|
|
- end:this.data.end
|
|
|
+ start: this.data.start,
|
|
|
+ end: this.data.end
|
|
|
};
|
|
|
|
|
|
// 将信息转为查询字符串
|
|
@@ -170,6 +170,7 @@ Component({
|
|
|
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();
|
|
|
// 为每一项添加价格属性
|
|
@@ -177,14 +178,18 @@ Component({
|
|
|
storeItem.iscollect = await this.iscollect(storeItem.objectId); // 等待iscollect的结果
|
|
|
return storeItem;
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
let storeList = await Promise.all(storeListPromises); // 等待所有的Promise完成
|
|
|
-
|
|
|
+
|
|
|
+ // 收藏提前-----------------------
|
|
|
+ // 合并新加载的商店和已存在的商店列表
|
|
|
+ let updatedStoreList = this.data.storeList.concat(storeList);
|
|
|
+
|
|
|
// 按照iscollect排序,true的排在前面
|
|
|
- storeList.sort((a, b) => {
|
|
|
+ updatedStoreList.sort((a, b) => {
|
|
|
return (b.iscollect === true) - (a.iscollect === true);
|
|
|
});
|
|
|
-
|
|
|
+ // 收藏提前-----------------------
|
|
|
if (storeList.length < this.data.pageSize) {
|
|
|
this.setData({
|
|
|
noMoreItems: true
|
|
@@ -194,12 +199,12 @@ Component({
|
|
|
noMoreItems: false
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
this.setData({
|
|
|
- storeList: this.data.storeList.concat(storeList),
|
|
|
- loadedItems: this.data.loadedItems + storeList.length,
|
|
|
+ storeList: updatedStoreList,//storeList: this.data.storeList.concat(storeList),
|
|
|
+ loadedItems: this.data.loadedItems + storeList.length,//loadedItems: this.data.loadedItems + storeList.length,
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
console.log(this.data.storeList);
|
|
|
},
|
|
|
//收藏功能
|
|
@@ -331,11 +336,11 @@ Component({
|
|
|
this.clear()
|
|
|
}
|
|
|
},
|
|
|
- clear(){
|
|
|
+ clear() {
|
|
|
this.setData({
|
|
|
- loadedItems:0,
|
|
|
- noMoreItems:false,
|
|
|
- storeList:[]
|
|
|
+ loadedItems: 0,
|
|
|
+ noMoreItems: false,
|
|
|
+ storeList: []
|
|
|
})
|
|
|
this.gethomestar()
|
|
|
},
|
|
@@ -386,8 +391,8 @@ Component({
|
|
|
}
|
|
|
},
|
|
|
//触底加载
|
|
|
- async loadMoreData(){
|
|
|
- if(!this.data.noMoreItems){
|
|
|
+ async loadMoreData() {
|
|
|
+ if (!this.data.noMoreItems) {
|
|
|
await this.gethomestar()
|
|
|
}
|
|
|
},
|