index.js 2.8 KB

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