// pages/liveDetail/index.js import * as echarts from '../../components/ec-canvas/echarts'; var app = getApp(); Page({ /** * 页面的初始数据 */ data: { ec: { lazyLoad: true // 延迟加载 }, hotCommentList: [], newCommentList: [], noneHot:false, noneNew: false, checkType: 1, photo_id: '', user_id: '', infoObj: {}, tab: 1, rewardList: [], productList: [], giftObj: {}, targetTop: '', isFix: false, pages: 1, page: 1, pages1: 0, page1: 1, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options) var that = this; wx.showLoading({ title: '加载中', }) that.setData({ 'photo_id':options.photoid, 'user_id': options.userid }) wx.getSystemInfo({ success(res) { that.setData({ scrollHeight: res.windowHeight - 10 }); } }); that.getInfo(); that.getNew(); var query = wx.createSelectorQuery(); //选择id query.select('#tabItem').boundingClientRect() query.exec((res) => { //res就是 所有标签为mjltest的元素的信息 的数组 that.setData({ targetTop: res[0].top }) }) wx.setNavigationBarTitle({ title: options.from?'广告详情':'视频详情' }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, // 热门评论 getNew:function() { wx.showLoading({ title: '加载中', }) var that = this; app.func.req('/api/kwaiUser/commentList','post',{ 'type': 0, 'photo_id':that.data.photo_id, 'user_id':that.data.user_id, 'page': that.data.page }, function(res) { wx.hideLoading({ title: '加载中', }) if(res && res.errno == 0){ //成功 var data = res.rst; that.setData({ newCommentList: that.data.newCommentList.concat(data.list), pages: data.pages }) if(that.data.newCommentList.length==0) { that.setData({ noneNew: true }) } } },function(err){ that.setData({ noneNew: true }) console.log(err) }) }, // 热门评论 getHot:function() { var that = this; app.func.req('/api/kwaiUser/commentList','post',{ 'type': 1, 'photo_id':that.data.photo_id, 'user_id':that.data.user_id, 'page': that.data.page1 }, function(res) { wx.hideLoading({ title: '加载中', }) if(res && res.errno == 0){ //成功 var data = res.rst; that.setData({ hotCommentList: that.data.hotCommentList.concat(data.list), pages1: data.pages }) if(that.data.hotCommentList.length==0) { that.setData({ noneHot: true }) } } },function(err){ console.log(err) that.setData({ noneHot: true }) }) }, // 直播详情 getInfo:function() { var that = this; app.func.req('/api/kwaiUser/ShowVideos','get',{ 'photo_id':that.data.photo_id, 'user_id': that.data.user_id }, function(res) { if(res && res.errno == 0){ //成功 var data = res.rst; that.setData({ infoObj: data }) } },function(err){ console.log(err) }) }, // 滚动 scroll(e) { let page = this, scrollTop = e.detail.scrollTop; if(scrollTop>=this.data.targetTop) { this.setData({ isFix: true }) }else { this.setData({ isFix: false }) } }, bindDownLoad() { if(this.data.tab==1) { if(this.data.page