// pages/hotel/hotel.js const app = getApp() var host = app.globalData.host; Page({ /** * 页面的初始数据 */ data: { info:{}, aid:'', data:{}, date:'', show:0, s_time:'', e_time:'', room_nums:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.showNavigationBarLoading(); // options.id=1; // options.conference_id=1; this.setData({ aid: Number(options.aid) }) wx.request({ url: host + '/api/signup/hotel', method: 'GET', data: { id: options.id }, success: res => { wx.hideNavigationBarLoading(); this.setData({ info: res.data.data }) }, fail: function () { wx.hideLoading(); wx.showToast({ title: '服务器开小差啦!', icon: 'none' }) } }) }, show_order:function(e){ var i = e.target.dataset.id; this.setData({ show:1, data:this.data.info.rooms[i] }) }, bindDateChange:function(e){ this.setData({ s_time:e.detail.value }) }, bindDateChange1: function (e) { this.setData({ e_time: e.detail.value }) }, bindinputChange:function(e){ this.setData({ room_nums:e.detail.value }) }, order:function(e){ var data={}; data.hotel_id=this.data.info.id; data.room_id=e.target.dataset.id; data.id = this.data.aid; data.room_stime=this.data.s_time; data.room_etime = this.data.e_time; wx.request({ url: host + '/api/user/signup', method: 'PUT', data: data, success: (res => { if (res.data.code == 0) { wx.showToast({ title: '预定成功', }) this.setData({ show: 0 }) } else { wx.showToast({ title: '提交失败', icon: 'none' }) } }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })