index.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. import WxValidate from '../../utils/wxValidate'
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. // 主体高度
  9. infoHeight: '',
  10. frameStyle: { useTop: true, name: '审核队员', leftArrow: true, useBar: false },
  11. //加入团队列表
  12. list: [],
  13. // 团队id
  14. id: '',
  15. // 团队队员
  16. members: [],
  17. //审核通过的团队队员
  18. member:[],
  19. //详情
  20. details: {},
  21. show: false,
  22. },
  23. back: function () {
  24. wx.navigateBack({ url: '/pages/me/index' })
  25. },
  26. // 详细信息
  27. toView: function (e) {
  28. const that = this;
  29. let { userid } = e.currentTarget.dataset;
  30. that.setData({ show: true })
  31. //用户详情
  32. wx.request({
  33. url: `${app.globalData.publicUrl}/courtAdmin/api/user/${userid}`, //接口地址
  34. method: "get",
  35. data: {},
  36. header: {},
  37. success: res => {
  38. that.setData({ details: res.data.data })
  39. },
  40. error: err => {
  41. }
  42. })
  43. },
  44. // 审核
  45. toCheck: function (e) {
  46. const that = this;
  47. let { id, userid, status } = e.currentTarget.dataset;
  48. let id_1 = that.data.id
  49. wx.showModal({
  50. content: `您确定提交${status == '1' ? '通过' : '驳回'}操作吗?`,
  51. title: '提示',
  52. success: (result) => {
  53. if (status == '1') {
  54. //修改状态-加入团队修改
  55. wx.request({
  56. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply/${id}`,
  57. method: "post",
  58. data: { status: status },
  59. header: {},
  60. success: res => {
  61. if (res.data.errcode === 0) {
  62. wx.showToast({ title: '审核成功', icon: 'success', duration: 2000 });
  63. that.watchLogin();
  64. } else {
  65. wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
  66. }
  67. },
  68. error: err => {
  69. }
  70. })
  71. //用户详情
  72. wx.request({
  73. url: `${app.globalData.publicUrl}/courtAdmin/api/user/${userid}`, //接口地址
  74. method: "get",
  75. data: {},
  76. header: {},
  77. success: res => {
  78. let member = [];
  79. member.push({ id: res.data.data.id, nickname: res.data.data.nickname, icon: res.data.data.icon })
  80. that.setData({ member: member })
  81. let members = that.data.members;
  82. members = [...members, ...member];
  83. wx.request({
  84. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id_1}`,
  85. method: "post",
  86. data: { members: members },
  87. header: {},
  88. success: res => {
  89. },
  90. error: err => {
  91. }
  92. })
  93. },
  94. error: err => {
  95. }
  96. })
  97. } else {
  98. wx.request({
  99. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply/${id}`,
  100. method: "post",
  101. data: { status: status },
  102. header: {},
  103. success: res => {
  104. if (res.data.errcode === 0) {
  105. wx.showToast({ title: '审核成功', icon: 'success', duration: 2000 });
  106. that.watchLogin();
  107. } else {
  108. wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
  109. }
  110. },
  111. error: err => {
  112. }
  113. })
  114. }
  115. },
  116. })
  117. },
  118. /**
  119. * 生命周期函数--监听页面加载
  120. */
  121. onLoad: function (options) {
  122. let id = options.id;
  123. this.setData({ id: id })
  124. // 计算高度
  125. this.searchHeight();
  126. // 监听用户是否登录
  127. this.watchLogin(id);
  128. },
  129. // 监听用户是否登录
  130. watchLogin: function () {
  131. const that = this;
  132. wx.getStorage({
  133. key: 'token',
  134. success: res => {
  135. wx.request({
  136. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply`,
  137. method: "get",
  138. data: { team_id: that.data.id },
  139. header: {},
  140. success: res => {
  141. that.setData({ list: res.data.data })
  142. },
  143. error: err => {
  144. }
  145. })
  146. wx.request({
  147. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${that.data.id}`,
  148. method: "get",
  149. data: {},
  150. header: {},
  151. success: res => {
  152. that.setData({ members: res.data.data.members })
  153. },
  154. error: err => {
  155. }
  156. })
  157. },
  158. fail: res => {
  159. wx.redirectTo({ url: '/pages/login/index', })
  160. }
  161. })
  162. },
  163. // 计算高度
  164. searchHeight: function () {
  165. let frameStyle = this.data.frameStyle;
  166. let client = app.globalData.client;
  167. let infoHeight = client.windowHeight;
  168. // 是否去掉状态栏
  169. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  170. // 是否减去底部菜单
  171. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  172. if (infoHeight) this.setData({ infoHeight: infoHeight })
  173. },
  174. /**
  175. * 生命周期函数--监听页面初次渲染完成
  176. */
  177. onReady: function () {
  178. },
  179. /**
  180. * 生命周期函数--监听页面显示
  181. */
  182. onShow: function () {
  183. },
  184. /**
  185. * 生命周期函数--监听页面隐藏
  186. */
  187. onHide: function () {
  188. },
  189. /**
  190. * 生命周期函数--监听页面卸载
  191. */
  192. onUnload: function () {
  193. },
  194. /**
  195. * 页面相关事件处理函数--监听用户下拉动作
  196. */
  197. onPullDownRefresh: function () {
  198. },
  199. /**
  200. * 页面上拉触底事件的处理函数
  201. */
  202. onReachBottom: function () {
  203. },
  204. /**
  205. * 用户点击右上角分享
  206. */
  207. onShareAppMessage: function () {
  208. }
  209. })