index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. // var list = that.data.list;
  71. // var match_id = that.ids;
  72. // var match_name = list.name;
  73. wx.request({
  74. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  75. method: 'get',
  76. data:'',
  77. success(res) {
  78. if (res.data.errcode == 0) {
  79. let datacan = res.data.data
  80. console.log('排名',datacan);
  81. that.setData({
  82. list: datacan,
  83. lists: datacan,
  84. });
  85. } else {
  86. wx.showToast({
  87. title: res.data.errmsg,
  88. icon: 'none',
  89. duration: 2000
  90. })
  91. }
  92. }
  93. })
  94. },
  95. fail: res => {
  96. return wx.redirectTo({ url: '/pages/login/index', })
  97. }
  98. })
  99. },
  100. back: function () {
  101. wx.navigateBack({ url: '/pages/home/index' })
  102. },
  103. /**
  104. * 生命周期函数--监听页面加载
  105. */
  106. onLoad: function (options) {
  107. // 监听用户是否登录
  108. this.watchLogin();
  109. // 计算高度
  110. this.searchHeight()
  111. },
  112. // 计算高度
  113. searchHeight: function () {
  114. let frameStyle = this.data.frameStyle;
  115. let client = app.globalData.client;
  116. // 减去状态栏
  117. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  118. // 是否减去底部菜单
  119. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  120. if (infoHeight) this.setData({ infoHeight: infoHeight })
  121. },
  122. /**
  123. * 生命周期函数--监听页面初次渲染完成
  124. */
  125. onReady: function () {
  126. },
  127. /**
  128. * 生命周期函数--监听页面显示
  129. */
  130. onShow: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面隐藏
  134. */
  135. onHide: function () {
  136. },
  137. /**
  138. * 生命周期函数--监听页面卸载
  139. */
  140. onUnload: function () {
  141. },
  142. /**
  143. * 页面相关事件处理函数--监听用户下拉动作
  144. */
  145. onPullDownRefresh: function () {
  146. },
  147. /**
  148. * 页面上拉触底事件的处理函数
  149. */
  150. onReachBottom: function () {
  151. },
  152. /**
  153. * 用户点击右上角分享
  154. */
  155. onShareAppMessage: function () {
  156. }
  157. })