hotel.js 2.7 KB

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