hotel.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. wx.navigateTo({
  89. url: '../order/order',
  90. })
  91. } else {
  92. wx.showToast({
  93. title: '提交失败',
  94. icon: 'none'
  95. })
  96. }
  97. })
  98. })
  99. },
  100. /**
  101. * 生命周期函数--监听页面初次渲染完成
  102. */
  103. onReady: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面显示
  107. */
  108. onShow: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload: function () {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh: function () {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom: function () {
  129. },
  130. /**
  131. * 用户点击右上角分享
  132. */
  133. onShareAppMessage: function () {
  134. }
  135. })