hotel.js 2.0 KB

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