hotel.js 2.2 KB

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