index.js 5.9 KB

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