index.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. let datasai = res.data.data
  124. that.setData({
  125. compete: datasai,
  126. });
  127. } else {
  128. wx.showToast({
  129. title: res.data.errmsg,
  130. icon: 'none',
  131. duration: 2000
  132. })
  133. }
  134. }
  135. })
  136. //查询数据
  137. wx.request({
  138. url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
  139. method: 'get',
  140. data: '',
  141. success(res) {
  142. if (res.data.errcode == 0) {
  143. let datas = res.data.data
  144. that.setData({
  145. teamlist: datas,
  146. });
  147. } else {
  148. wx.showToast({
  149. title: res.data.errmsg,
  150. icon: 'none',
  151. duration: 2000
  152. })
  153. }
  154. }
  155. })
  156. //解散团队数据
  157. wx.request({
  158. url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply`, //接口地址
  159. method: 'get',
  160. data: {},
  161. success(res) {
  162. if (res.data.errcode == 0) {
  163. let datas = res.data.data
  164. that.setData({
  165. dissolution: datas,
  166. });
  167. } else {
  168. wx.showToast({
  169. title: res.data.errmsg,
  170. icon: 'none',
  171. duration: 2000
  172. })
  173. }
  174. }
  175. })
  176. },
  177. fail: res => {
  178. return wx.redirectTo({ url: '/pages/login/index', })
  179. }
  180. })
  181. },
  182. // 计算高度
  183. searchHeight: function () {
  184. let frameStyle = this.data.frameStyle;
  185. let client = app.globalData.client;
  186. let infoHeight = client.windowHeight;
  187. // 是否去掉状态栏
  188. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  189. // 是否减去底部菜单
  190. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  191. if (infoHeight) this.setData({ infoHeight: infoHeight })
  192. },
  193. /**
  194. * 生命周期函数--监听页面初次渲染完成
  195. */
  196. onReady: function () {
  197. },
  198. /**
  199. * 生命周期函数--监听页面显示
  200. */
  201. onShow: function () {
  202. },
  203. /**
  204. * 生命周期函数--监听页面隐藏
  205. */
  206. onHide: function () {
  207. },
  208. /**
  209. * 生命周期函数--监听页面卸载
  210. */
  211. onUnload: function () {
  212. },
  213. /**
  214. * 页面相关事件处理函数--监听用户下拉动作
  215. */
  216. onPullDownRefresh: function () {
  217. },
  218. /**
  219. * 页面上拉触底事件的处理函数
  220. */
  221. onReachBottom: function () {
  222. },
  223. /**
  224. * 用户点击右上角分享
  225. */
  226. onShareAppMessage: function () {
  227. }
  228. })