hotel.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // pages/hotel/hotel.js
  2. const app = getApp()
  3. var host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. info:{},
  10. aid:'',
  11. data:{},
  12. date:'',
  13. show:0,
  14. s_time:'',
  15. e_time:'',
  16. room_nums:'',
  17. success:false
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. wx.showNavigationBarLoading();
  24. // options.id=1;
  25. // options.conference_id=1;
  26. this.setData({
  27. aid: Number(options.aid)
  28. })
  29. wx.request({
  30. url: host + '/api/signup/hotel',
  31. method: 'GET',
  32. data: {
  33. id: options.id
  34. },
  35. success: res => {
  36. wx.hideNavigationBarLoading();
  37. this.setData({
  38. info: res.data.data
  39. })
  40. },
  41. fail: function () {
  42. wx.hideLoading();
  43. wx.showToast({
  44. title: '服务器开小差啦!',
  45. icon: 'none'
  46. })
  47. }
  48. })
  49. },
  50. show_order:function(e){
  51. var i = e.target.dataset.id;
  52. this.setData({
  53. show:1,
  54. data:this.data.info.rooms[i]
  55. })
  56. },
  57. bindDateChange:function(e){
  58. this.setData({
  59. s_time:e.detail.value
  60. })
  61. },
  62. bindDateChange1: function (e) {
  63. this.setData({
  64. e_time: e.detail.value
  65. })
  66. },
  67. bindinputChange:function(e){
  68. this.setData({
  69. room_nums:e.detail.value
  70. })
  71. },
  72. order:function(e){
  73. var data={};
  74. data.hotel_id=this.data.info.id;
  75. data.room_id=e.target.dataset.id;
  76. data.id = this.data.aid;
  77. data.room_stime=this.data.s_time;
  78. data.room_etime = this.data.e_time;
  79. data.room_nums = this.data.room_nums;
  80. if (!data.room_nums || !data.room_stime || !data.room_etime){
  81. wx.showToast({
  82. title: '请输入入住人数和时间',
  83. icon: 'none'
  84. })
  85. return
  86. }
  87. wx.request({
  88. url: host + '/api/user/signup',
  89. method: 'PUT',
  90. data: data,
  91. success: (res => {
  92. if (res.data.code == 0) {
  93. wx.showToast({
  94. title: '预定成功',
  95. })
  96. this.setData({
  97. success:true
  98. })
  99. } else {
  100. wx.showToast({
  101. title: '提交失败',
  102. icon: 'none'
  103. })
  104. }
  105. })
  106. })
  107. },
  108. home: function () {
  109. wx.redirectTo({
  110. url: '../order/order',
  111. })
  112. },
  113. /**
  114. * 生命周期函数--监听页面初次渲染完成
  115. */
  116. onReady: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面显示
  120. */
  121. onShow: function () {
  122. },
  123. /**
  124. * 生命周期函数--监听页面隐藏
  125. */
  126. onHide: function () {
  127. },
  128. /**
  129. * 生命周期函数--监听页面卸载
  130. */
  131. onUnload: function () {
  132. },
  133. /**
  134. * 页面相关事件处理函数--监听用户下拉动作
  135. */
  136. onPullDownRefresh: function () {
  137. },
  138. /**
  139. * 页面上拉触底事件的处理函数
  140. */
  141. onReachBottom: function () {
  142. },
  143. /**
  144. * 用户点击右上角分享
  145. */
  146. onShareAppMessage: function () {
  147. }
  148. })