|
@@ -30,13 +30,13 @@ Component({
|
|
|
price: 211,
|
|
|
//搜索
|
|
|
value: '',
|
|
|
- start:'',
|
|
|
- end:'',
|
|
|
+ start: '',
|
|
|
+ end: '',
|
|
|
|
|
|
//触底加载
|
|
|
- loadedItems:0,
|
|
|
- pageSize:5,
|
|
|
- noMoreItems:false,
|
|
|
+ loadedItems: 0,
|
|
|
+ pageSize: 3,
|
|
|
+ noMoreItems: false,
|
|
|
|
|
|
},
|
|
|
lifetimes: {
|
|
@@ -76,8 +76,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);
|
|
|
},
|
|
@@ -107,7 +107,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({
|
|
@@ -130,11 +130,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) {
|
|
@@ -148,8 +148,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
|
|
|
};
|
|
|
|
|
|
// 将信息转为查询字符串
|
|
@@ -177,6 +177,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();
|
|
|
// 为每一项添加价格属性
|
|
@@ -186,18 +187,29 @@ Component({
|
|
|
});
|
|
|
|
|
|
let storeList = await Promise.all(storeListPromises); // 等待所有的Promise完成
|
|
|
- if(storeList.length<this.data.pageSize){
|
|
|
+
|
|
|
+ // 收藏提前-----------------------
|
|
|
+ // 合并新加载的商店和已存在的商店列表
|
|
|
+ let updatedStoreList = this.data.storeList.concat(storeList);
|
|
|
+
|
|
|
+ // 按照iscollect排序,true的排在前面
|
|
|
+ updatedStoreList.sort((a, b) => {
|
|
|
+ return (b.iscollect === true) - (a.iscollect === true);
|
|
|
+ });
|
|
|
+ // 收藏提前-----------------------
|
|
|
+ if (storeList.length < this.data.pageSize) {
|
|
|
this.setData({
|
|
|
- noMoreItems:true
|
|
|
- })
|
|
|
- }else{
|
|
|
+ noMoreItems: true
|
|
|
+ });
|
|
|
+ } else {
|
|
|
this.setData({
|
|
|
- noMoreItems:false
|
|
|
- })
|
|
|
+ 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 +343,11 @@ Component({
|
|
|
this.clear()
|
|
|
}
|
|
|
},
|
|
|
- clear(){
|
|
|
+ clear() {
|
|
|
this.setData({
|
|
|
- loadedItems:0,
|
|
|
- noMoreItems:false,
|
|
|
- storeList:[]
|
|
|
+ loadedItems: 0,
|
|
|
+ noMoreItems: false,
|
|
|
+ storeList: []
|
|
|
})
|
|
|
this.gethomestar()
|
|
|
},
|
|
@@ -386,8 +398,8 @@ Component({
|
|
|
}
|
|
|
},
|
|
|
//触底加载
|
|
|
- async loadMoreData(){
|
|
|
- if(!this.data.noMoreItems){
|
|
|
+ async loadMoreData() {
|
|
|
+ if (!this.data.noMoreItems) {
|
|
|
await this.gethomestar()
|
|
|
}
|
|
|
},
|