index.js 6.6 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. teamlist: [],
  14. compete: [],
  15. dissolution: [],
  16. },
  17. back: function () {
  18. wx.navigateBack({ url: '/pages/home/index' })
  19. },
  20. //查询解散团队
  21. shen: function (e) {
  22. let obj = e.currentTarget.dataset;
  23. wx.navigateTo({
  24. url: '/pages/administration/detail?obj=' + decodeURIComponent(JSON.stringify(obj)),
  25. })
  26. },
  27. //查询参赛团队详情
  28. canshen: function (e) {
  29. let obj = e.currentTarget.dataset;
  30. wx.navigateTo({
  31. url: '/pages/administration/compete?obj=' + decodeURIComponent(JSON.stringify(obj)),
  32. })
  33. },
  34. //查询团队详情
  35. shens: function (e) {
  36. let id = e.currentTarget.dataset.name;
  37. wx.navigateTo({
  38. url: '/pages/administration/details?id=' + id,
  39. })
  40. },
  41. //参赛团队点击通过
  42. cantong: function (e) {
  43. let id = e.currentTarget.dataset.name;
  44. wx.showModal({
  45. title: '',
  46. content: '是否通过参赛团队',
  47. success(res) {
  48. if (res.confirm) {
  49. wx.request({
  50. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam/` + id, //接口地址
  51. method: 'post',
  52. data: {
  53. "status": "1"
  54. },
  55. success(res) {
  56. if (res.data.errcode == 0) {
  57. wx.showToast({ title: `通过团队成功`, icon: 'success', duration: 2000 }) //创建成功提示
  58. return wx.redirectTo({ url: '/pages/manage/index' })// 跳转页面
  59. } else {
  60. wx.showToast({
  61. title: res.data.errmsg,
  62. icon: 'none',
  63. duration: 2000
  64. })
  65. }
  66. }
  67. })
  68. } else if (res.cancel) {
  69. }
  70. }
  71. })
  72. },
  73. //解散点击通过
  74. out: function (e) {
  75. let id = e.currentTarget.dataset.name;
  76. wx.showModal({
  77. title: '',
  78. content: '是否确认解散团队',
  79. success(res) {
  80. if (res.confirm) {
  81. wx.request({
  82. url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply/` + id, //接口地址
  83. method: 'DELETE',
  84. data: '',
  85. success(res) {
  86. if (res.data.errcode == 0) {
  87. wx.showToast({ title: `解散团队成功`, icon: 'success', duration: 2000 }) //创建成功提示
  88. return wx.redirectTo({ url: '/pages/manage/index' })// 跳转页面
  89. } else {
  90. wx.showToast({
  91. title: res.data.errmsg,
  92. icon: 'none',
  93. duration: 2000
  94. })
  95. }
  96. }
  97. })
  98. } else if (res.cancel) {
  99. }
  100. }
  101. })
  102. },
  103. /**
  104. * 生命周期函数--监听页面加载
  105. */
  106. onLoad: function (options) {
  107. // 监听用户是否登录
  108. this.watchLogin();
  109. // 计算高度
  110. this.searchHeight();
  111. },
  112. // 监听用户是否登录
  113. watchLogin: function () {
  114. var that = this;
  115. wx.getStorage({
  116. key: 'token',
  117. success: res => {
  118. wx.request({
  119. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  120. method: 'get',
  121. data: {},
  122. success(res) {
  123. if (res.data.errcode == 0) {
  124. let datasai = res.data.data
  125. that.setData({
  126. compete: datasai,
  127. });
  128. } else {
  129. wx.showToast({
  130. title: res.data.errmsg,
  131. icon: 'none',
  132. duration: 2000
  133. })
  134. }
  135. }
  136. })
  137. //查询数据
  138. wx.request({
  139. url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
  140. method: 'get',
  141. data: '',
  142. success(res) {
  143. let datas = res.data.data
  144. if (res.data.errcode == 0) {
  145. for (let i = 0; i < datas.length; i++) {
  146. if (datas[i].status == 0) {
  147. datas[i].status = '待比赛'
  148. } else if (datas[i].status == 1) {
  149. datas[i].status = '进行中'
  150. } else if (datas[i].status == 2) {
  151. datas[i].status = '报名中'
  152. } else if (datas[i].status == 3) {
  153. datas[i].status = '已结束'
  154. }
  155. }
  156. that.setData({
  157. teamlist: datas,
  158. });
  159. } else {
  160. wx.showToast({
  161. title: res.data.errmsg,
  162. icon: 'none',
  163. duration: 2000
  164. })
  165. }
  166. }
  167. })
  168. //解散团队数据
  169. wx.request({
  170. url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply`, //接口地址
  171. method: 'get',
  172. data: {},
  173. success(res) {
  174. if (res.data.errcode == 0) {
  175. let datas = res.data.data
  176. that.setData({
  177. dissolution: datas,
  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. })