index.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 (result.confirm) {
  54. if (status == '1') {
  55. //修改状态-加入团队修改
  56. wx.request({
  57. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply/${id}`,
  58. method: "post",
  59. data: { status: status },
  60. header: {},
  61. success: res => {
  62. if (res.data.errcode === 0) {
  63. wx.showToast({ title: '审核成功', icon: 'success', duration: 2000 });
  64. that.watchLogin();
  65. } else {
  66. wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
  67. }
  68. },
  69. error: err => {
  70. }
  71. })
  72. //用户详情
  73. wx.request({
  74. url: `${app.globalData.publicUrl}/courtAdmin/api/user/${userid}`, //接口地址
  75. method: "get",
  76. data: {},
  77. header: {},
  78. success: res => {
  79. let member = [];
  80. member.push({ id: res.data.data.id, nickname: res.data.data.nickname, icon: res.data.data.icon })
  81. that.setData({ member: member })
  82. let members = that.data.members;
  83. members = [...members, ...member];
  84. wx.request({
  85. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id_1}`,
  86. method: "post",
  87. data: { members: members },
  88. header: {},
  89. success: res => {
  90. },
  91. error: err => {
  92. }
  93. })
  94. },
  95. error: err => {
  96. }
  97. })
  98. } else {
  99. wx.request({
  100. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply/${id}`,
  101. method: "post",
  102. data: { status: status },
  103. header: {},
  104. success: res => {
  105. if (res.data.errcode === 0) {
  106. wx.showToast({ title: '审核成功', icon: 'success', duration: 2000 });
  107. that.watchLogin();
  108. } else {
  109. wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
  110. }
  111. },
  112. error: err => {
  113. }
  114. })
  115. }
  116. } else if (result.cancel) { }
  117. }
  118. })
  119. },
  120. /**
  121. * 生命周期函数--监听页面加载
  122. */
  123. onLoad: function (options) {
  124. let id = options.id;
  125. this.setData({ id: id })
  126. // 计算高度
  127. this.searchHeight();
  128. // 监听用户是否登录
  129. this.watchLogin(id);
  130. },
  131. // 监听用户是否登录
  132. watchLogin: function () {
  133. const that = this;
  134. wx.getStorage({
  135. key: 'token',
  136. success: res => {
  137. wx.request({
  138. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply`,
  139. method: "get",
  140. data: { team_id: that.data.id },
  141. header: {},
  142. success: res => {
  143. that.setData({ list: res.data.data })
  144. },
  145. error: err => {
  146. }
  147. })
  148. wx.request({
  149. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${that.data.id}`,
  150. method: "get",
  151. data: {},
  152. header: {},
  153. success: res => {
  154. that.setData({ members: res.data.data.members })
  155. },
  156. error: err => {
  157. }
  158. })
  159. },
  160. fail: res => {
  161. wx.redirectTo({ url: '/pages/login/index', })
  162. }
  163. })
  164. },
  165. // 计算高度
  166. searchHeight: function () {
  167. let frameStyle = this.data.frameStyle;
  168. let client = app.globalData.client;
  169. let infoHeight = client.windowHeight;
  170. // 是否去掉状态栏
  171. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  172. // 是否减去底部菜单
  173. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  174. if (infoHeight) this.setData({ infoHeight: infoHeight })
  175. },
  176. /**
  177. * 生命周期函数--监听页面初次渲染完成
  178. */
  179. onReady: function () {
  180. },
  181. /**
  182. * 生命周期函数--监听页面显示
  183. */
  184. onShow: function () {
  185. },
  186. /**
  187. * 生命周期函数--监听页面隐藏
  188. */
  189. onHide: function () {
  190. },
  191. /**
  192. * 生命周期函数--监听页面卸载
  193. */
  194. onUnload: function () {
  195. },
  196. /**
  197. * 页面相关事件处理函数--监听用户下拉动作
  198. */
  199. onPullDownRefresh: function () {
  200. },
  201. /**
  202. * 页面上拉触底事件的处理函数
  203. */
  204. onReachBottom: function () {
  205. },
  206. /**
  207. * 用户点击右上角分享
  208. */
  209. onShareAppMessage: function () {
  210. }
  211. })