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. out: function (e){
  144. let id= e.currentTarget.dataset.name;
  145. wx.showModal({
  146. title: '',
  147. content: '是否确认解散团队',
  148. success(res) {
  149. if (res.confirm) {
  150. wx.request({
  151. url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply/`+id, //接口地址
  152. method: 'DELETE',
  153. data: '',
  154. success(res) {
  155. if (res.data.errcode == 0) {
  156. wx.showToast({ title: `解散团队成功`, icon: 'success', duration: 2000 }) //创建成功提示
  157. return wx.redirectTo({ url: '/pages/manage/index' })// 跳转页面
  158. } else {
  159. wx.showToast({
  160. title: res.data.errmsg,
  161. icon: 'none',
  162. duration: 2000
  163. })
  164. }
  165. }
  166. })
  167. } else if (res.cancel) {
  168. console.log('用户点击取消')
  169. }
  170. }
  171. })
  172. },
  173. /**
  174. * 生命周期函数--监听页面加载
  175. */
  176. onLoad: function (options) {
  177. // 监听用户是否登录
  178. this.watchLogin();
  179. // 计算高度
  180. this.searchHeight();
  181. },
  182. // 计算高度
  183. searchHeight: function () {
  184. let frameStyle = this.data.frameStyle;
  185. let client = app.globalData.client;
  186. // 减去状态栏
  187. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  188. // 是否减去底部菜单
  189. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  190. if (infoHeight) this.setData({ infoHeight: infoHeight })
  191. },
  192. /**
  193. * 生命周期函数--监听页面初次渲染完成
  194. */
  195. onReady: function () {
  196. },
  197. /**
  198. * 生命周期函数--监听页面显示
  199. */
  200. onShow: function () {
  201. },
  202. /**
  203. * 生命周期函数--监听页面隐藏
  204. */
  205. onHide: function () {
  206. },
  207. /**
  208. * 生命周期函数--监听页面卸载
  209. */
  210. onUnload: function () {
  211. },
  212. /**
  213. * 页面相关事件处理函数--监听用户下拉动作
  214. */
  215. onPullDownRefresh: function () {
  216. },
  217. /**
  218. * 页面上拉触底事件的处理函数
  219. */
  220. onReachBottom: function () {
  221. },
  222. /**
  223. * 用户点击右上角分享
  224. */
  225. onShareAppMessage: function () {
  226. }
  227. })