info.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. // 用户信息
  13. user: {},
  14. // 当前用户是否在团队成员列表里面
  15. is_membes: false,
  16. // 背景图片
  17. bg_img: '/image/team_1.jpg',
  18. id: '62985b80006dd062af49fdf9',
  19. form: {},
  20. },
  21. back: function () {
  22. wx.navigateBack({ delta: 1 })
  23. },
  24. // 删除成员
  25. toDel: async function (e) {
  26. const that = this;
  27. const data = that.data.form;
  28. const { id } = e.currentTarget.dataset;
  29. wx.showModal({
  30. title: '是否删除该名队员',
  31. async success(res) {
  32. if (res.confirm) {
  33. let members = data.members.filter((i) => i.user_id != id);
  34. const arr = await app.$post(`/courtAdmin/api/team/${data.id}`, { members: members });
  35. if (arr.errcode == '0') {
  36. wx.showToast({ title: `删除成员成功`, icon: 'error', duration: 2000 });
  37. that.watchLogin();
  38. } else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
  39. } else if (res.cancel) { }
  40. }
  41. })
  42. },
  43. // 退出团队
  44. delTeam: function () {
  45. const that = this;
  46. const data = that.data.form;
  47. const user = that.data.user;
  48. wx.showModal({
  49. title: '是否确认退出团队?',
  50. async success(res) {
  51. if (res.confirm) {
  52. const arr = await app.$get(`/courtAdmin/api/team/leaves`, { user_id: user._id, team_id: data.id });
  53. if (arr.errcode == '0') {
  54. wx.showToast({ title: `退出团队成功`, icon: 'error', duration: 2000 });
  55. that.watchLogin();
  56. } else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
  57. } else if (res.cancel) {
  58. }
  59. }
  60. })
  61. },
  62. /**
  63. * 生命周期函数--监听页面加载
  64. */
  65. onLoad: function (options) {
  66. const that = this;
  67. if (options && options.id) that.setData({ id: options.id })
  68. // 计算高度
  69. this.searchHeight();
  70. // 监听用户是否登录
  71. this.watchLogin();
  72. },
  73. // 监听用户是否登录
  74. watchLogin: function () {
  75. const that = this;
  76. wx.getStorage({
  77. key: 'token',
  78. success: async res => {
  79. that.setData({ user: res.data })
  80. let arr;
  81. // 系统团队
  82. arr = await app.$get(`/courtAdmin/api/team/${that.data.id}`);
  83. if (arr.errcode == '0') {
  84. that.setData({ form: arr.data });
  85. // 个人用户判断当前用户是否为团队成员
  86. if (res.data.type == '2') {
  87. let is_membes = arr.data.members.find((i) => i.user_id == res.data._id);
  88. if (is_membes) that.setData({ is_membes: true })
  89. }
  90. }
  91. },
  92. fail: res => {
  93. wx.redirectTo({ url: '/pages/index/index', })
  94. }
  95. })
  96. },
  97. // 计算高度
  98. searchHeight: function () {
  99. let frameStyle = this.data.frameStyle;
  100. let client = app.globalData.client;
  101. let infoHeight = client.windowHeight;
  102. // 是否去掉状态栏
  103. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  104. // 是否减去底部菜单
  105. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  106. if (infoHeight) this.setData({ infoHeight: infoHeight })
  107. },
  108. /**
  109. * 生命周期函数--监听页面初次渲染完成
  110. */
  111. onReady: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面显示
  115. */
  116. onShow: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面隐藏
  120. */
  121. onHide: function () {
  122. },
  123. /**
  124. * 生命周期函数--监听页面卸载
  125. */
  126. onUnload: function () {
  127. },
  128. /**
  129. * 页面相关事件处理函数--监听用户下拉动作
  130. */
  131. onPullDownRefresh: function () {
  132. },
  133. /**
  134. * 页面上拉触底事件的处理函数
  135. */
  136. onReachBottom: function () {
  137. },
  138. /**
  139. * 用户点击右上角分享
  140. */
  141. onShareAppMessage: function () {
  142. }
  143. })