searchRoom.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. // console.log(this.data.searchKey)
  36. this.setData({
  37. isSearch: true
  38. })
  39. this.getRoomList()
  40. } else {
  41. wx.showToast({
  42. title: '请输入VR场景名称',
  43. icon: 'none'
  44. })
  45. }
  46. },
  47. getRoomList() {
  48. if (this.data.fetcherData.type == '21') { //商家
  49. this.setData({
  50. 'fetcherData.address': '',
  51. })
  52. } else {
  53. if (app.globalData.city == '全国') {
  54. this.setData({
  55. 'fetcherData.address': '',
  56. })
  57. } else {
  58. this.setData({
  59. 'fetcherData.address': app.globalData.city,
  60. })
  61. }
  62. }
  63. util.request(api.BrandList, this.data.fetcherData).then((res) => {
  64. console.log(res)
  65. if (res.errno === 0) {
  66. if (this.data.fetcherData.type == '21') {
  67. this.setData({
  68. storeList: res.data.data,
  69. })
  70. } else {
  71. this.setData({
  72. roomList: res.data.data,
  73. })
  74. }
  75. }
  76. });
  77. },
  78. /**
  79. * 生命周期函数--监听页面加载
  80. */
  81. onLoad: function (options) {
  82. getApp().checkNetStatu();
  83. this.setData({
  84. 'fetcherData.type': options.type || 21
  85. })
  86. },
  87. /**
  88. * 生命周期函数--监听页面初次渲染完成
  89. */
  90. onReady: function () {
  91. },
  92. /**
  93. * 生命周期函数--监听页面显示
  94. */
  95. onShow: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面隐藏
  99. */
  100. onHide: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面卸载
  104. */
  105. onUnload: function () {
  106. },
  107. /**
  108. * 页面相关事件处理函数--监听用户下拉动作
  109. */
  110. onPullDownRefresh: function () {
  111. },
  112. /**
  113. * 页面上拉触底事件的处理函数
  114. */
  115. onReachBottom: function () {},
  116. /**
  117. * 用户点击右上角分享
  118. */
  119. onShareAppMessage: function () {
  120. }
  121. })