// pages/sence/sence.js var util = require('./../../utils/util.js'); var api = require('./../../config/api.js'); const app = getApp() Page({ /** * 页面的初始数据 */ data: { roomList: [], hasData: true, fetcherData: { type: null, address: '', page: 1, size: 20, name: '' } }, inputChange(e) { this.setData({ 'fetcherData.name': e.detail.value, }); }, search() { if (this.data.fetcherData.name != '') { wx.showLoading({ title: '加载中...', }); // console.log(this.data.searchKey) this.searchRoomList() } else { wx.showToast({ title: '请输入VR场景名称', icon: 'none' }) } }, getRoomList() { if (this.data.hasData) { util.request(api.BrandList, this.data.fetcherData).then((res) => { console.log(res) if (res.errno === 0) { if (res.data.data.length != 0) { this.setData({ roomList: this.data.roomList.concat(res.data.data), 'fetcherData.page': this.data.fetcherData.page + 1 }) } else { this.setData({ hasData: false }) } } }); } else { console.log('没有更多数据') } }, searchRoomList() { this.setData({ 'fetcherData.page': 1, 'fetcherData.size': 100, }) util.request(api.BrandList, this.data.fetcherData).then((res) => { wx.hideLoading() if (res.errno === 0) { this.setData({ roomList: res.data.data, }) } }); }, gotoWV: function (event) { let id = event.detail wx.navigateTo({ url: `/pages/webview/index?id=${id}`, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { getApp().checkNetStatu(); console.log(options) this.setData({ 'fetcherData.type': options.type }) if (options.type == 31) { wx.setNavigationBarTitle({ title: 'VR场景' }) } else { wx.setNavigationBarTitle({ title: 'VR场景直播间' }) } this.getRoomList() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.getRoomList() }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })