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