index.js 8.6 KB

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