hotel.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. start:'',
  19. end:''
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. wx.showNavigationBarLoading();
  26. // options.id=1;
  27. // options.conference_id=1;
  28. this.setData({
  29. aid: Number(options.aid)
  30. })
  31. wx.request({
  32. url: host + '/api/detail',
  33. method: 'GET',
  34. data: {
  35. type: 'conference',
  36. id: options.huiyi_id,
  37. },
  38. success:res=>{
  39. this.setData({
  40. start: res.data.data.begin_time.split(' ')[0],
  41. start1: res.data.data.begin_time.split(' ')[0],
  42. end: res.data.data.end_time.split(' ')[0]
  43. })
  44. }
  45. })
  46. wx.request({
  47. url: host + '/api/signup/hotel',
  48. method: 'GET',
  49. data: {
  50. id: options.id
  51. },
  52. success: res => {
  53. wx.hideNavigationBarLoading();
  54. this.setData({
  55. info: res.data.data
  56. })
  57. },
  58. fail: function () {
  59. wx.hideLoading();
  60. wx.showToast({
  61. title: '服务器开小差啦!',
  62. icon: 'none'
  63. })
  64. }
  65. })
  66. },
  67. close(){
  68. this.setData({
  69. show: 0
  70. })
  71. },
  72. show_order:function(e){
  73. var i = e.target.dataset.id;
  74. var data = this.data.info.rooms[i]
  75. var num = data.enable_number,nums=[];
  76. for(let i=1;i<=num;i++){
  77. nums.push(i)
  78. }
  79. data.nums = nums
  80. this.setData({
  81. show:1,
  82. data: data
  83. })
  84. },
  85. bindDateChange:function(e){
  86. this.setData({
  87. s_time:e.detail.value,
  88. start1: e.detail.value
  89. })
  90. },
  91. bindDateChange1: function (e) {
  92. this.setData({
  93. e_time: e.detail.value
  94. })
  95. },
  96. bindinputChange:function(e){
  97. this.setData({
  98. room_nums:e.detail.value
  99. })
  100. },
  101. order:function(e){
  102. var data={};
  103. data.hotel_id=this.data.info.id;
  104. data.room_id=e.target.dataset.id;
  105. data.id = this.data.aid;
  106. data.room_stime=this.data.s_time;
  107. data.room_etime = this.data.e_time;
  108. data.room_nums = this.data.room_nums;
  109. if (!data.room_nums || !data.room_stime || !data.room_etime){
  110. wx.showToast({
  111. title: '请输入入住人数和时间',
  112. icon: 'none'
  113. })
  114. return
  115. }
  116. wx.request({
  117. url: host + '/api/user/signup',
  118. method: 'PUT',
  119. data: data,
  120. success: (res => {
  121. if (res.data.code == 0) {
  122. wx.showToast({
  123. title: '预定成功',
  124. })
  125. this.setData({
  126. success:true
  127. })
  128. } else {
  129. wx.showToast({
  130. title: '提交失败',
  131. icon: 'none'
  132. })
  133. }
  134. })
  135. })
  136. },
  137. home: function () {
  138. wx.redirectTo({
  139. url: '../order/order',
  140. })
  141. },
  142. /**
  143. * 生命周期函数--监听页面初次渲染完成
  144. */
  145. onReady: function () {
  146. },
  147. /**
  148. * 生命周期函数--监听页面显示
  149. */
  150. onShow: function () {
  151. },
  152. /**
  153. * 生命周期函数--监听页面隐藏
  154. */
  155. onHide: function () {
  156. },
  157. /**
  158. * 生命周期函数--监听页面卸载
  159. */
  160. onUnload: function () {
  161. },
  162. /**
  163. * 页面相关事件处理函数--监听用户下拉动作
  164. */
  165. onPullDownRefresh: function () {
  166. },
  167. /**
  168. * 页面上拉触底事件的处理函数
  169. */
  170. onReachBottom: function () {
  171. },
  172. /**
  173. * 用户点击右上角分享
  174. */
  175. onShareAppMessage: function () {
  176. }
  177. })