searchRoom.js 2.8 KB

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