let Parse = getApp().Parse const company = getApp().globalData.company let navigationBarHeight = getApp().globalData.statusBarHeight + 44; Page({ /** * 页面的初始数据 */ data: { hotels: [], active: 0, loadIndex: 1, searchVal: '', stickytop: navigationBarHeight }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ activeColor: getApp().globalData.activeColor || '#229293' }) this.getHotels() }, details(e) { let id = e.detail.id console.log(id) wx.navigateTo({ url: `/nova-tourism/pages/homestay/hotel-details/index?id=${id}` }) }, getHotels: async function (type) { let Hotel = new Parse.Query('ShopStore') Hotel.notEqualTo('isDeleted', "true") Hotel.equalTo('company', company) Hotel.equalTo('type', 'stay') if (this.data.searchVal != '') { Hotel.contains('storeName', this.data.searchVal) } Hotel.select( 'cover', 'storeName', 'perCapita', 'address', 'type', 'isShow' ) // Hotel.equalTo('isShow', true) Hotel.skip((this.data.loadIndex - 1) * 10) if (type == 'price') { Hotel.ascending('perCapita') } Hotel.limit(10) let hotels = await Hotel.find() hotels = hotels.map((hotel) => hotel.toJSON()) console.log(hotels) // hotels = hotels.concat(hotels).concat(hotels).concat(hotels).concat(hotels) hotels = this.data.loadIndex == 1 ? hotels : this.data.hotels.concat(hotels) console.log('hotels', hotels) this.setData({ hotels }) }, search(event) { console.log(event, this.data.searchVal); this.getHotels() }, searchClear() { this.data.searchVal = ''; this.getHotels() }, tabChange(event) { this.data.active = event.detail.name this.data.loadIndex = 1 console.log(this.data.active) this.getHotels(event.detail.name) }, loadMore() { this.data.loadIndex++ console.log('ddddddddddddd', this.data.loadIndex) this.getHotels() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })