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