const app=getApp(); var utils=require("../../../utils/http"); const util=require("../../../utils/util"); let nowfid='',copytextarr=[],copyimgarr=[]; Page({ /** * 页面的初始数据 */ data: { storeflag:false, wxfriendlist:[], imgUrl:app.globalData.imgUrl, friendpage:1, wxlabel:'', friendkeytext:'', companylabel:[], videoid:[], nowlabel:'', text:'养成良好的发圈习惯^.^', fromtype:'', filterId: '', tab: [{ name: '全部', type: '' },{ name: '分类', type: '3' }] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let that = this; if (options.id) { that.setData({ filterId: options.id }) } this.friendtitfun(); this.wxfriendfun(); }, dothis(){}, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, closetitleTap(){ this.setData({ storeflag:false }) }, setfromtap(e){ this.setData({ fromtype: e.currentTarget.dataset.type, storeflag:false, allfiltrate:false }) if(this.data.fromtype===''){ this.data.tab[1].name = '分类'; this.setData({ wxlabel:'', nowlabel:'', festival_id:'', tab: this.data.tab }) } else { this.setData({ allfiltrate:true }) } this.wxfriendfun(); }, opentitleTap(){ this.setData({ storeflag:true }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { // var that=this; // const query = wx.createSelectorQuery() // query.select('.pagetop').boundingClientRect() // query.selectViewport().scrollOffset() // query.exec(function(res){ // that.setData({ // dayght:res[0].height // }) // }) }, titleTap:function(e){ this.data.tab[1].name = e.currentTarget.dataset.text; this.setData({ wxlabel:e.currentTarget.dataset.tid, tab: this.data.tab, allfiltrate:false, fromtype: '3' }) this.wxfriendfun(); }, friendtitfun:function(){ var that=this; utils.$post({ url: app.globalData.webUrl + 'api/daily_wechat/label_list', header: { 'Authorization':'bearer '+app.globalData.token }, data:{}, success: function (res) { that.setData({ companylabel:res.data }) } }) }, wxfriendfun:function(e){ var that=this; this.setData({ friendpage:1 }) utils.$get({ url: app.globalData.webUrl + 'api/daily_wechat/list', header: { 'Authorization':'bearer '+app.globalData.token }, data:{ page:1, limit:10, festival_id:that.data.wxlabel, keyword:that.data.friendkeytext, from_type:that.data.fromtype=='3'?'':'', id: that.data.filterId }, success: function (res) { setTimeout(function(){ wx.hideLoading() },1000) if(res.data.code=='0'){ // var arr=[ 'png','PNG','jpg','JPG', 'jpeg','JPEG', 'bmp','BMP', 'gif',"GIF","WEBP", 'webp', 'psd',"PSD", 'svg', 'tiff']; for(let i=0;i62){ res.data.data[i].othercontent=res.data.data[i].content.substring(0,60)+'...'; res.data.data[i].textflag=0; }else{ res.data.data[i].othercontent=res.data.data[i].content; res.data.data[i].textflag=1; } } that.setData({ wxfriendlist:res.data.data, datashow:true }) } }, fail(){ wx.hideLoading() } }) }, previewImg:function(e){ var that=this; var idx = e.target.dataset.src,current; var imglist=[]; for(var i=0;i { // console.log(res) var videoContext = that.selectComponent('#video'+that.data.videoid[0]) let { intersectionRatio } = res if (intersectionRatio === 0) { //离开视界,因为视窗占比为0,停止播放 if(videoContext){ videoContext.pause() } } }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { var that=this; this.setData({ friendpage:1 }) if (!that.data.wxlabel) { console.log(that.data.wxlabel) that.setData({ fromtype: '' }) } utils.$get({ url: app.globalData.webUrl + 'api/daily_wechat/list', header: { 'Authorization':'bearer '+app.globalData.token }, data:{ page:1, limit:10, festival_id:that.data.wxlabel, keyword:that.data.friendkeytext, from_type: that.data.fromtype=='3'?'':'', }, success: function (res) { wx.stopPullDownRefresh() if(res.data.code=='0'){ // var arr=[ 'png','PNG','jpg','JPG', 'jpeg','JPEG', 'bmp','BMP', 'gif',"GIF","WEBP", 'webp', 'psd',"PSD", 'svg', 'tiff']; for(let i=0;i62){ res.data.data[i].othercontent=res.data.data[i].content.substring(0,60)+'...'; res.data.data[i].textflag=0; }else{ res.data.data[i].othercontent=res.data.data[i].content; res.data.data[i].textflag=1; } } that.setData({ wxfriendlist:res.data.data, datashow:true }) } }, fail(){ wx.hideLoading() } }) }, opentap(e){ const that=this; let wxfriendlist=that.data.wxfriendlist; wxfriendlist[e.currentTarget.dataset.idx].textflag=wxfriendlist[e.currentTarget.dataset.idx].textflag==1?0:1; this.setData({ wxfriendlist:wxfriendlist }) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { var that=this; let friendpage=that.data.friendpage; friendpage=friendpage*1+1; this.setData({ friendpage:friendpage }) utils.$get({ url: app.globalData.webUrl + 'api/daily_wechat/list', header: { 'Authorization':'bearer '+app.globalData.token }, data:{ page:friendpage, limit:10, festival_id:that.data.wxlabel, keyword:that.data.friendkeytext, from_type:that.data.fromtype=='3'?'':'', }, success: function (res) { if(res.data.code=='0'){ for(let i=0;i62){ res.data.data[i].othercontent=res.data.data[i].content.substring(0,60)+'...'; res.data.data[i].textflag=0; }else{ res.data.data[i].othercontent=res.data.data[i].content; res.data.data[i].textflag=1; } } let wxfriendlist=that.data.wxfriendlist; wxfriendlist=wxfriendlist.concat(res.data.data); that.setData({ wxfriendlist:wxfriendlist }) } }, fail(){ wx.hideLoading() } }) }, /** * 用户点击右上角分享 */ })