index.js 6.1 KB

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