// 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:'', success:false, start:'', end:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.showNavigationBarLoading(); // options.id=1; // options.conference_id=1; this.setData({ aid: Number(options.aid) }) wx.request({ url: host + '/api/detail', method: 'GET', data: { type: 'conference', id: options.huiyi_id, }, success:res=>{ this.setData({ start: res.data.data.begin_time.split(' ')[0], start1: res.data.data.begin_time.split(' ')[0], end: res.data.data.end_time.split(' ')[0] }) } }) 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' }) } }) }, close(){ this.setData({ show: 0 }) }, show_order:function(e){ var i = e.target.dataset.id; var data = this.data.info.rooms[i] var num = data.enable_number,nums=[]; for(let i=1;i<=num;i++){ nums.push(i) } data.nums = nums this.setData({ show:1, data: data }) }, bindDateChange:function(e){ this.setData({ s_time:e.detail.value, start1: 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; data.room_nums = this.data.room_nums; if (!data.room_nums || !data.room_stime || !data.room_etime){ wx.showToast({ title: '请输入入住人数和时间', icon: 'none' }) return } wx.request({ url: host + '/api/user/signup', method: 'PUT', data: data, success: (res => { if (res.data.code == 0) { wx.showToast({ title: '预定成功', }) this.setData({ success:true }) } else { wx.showToast({ title: '提交失败', icon: 'none' }) } }) }) }, home: function () { wx.redirectTo({ url: '../order/order', }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })