const util = require('../../../utils/util.js'); const app = getApp(); Page({ data: { nav:[], videoList:[], bottom:false, page:1, vtype:'-1', src:'', wid:375, mask:true, autoplay:false, }, onLoad: function (options) { wx.showNavigationBarLoading(); let that = this; wx.getSystemInfo({ success: function(res) { that.setData({wid:res.windowWidth}) } }) util.ajax({ func:"video/index", data:{} },function(res){ if(res.code == 0){ let nav = res.data; let first = {vtype:'-1',name:'全部'} nav.unshift(first) that.setData({nav}) that.getList('',1); }else{ wx.hideNavigationBarLoading() util.showTips(res.reason) setTimeout(function(){ wx.navigateBack({}) },2500) } }) }, onReachBottom:function(){ if(!this.data.bottom){ wx.showNavigationBarLoading(); var vtype = ''; this.data.vtype == '-1' ? vtype = '' : vtype = this.data.vtype this.getList(vtype,this.data.page+1) } }, getList:function(vtype,page){ let that = this; util.ajax({ func:"video/list", data:{"vtype":vtype,"pageIndex":page,"pageSize":20}, load:false },function(res){ if(res.code == 0){ let datas = res.data.list,videoList = that.data.videoList,bottom = false; if(page == 1){ videoList = datas }else{ videoList = [...videoList,...datas] } if(datas.length < 20 && videoList.length >= 20){ bottom = true } that.setData({videoList,page,bottom}) wx.hideNavigationBarLoading() }else{ util.showTips(res.reason) } }) }, chooseNav:function(e){ wx.showNavigationBarLoading(); this.setData({vtype:e.currentTarget.dataset.vtype}) var vtype = ''; e.currentTarget.dataset.vtype == '-1' ? vtype = '' : vtype = e.currentTarget.dataset.vtype; this.getList(vtype,1); }, onShareAppMessage: function () { return { title: '精彩活动视频', path: '/pages/public/video/video', imageUrl:'https://img.bbztx.com/images/upload/202211/a3feaddd6ee339fc939e35eac0e63e9.jpg' } } })