123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- const Parse = getApp().Parse;
- const app = getApp();
- const company = getApp().globalData.company;
- let navigationBarHeight = getApp().globalData.statusBarHeight + 44;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- storeId: null,
- loadIndex: 1,
- rooms: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let merchant = wx.getStorageSync('merchant')
- let store = wx.getStorageSync('store')
- if (!merchant) {
- wx.navigateTo({
- url: `/nova-tourism/pages/index/index`
- })
- }
- this.setData({
- storeId: store.objectId,
- store: store,
- merchant: merchant
- })
- this.getRooms()
- },
-
- async getStore() {
- let Store = new Parse.Query('ShopStore')
- let hotel = await Store.get(this.data.hotelId)
- hotel = hotel.toJSON()
- if (hotel.content) {
- hotel.content = rechText.formatRichText(hotel.content)
- }
- console.log(hotel)
- this.setData({
- hotel
- })
- },
- async getRooms() {
- let Room = new Parse.Query('ShopRoom')
- Room.equalTo('company', company)
- Room.equalTo("shop", this.data.storeId)
- Room.select(
- 'name',
- 'images',
- 'price',
- 'total',
- 'remaining',
- 'merber',
- 'type',
- 'area',
- 'tags'
- )
- Room.skip((this.data.loadIndex - 1) * 10)
- Room.limit(10)
- let rooms = await Room.find()
- rooms = rooms.map((room) => {
- room = room.toJSON()
- room.tags.slice(0, 5)
- return room
- })
- console.log(rooms)
- if (this.data.loadIndex != 1) {
- rooms = this.data.rooms.concat(rooms)
- }
- this.setData({
- rooms
- })
- },
- loadMore() {
- this.data.loadIndex++;
- this.getRooms()
- },
- edit(event) {
- console.log(event);
- let id = event.detail.id;
- wx.navigateTo({
- url: `/nova-tourism/pages/my/merchant/room-manage/room-edit/index?roomId=${id}`
- })
- },
- addRoom() {
- wx.navigateTo({
- url: `/nova-tourism/pages/my/merchant/room-manage/room-edit/index?storeId=${this.data.storeId}`
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getRooms()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|