index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. type: '',
  10. src: '/image/team.png',
  11. frameStyle: { useTop: true, name: '我的团队', leftArrow: false, useBar: true },
  12. // 主体高度
  13. infoHeight: '',
  14. list: [],
  15. },
  16. tabPath(e) {
  17. let query = e.detail.detail;
  18. if (query) wx.redirectTo({ url: `/pages/${query}/index` })
  19. },
  20. tiao: function (e) {
  21. let id = e.currentTarget.dataset.name;
  22. wx.navigateTo({
  23. url: '/pages/team/examine?id=' + id,
  24. })
  25. },
  26. jump: function (e) {
  27. let id = e.currentTarget.dataset.name;
  28. wx.navigateTo({
  29. url: '/pages/team/apply?id=' + id,
  30. })
  31. },
  32. // 监听用户是否登录
  33. watchLogin: function () {
  34. var that = this;
  35. wx.getStorage({
  36. key: 'token',
  37. success: res => {
  38. this.setData({
  39. type: res.data.type,
  40. })
  41. //查询数据
  42. wx.request({
  43. url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
  44. method: 'get',
  45. data: '',
  46. success(res) {
  47. console.log('res', res.data);
  48. if (res.data.errcode == 0) {
  49. let datas = res.data.data
  50. for (let i = 0; i < datas.length; i++) {
  51. if (datas[i].status == 0) {
  52. datas[i].status = '待比赛'
  53. } else if (datas[i].status == 1) {
  54. datas[i].status = '进行中'
  55. } else if (datas[i].status == 2) {
  56. datas[i].status = '报名中'
  57. } else if (datas[i].status == 3) {
  58. datas[i].status = '已结束'
  59. }
  60. }
  61. that.setData({
  62. list: datas,
  63. });
  64. } else {
  65. wx.showToast({
  66. title: res.data.errmsg,
  67. icon: 'none',
  68. duration: 2000
  69. })
  70. }
  71. }
  72. })
  73. },
  74. fail: res => {
  75. return wx.redirectTo({ url: '/pages/login/index', })
  76. }
  77. })
  78. },
  79. /**
  80. * 生命周期函数--监听页面加载
  81. */
  82. onLoad: function (options) {
  83. // 计算高度
  84. this.searchHeight()
  85. // 监听用户是否登录
  86. this.watchLogin();
  87. },
  88. // 计算高度
  89. searchHeight: function () {
  90. let frameStyle = this.data.frameStyle;
  91. let client = app.globalData.client;
  92. // 减去状态栏
  93. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  94. // 是否减去底部菜单
  95. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  96. if (infoHeight) this.setData({ infoHeight: infoHeight })
  97. },
  98. /**
  99. * 生命周期函数--监听页面初次渲染完成
  100. */
  101. onReady: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面显示
  105. */
  106. onShow: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面隐藏
  110. */
  111. onHide: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面卸载
  115. */
  116. onUnload: function () {
  117. },
  118. /**
  119. * 页面相关事件处理函数--监听用户下拉动作
  120. */
  121. onPullDownRefresh: function () {
  122. },
  123. /**
  124. * 页面上拉触底事件的处理函数
  125. */
  126. onReachBottom: function () {
  127. },
  128. /**
  129. * 用户点击右上角分享
  130. */
  131. onShareAppMessage: function () {
  132. }
  133. })