agentdetail.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. var app = getApp();
  2. var util = require("../../utils/util.js")
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. bottomLeft: app.bottomLeft,
  9. appAssetsUrl2: app.appAssetsUrl2,
  10. stateIndex: 0,
  11. nodata: util.nodata(),
  12. stateArray: ['全部','报名中','已结束'],
  13. id: null,
  14. obj: {},
  15. statusList: [],
  16. params: {
  17. page:1,
  18. limit:10
  19. },
  20. statusListIndex: 0,
  21. memberId: null,
  22. currPage: 1,
  23. totalPage: 0,
  24. dataList: [],
  25. load: false,
  26. activeInfo: {},
  27. isSchool: false,
  28. roleList: ['平台管理员','校园代理人','行家','行家;平台管理员','行家;校园代理人'],
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. console.log(options)
  35. this.setData({
  36. id: options.id,
  37. memberId: options.id
  38. })
  39. if(options.type == '校园代理人') {
  40. this.getDetail(options.id)
  41. wx.setNavigationBarTitle({
  42. title: options.type
  43. })
  44. this.setData({
  45. isSchool: true,
  46. })
  47. }else {
  48. this.activeUser(options.activityId || options.id)
  49. wx.setNavigationBarTitle({
  50. title: options.name
  51. })
  52. this.setData({
  53. isSchool: false,
  54. })
  55. }
  56. // wx.setNavigationBarTitile({ activityId
  57. // title: options.name
  58. // })
  59. wx.setNavigationBarTitle({
  60. title: options.name
  61. })
  62. },
  63. stateChange(e) {
  64. this.setData({
  65. stateIndex: e.detail.value,
  66. dataList: [],
  67. params: {
  68. page: 1,
  69. limit: 10
  70. }
  71. })
  72. this.getList()
  73. },
  74. activeDetail: function(e) {
  75. if (e.currentTarget.dataset.id) {
  76. wx.navigateTo({
  77. url: '/pages/home/index/activityDetail/activityDetail?id=' + e.currentTarget.dataset.id
  78. })
  79. }
  80. },
  81. // 校园代理人详情
  82. getDetail(id) {
  83. app._get(`campusagent/info/`+id, {
  84. }, res => {
  85. if (res.code === 0) {
  86. this.setData({
  87. obj: res.campusAgent,
  88. memberId: res.campusAgent.memberId
  89. })
  90. this.getState()
  91. }
  92. })
  93. },
  94. // 活动页进来的管理员信息
  95. activeUser(id) {
  96. app._get(`activity/activeCampusAgent`, {
  97. activityId: id
  98. }, res => {
  99. if (res.code === 0) {
  100. this.setData({
  101. activeInfo: res.data
  102. })
  103. this.getState()
  104. }
  105. })
  106. },
  107. getState() {
  108. // debugger
  109. app._post_form('home/activityStatus', '', null,
  110. (res) =>{
  111. if(res.code == 0){
  112. this.setData({
  113. statusList: [{itemname:'全部',itemcode:''},...res.data],
  114. })
  115. this.getList()
  116. }
  117. })
  118. },
  119. getList() {
  120. let that = this
  121. that.setData({
  122. load: false
  123. })
  124. this.setData({
  125. params: {
  126. ...that.data.params,
  127. status: that.data.statusList[that.data.stateIndex].itemcode,
  128. memberId: that.data.memberId
  129. },
  130. // noMore:isRefresh?false:this.data.noMore
  131. })
  132. app._post_form('act/list', '', {...this.data.params},
  133. function(res) {
  134. if(res.code == 0){
  135. that.setData({
  136. dataList: res.page.list,
  137. currPage: res.page.currPage,
  138. totalPage: res.page.totalPage,
  139. load: true
  140. })
  141. }
  142. })
  143. },
  144. /**
  145. * 生命周期函数--监听页面初次渲染完成
  146. */
  147. onReady: function() {
  148. },
  149. /**
  150. * 生命周期函数--监听页面显示
  151. */
  152. onShow: function() {
  153. },
  154. /**
  155. * 生命周期函数--监听页面隐藏
  156. */
  157. onHide: function() {},
  158. /**
  159. * 页面相关事件处理函数--监听用户下拉动作
  160. */
  161. onPullDownRefresh: function() {
  162. },
  163. /**
  164. * 页面上拉触底事件的处理函数
  165. */
  166. onReachBottom: function() {
  167. let that = this
  168. if(this.data.currPage >= this.data.totalPage) {
  169. wx.showToast({
  170. title: '没有更多了~',
  171. icon: 'none'
  172. })
  173. return false;
  174. }
  175. this.setData({
  176. currPage: that.data.currPage + 1
  177. })
  178. this.getList()
  179. },
  180. showShareMenu: function() {
  181. wx.showShareMenu();
  182. },
  183. hideShareMenu() {
  184. wx.hideShareMenu();
  185. }
  186. })