searchRoom.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // pages/searchRoom/searchRoom.js
  2. const util = require('../../utils/util.js');
  3. const api = require('../../config/api.js');
  4. const app = getApp()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. searchKey: '',
  11. roomList: [],
  12. storeList: [],
  13. isSearch: false,
  14. fetcherData: {
  15. type: null,
  16. address: app.globalData.city,
  17. page: 1,
  18. size: 100,
  19. name: ''
  20. }
  21. },
  22. gotoWV: function (event) {
  23. let id = event.detail
  24. wx.navigateTo({
  25. url: `/pages/webview/index?id=${id}`,
  26. })
  27. },
  28. inputChange(e) {
  29. this.setData({
  30. 'fetcherData.name': e.detail.value,
  31. });
  32. },
  33. search() {
  34. if (this.data.fetcherData.name != '') {
  35. wx.showLoading({
  36. title: '加载中...',
  37. });
  38. // console.log(this.data.searchKey)
  39. this.setData({
  40. isSearch: true
  41. })
  42. this.getRoomList()
  43. } else {
  44. wx.showToast({
  45. title: '请输入VR场景名称',
  46. icon: 'none'
  47. })
  48. }
  49. },
  50. getRoomList() {
  51. if (this.data.fetcherData.type == '21') { //商家
  52. this.setData({
  53. 'fetcherData.address': '',
  54. })
  55. } else {
  56. if (app.globalData.city == '全国') {
  57. this.setData({
  58. 'fetcherData.address': '',
  59. })
  60. } else {
  61. this.setData({
  62. 'fetcherData.address': app.globalData.city,
  63. })
  64. }
  65. }
  66. util.request(api.BrandList, this.data.fetcherData).then((res) => {
  67. wx.hideLoading()
  68. if (res.errno === 0) {
  69. if (this.data.fetcherData.type == '21') {
  70. this.setData({
  71. storeList: res.data.data,
  72. })
  73. } else {
  74. this.setData({
  75. roomList: res.data.data,
  76. })
  77. }
  78. }
  79. });
  80. },
  81. /**
  82. * 生命周期函数--监听页面加载
  83. */
  84. onLoad: function (options) {
  85. getApp().checkNetStatu();
  86. this.setData({
  87. 'fetcherData.type': options.type || 21
  88. })
  89. },
  90. /**
  91. * 生命周期函数--监听页面初次渲染完成
  92. */
  93. onReady: function () {
  94. },
  95. /**
  96. * 生命周期函数--监听页面显示
  97. */
  98. onShow: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面卸载
  107. */
  108. onUnload: function () {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh: function () {
  114. },
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom: function () {},
  119. /**
  120. * 用户点击右上角分享
  121. */
  122. onShareAppMessage: function () {
  123. }
  124. })