agentdetail.js 3.6 KB

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