123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- // index/pages/activity/activity.js
- const app=getApp();
- var utils=require("../../../utils/http");
- let activitypage=1;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- activitylist:[],
- imgUrl:app.globalData.imgUrl,
- type:'',
- datashow:false,
- wshareshow:false,
- nowid:'',
- nowtitle:'',
- nowimg:'',
- activityType: '',
- keyword: ""
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if (!!options.type) {
- this.setData({
- activityType: options.type
- })
- }
- wx.showLoading({
- title: '加载中...',
- })
- this.activityfun();
- },
- setypetap:function(e){
- this.setData({
- type:e.currentTarget.dataset.type
- })
- this.activityfun();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- searchInputFunc(e) {
- this.setData({
- keyword: e.detail.value
- })
- },
- searchFunc() {
- this.activityfun();
- },
- activityfun:function(){
- var that=this;
- activitypage=1;
- let apiUrl = '';
- if (that.data.activityType && that.data.activityType == 'broker') {
- apiUrl = 'api/agents_work/activity_list';
- } else {
- apiUrl = 'api/activity/list';
- }
- utils.$get({
- url: app.globalData.webUrl + apiUrl,
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- page: 1,
- type: this.data.type?this.data.type:3,
- name: this.data.keyword
- },
- 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;
- let item=this.data.activitylist[e.currentTarget.dataset.idx];
- if(item.cate==2){
- wx.navigateTo({
- url: '/index/pages/communitactiv/communitactiv?aid='+e.currentTarget.dataset.aid+'&name='+item.title
- })
- }else{
- if (that.data.activityType && that.data.activityType == 'broker') {
- wx.navigateTo({
- url: '/index/pages/activitymsg/activitymsg?aid='+e.currentTarget.dataset.aid+'&name='+item.title+'&type=broker'
- })
- } else {
- wx.navigateTo({
- url: '/index/pages/activitymsg/activitymsg?aid='+e.currentTarget.dataset.aid+'&name='+item.title
- })
- }
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.activityfun();
- wx.stopPullDownRefresh()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- var that=this;
- activitypage=activitypage*1+1;
- let apiUrl = '';
- if (that.data.activityType && that.data.activityType == 'broker') {
- apiUrl = 'api/agents_work/activity_list';
- } else {
- apiUrl = 'api/activity/list';
- }
- utils.$get({
- url: app.globalData.webUrl + apiUrl,
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- page: activitypage,
- type:this.data.type?this.data.type:3
- },
- success: function (res) {
- let activitylist=that.data.activitylist;
- if(res.data.code=='0'){
- activitylist=activitylist.concat(res.data.data)
- that.setData({
- activitylist:activitylist,
- })
- }
- }
- })
- },
- /**
- * 用户点击右上角分享
- */
- })
|