hotel.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. wx.request({
  79. url: host + '/api/user/signup',
  80. method: 'PUT',
  81. data: data,
  82. success: (res => {
  83. if (res.data.code == 0) {
  84. wx.showToast({
  85. title: '预定成功',
  86. })
  87. this.setData({
  88. show: 0
  89. })
  90. } else {
  91. wx.showToast({
  92. title: '提交失败',
  93. icon: 'none'
  94. })
  95. }
  96. })
  97. })
  98. },
  99. /**
  100. * 生命周期函数--监听页面初次渲染完成
  101. */
  102. onReady: function () {
  103. },
  104. /**
  105. * 生命周期函数--监听页面显示
  106. */
  107. onShow: function () {
  108. },
  109. /**
  110. * 生命周期函数--监听页面隐藏
  111. */
  112. onHide: function () {
  113. },
  114. /**
  115. * 生命周期函数--监听页面卸载
  116. */
  117. onUnload: function () {
  118. },
  119. /**
  120. * 页面相关事件处理函数--监听用户下拉动作
  121. */
  122. onPullDownRefresh: function () {
  123. },
  124. /**
  125. * 页面上拉触底事件的处理函数
  126. */
  127. onReachBottom: function () {
  128. },
  129. /**
  130. * 用户点击右上角分享
  131. */
  132. onShareAppMessage: function () {
  133. }
  134. })