index.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. toCheck: function (e) {
  25. const that = this;
  26. let { id, status } = e.currentTarget.dataset;
  27. wx.showModal({
  28. content: `您确定提交${status == '1' ? '通过' : '驳回'}操作吗?`,
  29. title: '提示',
  30. success(result) {
  31. if (result.confirm) {
  32. if (status == '1') {
  33. wx.request({
  34. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`,
  35. method: "post",
  36. data: { status: status },
  37. header: {},
  38. success: res => {
  39. if (res.data.errcode === 0) {
  40. wx.showToast({ title: '审核成功', icon: 'success', duration: 2000 });
  41. that.watchLogin();
  42. } else {
  43. wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
  44. }
  45. },
  46. error: err => {
  47. }
  48. })
  49. } else {
  50. wx.request({
  51. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`,
  52. method: "post",
  53. data: { status: status },
  54. header: {},
  55. success: res => {
  56. if (res.data.errcode === 0) {
  57. wx.showToast({ title: '审核成功', icon: 'success', duration: 2000 });
  58. that.watchLogin();
  59. } else {
  60. wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
  61. }
  62. },
  63. error: err => {
  64. }
  65. })
  66. }
  67. } else if (result.cancel) { }
  68. }
  69. })
  70. },
  71. //查询解散或参赛团队详情
  72. shen: function (e) {
  73. let obj = e.currentTarget.dataset;
  74. if (obj.route) {
  75. wx.navigateTo
  76. ({
  77. url: `/pages/administration/${obj.route}?obj=${decodeURIComponent(JSON.stringify(obj))}`
  78. })
  79. }
  80. },
  81. //查询团队详情
  82. shens: function (e) {
  83. let id = e.currentTarget.dataset.id;
  84. wx.navigateTo({
  85. url: `/pages/administration/details?id=${id}`
  86. })
  87. },
  88. //参赛团队点击通过
  89. cantong: function (e) {
  90. let id = e.currentTarget.dataset.id;
  91. wx.showModal({
  92. title: '',
  93. content: '是否通过参赛团队',
  94. success(res) {
  95. if (res.confirm) {
  96. wx.request({
  97. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam/${id}`, //接口地址
  98. method: 'post',
  99. data: {
  100. "status": "1"
  101. },
  102. success(res) {
  103. if (res.data.errcode == 0) {
  104. wx.showToast({ title: `通过团队成功`, icon: 'success', duration: 2000 }) //创建成功提示
  105. return wx.redirectTo({ url: '/pages/manage/index' })// 跳转页面
  106. } else {
  107. wx.showToast({
  108. title: res.data.errmsg,
  109. icon: 'none',
  110. duration: 2000
  111. })
  112. }
  113. }
  114. })
  115. } else if (res.cancel) {
  116. }
  117. }
  118. })
  119. },
  120. //解散点击通过
  121. out: function (e) {
  122. let { teamid, id } = e.currentTarget.dataset;
  123. wx.showModal({
  124. title: '',
  125. content: '是否确认解散团队',
  126. success(res) {
  127. if (res.confirm) {
  128. wx.request({
  129. url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply/` + id, //接口地址
  130. method: 'DELETE',
  131. data: {},
  132. success(res) {
  133. if (res.data.errcode == 0) {
  134. wx.request({
  135. url: `${app.globalData.publicUrl}/courtAdmin/api/team/` + teamid, //接口地址
  136. method: 'DELETE',
  137. data: {},
  138. success(res) {
  139. if (res.data.errcode == 0) {
  140. wx.showToast({ title: `解散团队成功`, icon: 'success', duration: 2000 }) //创建成功提示
  141. return wx.redirectTo({ url: '/pages/manage/index' })// 跳转页面
  142. } else {
  143. wx.showToast({
  144. title: res.data.errmsg,
  145. icon: 'none',
  146. duration: 2000
  147. })
  148. }
  149. }
  150. })
  151. } else {
  152. wx.showToast({
  153. title: res.data.errmsg,
  154. icon: 'none',
  155. duration: 2000
  156. })
  157. }
  158. }
  159. })
  160. } else if (res.cancel) {
  161. }
  162. }
  163. })
  164. },
  165. /**
  166. * 生命周期函数--监听页面加载
  167. */
  168. onLoad: function (options) {
  169. // 计算高度
  170. this.searchHeight();
  171. // 监听用户是否登录
  172. this.watchLogin();
  173. },
  174. // 监听用户是否登录
  175. watchLogin: function () {
  176. var that = this;
  177. wx.getStorage({
  178. key: 'token',
  179. success: res => {
  180. wx.request({
  181. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  182. method: 'get',
  183. data: {},
  184. success(res) {
  185. if (res.data.errcode == 0) {
  186. that.setData({
  187. compete: res.data.data,
  188. });
  189. } else {
  190. wx.showToast({
  191. title: res.data.errmsg,
  192. icon: 'none',
  193. duration: 2000
  194. })
  195. }
  196. }
  197. })
  198. //查询数据
  199. wx.request({
  200. url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
  201. method: 'get',
  202. data: {},
  203. success(res) {
  204. if (res.data.errcode == 0) {
  205. that.setData({
  206. teamlist: res.data.data,
  207. });
  208. } else {
  209. wx.showToast({
  210. title: res.data.errmsg,
  211. icon: 'none',
  212. duration: 2000
  213. })
  214. }
  215. }
  216. })
  217. //解散团队数据
  218. wx.request({
  219. url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply`, //接口地址
  220. method: 'get',
  221. data: {},
  222. success(res) {
  223. if (res.data.errcode == 0) {
  224. that.setData({
  225. dissolution: res.data.data,
  226. });
  227. } else {
  228. wx.showToast({
  229. title: res.data.errmsg,
  230. icon: 'none',
  231. duration: 2000
  232. })
  233. }
  234. }
  235. })
  236. },
  237. fail: res => {
  238. return wx.redirectTo({ url: '/pages/login/index', })
  239. }
  240. })
  241. },
  242. // 计算高度
  243. searchHeight: function () {
  244. let frameStyle = this.data.frameStyle;
  245. let client = app.globalData.client;
  246. let infoHeight = client.windowHeight;
  247. // 是否去掉状态栏
  248. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  249. // 是否减去底部菜单
  250. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  251. if (infoHeight) this.setData({ infoHeight: infoHeight })
  252. },
  253. /**
  254. * 生命周期函数--监听页面初次渲染完成
  255. */
  256. onReady: function () {
  257. },
  258. /**
  259. * 生命周期函数--监听页面显示
  260. */
  261. onShow: function () {
  262. // 监听用户是否登录
  263. this.watchLogin();
  264. },
  265. /**
  266. * 生命周期函数--监听页面隐藏
  267. */
  268. onHide: function () {
  269. },
  270. /**
  271. * 生命周期函数--监听页面卸载
  272. */
  273. onUnload: function () {
  274. },
  275. /**
  276. * 页面相关事件处理函数--监听用户下拉动作
  277. */
  278. onPullDownRefresh: function () {
  279. },
  280. /**
  281. * 页面上拉触底事件的处理函数
  282. */
  283. onReachBottom: function () {
  284. },
  285. /**
  286. * 用户点击右上角分享
  287. */
  288. onShareAppMessage: function () {
  289. }
  290. })