index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. //数据请求
  30. wx.request({
  31. url: `${app.globalData.publicUrl}/courtAdmin/api/team/leaves`, //接口地址
  32. method: "get",//请求方法
  33. data: { user_id: id1, team_id: id },//请求参数
  34. header: {},
  35. success: res => {
  36. return wx.redirectTo({ url: '/pages/me/index' })// 跳转页面
  37. },
  38. error: err => {
  39. }
  40. })
  41. } else if (res.cancel) {
  42. }
  43. }
  44. })
  45. },
  46. /**
  47. * 生命周期函数--监听页面加载
  48. */
  49. onLoad: function (options) {
  50. // 计算高度
  51. this.searchHeight()
  52. this.ids = options.id;
  53. // 监听用户是否登录
  54. this.watchLogin();
  55. },
  56. // 监听用户是否登录
  57. watchLogin: function () {
  58. const that = this;
  59. let id = that.ids
  60. wx.getStorage({
  61. key: 'token',
  62. success: res => {
  63. //查询数据
  64. wx.request({
  65. url: `${app.globalData.publicUrl}/courtAdmin/api/team/` + id, //接口地址
  66. method: 'get',
  67. data: '',
  68. success(res) {
  69. that.setData({ list: res.data.data });
  70. }
  71. })
  72. },
  73. fail: res => {
  74. return wx.redirectTo({ url: '/pages/login/index', })
  75. }
  76. })
  77. },
  78. // 计算高度
  79. searchHeight: function () {
  80. let frameStyle = this.data.frameStyle;
  81. let client = app.globalData.client;
  82. let infoHeight = client.windowHeight;
  83. // 是否去掉状态栏
  84. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  85. // 是否减去底部菜单
  86. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  87. if (infoHeight) this.setData({ infoHeight: infoHeight })
  88. },
  89. /**
  90. * 生命周期函数--监听页面初次渲染完成
  91. */
  92. onReady: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面显示
  96. */
  97. onShow: function () {
  98. },
  99. /**
  100. * 生命周期函数--监听页面隐藏
  101. */
  102. onHide: function () {
  103. },
  104. /**
  105. * 生命周期函数--监听页面卸载
  106. */
  107. onUnload: function () {
  108. },
  109. /**
  110. * 页面相关事件处理函数--监听用户下拉动作
  111. */
  112. onPullDownRefresh: function () {
  113. },
  114. /**
  115. * 页面上拉触底事件的处理函数
  116. */
  117. onReachBottom: function () {
  118. },
  119. /**
  120. * 用户点击右上角分享
  121. */
  122. onShareAppMessage: function () {
  123. }
  124. })