index.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 { teamid, id } = e.currentTarget.dataset;
  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.request({
  87. url: `${app.globalData.publicUrl}/courtAdmin/api/team/` + teamid, //接口地址
  88. method: 'DELETE',
  89. data: {},
  90. success(res) {
  91. if (res.data.errcode == 0) {
  92. wx.showToast({ title: `解散团队成功`, icon: 'success', duration: 2000 }) //创建成功提示
  93. return wx.redirectTo({ url: '/pages/manage/index' })// 跳转页面
  94. } else {
  95. wx.showToast({
  96. title: res.data.errmsg,
  97. icon: 'none',
  98. duration: 2000
  99. })
  100. }
  101. }
  102. })
  103. } else {
  104. wx.showToast({
  105. title: res.data.errmsg,
  106. icon: 'none',
  107. duration: 2000
  108. })
  109. }
  110. }
  111. })
  112. } else if (res.cancel) {
  113. }
  114. }
  115. })
  116. },
  117. /**
  118. * 生命周期函数--监听页面加载
  119. */
  120. onLoad: function (options) {
  121. // 计算高度
  122. this.searchHeight();
  123. // 监听用户是否登录
  124. this.watchLogin();
  125. },
  126. // 监听用户是否登录
  127. watchLogin: function () {
  128. var that = this;
  129. wx.getStorage({
  130. key: 'token',
  131. success: res => {
  132. wx.request({
  133. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  134. method: 'get',
  135. data: {},
  136. success(res) {
  137. if (res.data.errcode == 0) {
  138. that.setData({
  139. compete: res.data.data,
  140. });
  141. } else {
  142. wx.showToast({
  143. title: res.data.errmsg,
  144. icon: 'none',
  145. duration: 2000
  146. })
  147. }
  148. }
  149. })
  150. //查询数据
  151. wx.request({
  152. url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
  153. method: 'get',
  154. data: {},
  155. success(res) {
  156. if (res.data.errcode == 0) {
  157. that.setData({
  158. teamlist: res.data.data,
  159. });
  160. } else {
  161. wx.showToast({
  162. title: res.data.errmsg,
  163. icon: 'none',
  164. duration: 2000
  165. })
  166. }
  167. }
  168. })
  169. //解散团队数据
  170. wx.request({
  171. url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply`, //接口地址
  172. method: 'get',
  173. data: {},
  174. success(res) {
  175. if (res.data.errcode == 0) {
  176. that.setData({
  177. dissolution: res.data.data,
  178. });
  179. } else {
  180. wx.showToast({
  181. title: res.data.errmsg,
  182. icon: 'none',
  183. duration: 2000
  184. })
  185. }
  186. }
  187. })
  188. },
  189. fail: res => {
  190. return wx.redirectTo({ url: '/pages/login/index', })
  191. }
  192. })
  193. },
  194. // 计算高度
  195. searchHeight: function () {
  196. let frameStyle = this.data.frameStyle;
  197. let client = app.globalData.client;
  198. let infoHeight = client.windowHeight;
  199. // 是否去掉状态栏
  200. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  201. // 是否减去底部菜单
  202. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  203. if (infoHeight) this.setData({ infoHeight: infoHeight })
  204. },
  205. /**
  206. * 生命周期函数--监听页面初次渲染完成
  207. */
  208. onReady: function () {
  209. },
  210. /**
  211. * 生命周期函数--监听页面显示
  212. */
  213. onShow: function () {
  214. },
  215. /**
  216. * 生命周期函数--监听页面隐藏
  217. */
  218. onHide: function () {
  219. },
  220. /**
  221. * 生命周期函数--监听页面卸载
  222. */
  223. onUnload: function () {
  224. },
  225. /**
  226. * 页面相关事件处理函数--监听用户下拉动作
  227. */
  228. onPullDownRefresh: function () {
  229. },
  230. /**
  231. * 页面上拉触底事件的处理函数
  232. */
  233. onReachBottom: function () {
  234. },
  235. /**
  236. * 用户点击右上角分享
  237. */
  238. onShareAppMessage: function () {
  239. }
  240. })