index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. hasindex:3, //当前选择菜单的id
  10. frameStyle: { useTop: true, name: '团队排名', leftArrow: true, useBar: false },
  11. // 主体高度
  12. infoHeight: '',
  13. list: [
  14. // {
  15. // id: 1,
  16. // name: "哈拉海队幼儿组",
  17. // head: '/image/head2.png',
  18. // score1: "9",
  19. // score2: "0"
  20. // }, {
  21. // id: 2,
  22. // name: "哈拉海队幼儿组",
  23. // head: '/image/head2.png',
  24. // score1: "1",
  25. // score2: "0"
  26. // }, {
  27. // id: 3,
  28. // name: "哈拉海队幼儿组",
  29. // head: '/image/head2.png',
  30. // score1: "1",
  31. // score2: "0"
  32. // }, {
  33. // id: 4,
  34. // name: "哈拉海队幼儿组",
  35. // head: '/image/head2.png',
  36. // score1: "1",
  37. // score2: "1"
  38. // }
  39. ],
  40. lists: [
  41. // {
  42. // id: 1,
  43. // name: "哈拉海队幼儿组",
  44. // head: '/image/head2.png',
  45. // score: "9",
  46. // }, {
  47. // id: 2,
  48. // name: "哈拉海队幼儿组",
  49. // head: '/image/head2.png',
  50. // score: "1",
  51. // }, {
  52. // id: 3,
  53. // name: "哈拉海队幼儿组",
  54. // head: '/image/head2.png',
  55. // score: "1",
  56. // }, {
  57. // id: 4,
  58. // name: "哈拉海队幼儿组",
  59. // head: '/image/head2.png',
  60. // score: "1",
  61. // }
  62. ],
  63. },
  64. // 监听用户是否登录
  65. watchLogin: function () {
  66. wx.getStorage({
  67. key: 'token',
  68. success: res => {
  69. var that = this;
  70. wx.request({
  71. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  72. method: 'get',
  73. data:'',
  74. success(res) {
  75. if (res.data.errcode == 0) {
  76. let datacan = res.data.data
  77. console.log('排名',datacan);
  78. that.setData({
  79. list: datacan,
  80. lists: datacan,
  81. });
  82. } else {
  83. wx.showToast({
  84. title: res.data.errmsg,
  85. icon: 'none',
  86. duration: 2000
  87. })
  88. }
  89. }
  90. })
  91. },
  92. fail: res => {
  93. return wx.redirectTo({ url: '/pages/login/index', })
  94. }
  95. })
  96. },
  97. back: function () {
  98. wx.navigateBack({ url: '/pages/home/index' })
  99. },
  100. /**
  101. * 生命周期函数--监听页面加载
  102. */
  103. onLoad: function (options) {
  104. // 监听用户是否登录
  105. this.watchLogin();
  106. // 计算高度
  107. this.searchHeight()
  108. },
  109. // 计算高度
  110. searchHeight: function () {
  111. let frameStyle = this.data.frameStyle;
  112. let client = app.globalData.client;
  113. // 减去状态栏
  114. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  115. // 是否减去底部菜单
  116. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  117. if (infoHeight) this.setData({ infoHeight: infoHeight })
  118. },
  119. /**
  120. * 生命周期函数--监听页面初次渲染完成
  121. */
  122. onReady: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面显示
  126. */
  127. onShow: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面隐藏
  131. */
  132. onHide: function () {
  133. },
  134. /**
  135. * 生命周期函数--监听页面卸载
  136. */
  137. onUnload: function () {
  138. },
  139. /**
  140. * 页面相关事件处理函数--监听用户下拉动作
  141. */
  142. onPullDownRefresh: function () {
  143. },
  144. /**
  145. * 页面上拉触底事件的处理函数
  146. */
  147. onReachBottom: function () {
  148. },
  149. /**
  150. * 用户点击右上角分享
  151. */
  152. onShareAppMessage: function () {
  153. }
  154. })