const app = getApp(); var utils = require("../../../utils/http"); let activitypage = 1; Page({ /** * 页面的初始数据 */ data: { activitylist: [], imgUrl: app.globalData.imgUrl, type: '', datashow: false, wshareshow: false, activityType: '', nowidx:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.hideShareMenu({ menus: ['shareAppMessage', 'shareTimeline'] }) wx.showLoading({ title: '加载中...', }) this.activityfun(); }, setypetap: function (e) { this.setData({ type: e.currentTarget.dataset.type }) this.activityfun(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, activityfun: function () { var that = this; activitypage = 1; utils.$get({ url: app.globalData.webUrl + 'api/activity/list', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { page: 1, type: '', in:7 }, success: function (res) { // Timestate, 0未开始,1进行中,2已结束 if (res.data.code == '0') { that.setData({ activitylist: res.data.data, datashow: true }) } setTimeout(function () { wx.hideLoading() }, 1000) } }) }, activitytap: function (e) { let that = this; wx.navigateTo({ url: '/customer/pages/activitymsg/activitymsg?aid=' + e.currentTarget.dataset.aid }) }, sharetpa(e){ this.setData({ wshareshow:true, nowidx:e.currentTarget.dataset.idx }) }, shareurltap: function () { wx.showLoading({ title: '加载中...', }) this.shareactivitytap(); util.schemefun('/share/pages/activitymsg/activitymsg', 'aid=' + this.data.activitylist[this.data.nowidx].id + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, this.data.activitylist[this.data.nowidx].id, 'activity', ''); }, setpostertap: function () { wx.navigateTo({ url: '/index/pages/setposter/setposter?type=activity&aid=' + this.data.activitylist[this.data.nowidx].id + "&listshare=", }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.activityfun(); wx.stopPullDownRefresh() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { var that = this; activitypage = activitypage * 1 + 1; utils.$get({ url: app.globalData.webUrl + 'api/activity/list', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { page: activitypage, type: '', in:7 }, success: function (res) { let activitylist = that.data.activitylist; if (res.data.code == '0') { activitylist = activitylist.concat(res.data.data) that.setData({ activitylist: activitylist, }) } } }) }, dothis(){}, shareactivitytap: function (aid) { let that = this; utils.$post({ url: app.globalData.webUrl + 'api/share/addlog', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: aid, type: 'activity', }, success: function (r) {} }) }, addsharetap: function (type) { let that = this; utils.$post({ url: app.globalData.webUrl + 'api/share/addlog', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: '0', type: type, }, success: function (r) {} }) }, /** * 用户点击右上角分享 */ onShareAppMessage: function (e) { let idx=e.target.dataset.idx; var img = this.data.activitylist[idx].poster; // this.shareactivitytap(this.data.activitylist[idx].id); this.addsharetap('toolAll'); return { title: this.data.activitylist[idx].title, imageUrl: img, path: '/share/pages/activitymsg/activitymsg?aid=' + this.data.activitylist[idx].id + '&uid=' + app.globalData.personMsg.id + "&ctp=" + app.globalData.clientype } } })