123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- // 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<this.data.pages) {
- this.setData({
- page: ++this.data.page
- })
- this.getNew();
- }
- }else {
- if(this.data.page1<this.data.pages1) {
- this.setData({
- page1: ++this.data.page1
- })
- this.getHot();
- }
- }
- },
- check(e) {
- this.setData({
- tab: e.target.dataset.id
- })
- if(this.data.tab==2&&this.data.pages1==0) {
- this.getHot();
- }
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|