hotel.js 3.4 KB

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