// packageH/Advertising/advertisingList/advertisingList.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { list: [], tag: "all", //从什么页面进入的,聚合页||直播间||发现视频 //more current_page: 1, //分页数,当前页数 isLoadMore: true, //判断是否要加载更多的标志 last_page: 0 //总页数 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getData(); }, getData() { let json = {}; if (this.options.tag && this.options.tag != "all") { json.put_in_type = this.options.tag == "video" ? "2" : "1"; //投放类型:1-直播间,2-短视频 json.put_in_id = this.options.id; //投放短视频/直播间ID } let urlStr = app.getNetAddresss('plugin.ad-serving.frontend.advertising.index.getList'); app._postNetWork({ url: urlStr, data: json, success: (resdata) => { let res = resdata.data; if (res.result == 1) { this.setData({ list: res.data.list.data, current_page: res.data.list.current_page, last_page: res.data.list.last_page }); } else { wx.showToast({ title: res.msg, icon: 'none', duration: 1500 }); } }, fail: function (res) { console.log(res.msg); } }); }, getMore() { let json = {}; if (this.options.tag && this.options.tag != "all") { json.put_in_type = this.options.tag == "video" ? "2" : "1"; //投放类型:1-直播间,2-短视频 json.put_in_id = this.options.id; //投放短视频/直播间ID } json.page = this.data.page; let urlStr = app.getNetAddresss("plugin.ad-serving.frontend.advertising.index.getList"); app._getNetWork({ url: urlStr, data: json, success: (resdata) => { var res = resdata.data; if (res.result == 1) { this.setData({ list: that.data.info.concat(res.data.list.data), current_page: res.data.current_page, last_page: res.data.last_page }); } else { wx.showToast({ icon: "none", title: res.msg, duration: 1500, }); } }, fail: function (res) { console.log(res); }, }); }, gotoADPlay(e) { let detail = e.currentTarget.dataset; let page = Math.ceil((detail.index+1)/15); wx.navigateTo({ url: '/packageH/Advertising/advertisingPlayPage/advertisingPlayPage?aid='+detail.id+"&tag="+this.options.tag+"&id="+this.options.id+"&page="+page }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.current_page >= this.data.last_page) { return; } else { let pages = this.data.page + 1; this.setData({ page: pages }); this.getMore(); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } });