index.js 3.0 KB

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