sence.js 2.8 KB

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