1
0

activity.js 3.8 KB

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