index.js 6.9 KB

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