activity.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // index/pages/activity/activity.js
  2. const app=getApp();
  3. var utils=require("../../../utils/http");
  4. let activitypage=1;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. activitylist:[],
  11. imgUrl:app.globalData.imgUrl,
  12. type:'',
  13. datashow:false,
  14. wshareshow:false,
  15. nowid:'',
  16. nowtitle:'',
  17. nowimg:'',
  18. activityType: ''
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. if (!!options.type) {
  25. this.setData({
  26. activityType: options.type
  27. })
  28. }
  29. wx.showLoading({
  30. title: '加载中...',
  31. })
  32. this.activityfun();
  33. },
  34. setypetap:function(e){
  35. this.setData({
  36. type:e.currentTarget.dataset.type
  37. })
  38. this.activityfun();
  39. },
  40. /**
  41. * 生命周期函数--监听页面初次渲染完成
  42. */
  43. onReady: function () {
  44. },
  45. activityfun:function(){
  46. var that=this;
  47. activitypage=1;
  48. let apiUrl = '';
  49. if (that.data.activityType && that.data.activityType == 'broker') {
  50. apiUrl = 'api/agents_work/activity_list';
  51. } else {
  52. apiUrl = 'api/activity/list';
  53. }
  54. utils.$get({
  55. url: app.globalData.webUrl + apiUrl,
  56. header: {
  57. 'Authorization':'bearer '+app.globalData.token
  58. },
  59. data:{
  60. page:1,
  61. type:this.data.type?this.data.type:3
  62. },
  63. success: function (res) {
  64. // Timestate, 0未开始,1进行中,2已结束
  65. if(res.data.code=='0'){
  66. that.setData({
  67. activitylist:res.data.data,
  68. datashow:true
  69. })
  70. }
  71. setTimeout(function(){
  72. wx.hideLoading()
  73. },1000)
  74. }
  75. })
  76. },
  77. activitytap:function(e){
  78. let that = this;
  79. let item=this.data.activitylist[e.currentTarget.dataset.idx];
  80. if(item.cate==2){
  81. wx.navigateTo({
  82. url: '/index/pages/communitactiv/communitactiv?aid='+e.currentTarget.dataset.aid+'&name='+item.title
  83. })
  84. }else{
  85. if (that.data.activityType && that.data.activityType == 'broker') {
  86. wx.navigateTo({
  87. url: '/index/pages/activitymsg/activitymsg?aid='+e.currentTarget.dataset.aid+'&name='+item.title+'&type=broker'
  88. })
  89. } else {
  90. wx.navigateTo({
  91. url: '/index/pages/activitymsg/activitymsg?aid='+e.currentTarget.dataset.aid+'&name='+item.title
  92. })
  93. }
  94. }
  95. },
  96. /**
  97. * 生命周期函数--监听页面显示
  98. */
  99. onShow: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面隐藏
  103. */
  104. onHide: function () {
  105. },
  106. /**
  107. * 生命周期函数--监听页面卸载
  108. */
  109. onUnload: function () {
  110. },
  111. /**
  112. * 页面相关事件处理函数--监听用户下拉动作
  113. */
  114. onPullDownRefresh: function () {
  115. this.activityfun();
  116. wx.stopPullDownRefresh()
  117. },
  118. /**
  119. * 页面上拉触底事件的处理函数
  120. */
  121. onReachBottom: function () {
  122. var that=this;
  123. activitypage=activitypage*1+1;
  124. let apiUrl = '';
  125. if (that.data.activityType && that.data.activityType == 'broker') {
  126. apiUrl = 'api/agents_work/activity_list';
  127. } else {
  128. apiUrl = 'api/activity/list';
  129. }
  130. utils.$get({
  131. url: app.globalData.webUrl + apiUrl,
  132. header: {
  133. 'Authorization':'bearer '+app.globalData.token
  134. },
  135. data:{
  136. page:activitypage,
  137. type:this.data.type?this.data.type:3
  138. },
  139. success: function (res) {
  140. let activitylist=that.data.activitylist;
  141. if(res.data.code=='0'){
  142. activitylist=activitylist.concat(res.data.data)
  143. that.setData({
  144. activitylist:activitylist,
  145. })
  146. }
  147. }
  148. })
  149. },
  150. /**
  151. * 用户点击右上角分享
  152. */
  153. })