detail.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. //队员列表
  17. { members: [], }
  18. ],
  19. ids: '',
  20. id1: ''
  21. },
  22. back: function () {
  23. wx.navigateBack({ url: '/pages/home/index' })
  24. },
  25. //删除队员-退出团队
  26. delList: function (e) {
  27. var that = this;
  28. var type = that.data.type;
  29. var members = that.data.list.members;
  30. var list = that.data.list;
  31. var ids = that.data.list.id;
  32. var id1 = that.data.id1;
  33. if (type == 1) {
  34. wx.showModal({
  35. title: '是否删除该名队员',
  36. success(res) {
  37. if (res.confirm) {
  38. let id = e.currentTarget.dataset.id;
  39. for (var i = 0; i < members.length; i++) {
  40. if (members[i].id == id) {
  41. members.splice(i, 1)
  42. }
  43. }
  44. that.setData({ ['list.members']: members })
  45. wx.request({
  46. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${ids}`,
  47. method: "post",
  48. data: list,
  49. header: {},
  50. success: res => {
  51. },
  52. })
  53. } else if (res.cancel) { }
  54. }
  55. })
  56. } else if (type == 2) {
  57. wx.showModal({
  58. title: '是否退出团队',
  59. success(res) {
  60. if (res.confirm) {
  61. wx.request({
  62. url: `${app.globalData.publicUrl}/courtAdmin/api/team/leaves`,
  63. method: "get",
  64. data: { user_id: id1, team_id: ids },
  65. header: {},
  66. success: res => {
  67. return wx.redirectTo({ url: '/pages/me/index' })
  68. },
  69. error: err => {
  70. }
  71. })
  72. } else if (res.cancel) {
  73. }
  74. }
  75. })
  76. }
  77. },
  78. /**
  79. * 生命周期函数--监听页面加载
  80. */
  81. onLoad: function (options) {
  82. // 计算高度
  83. this.searchHeight()
  84. this.setData({ ids: options.id })
  85. // 监听用户是否登录
  86. this.watchLogin();
  87. },
  88. // 监听用户是否登录
  89. watchLogin: function () {
  90. const that = this;
  91. let id = that.data.ids
  92. wx.getStorage({
  93. key: 'token',
  94. success: res => {
  95. that.setData({ type: res.data.type })
  96. that.setData({ id1: res.data.id })
  97. wx.request({
  98. url: `${app.globalData.publicUrl}/courtAdmin/api/team/` + id,
  99. method: 'get',
  100. data: '',
  101. success(res) {
  102. that.setData({ list: res.data.data });
  103. }
  104. })
  105. },
  106. fail: res => {
  107. return wx.redirectTo({ url: '/pages/login/index', })
  108. }
  109. })
  110. },
  111. // 计算高度
  112. searchHeight: function () {
  113. let frameStyle = this.data.frameStyle;
  114. let client = app.globalData.client;
  115. let infoHeight = client.windowHeight;
  116. // 是否去掉状态栏
  117. if (frameStyle.useTop) infoHeight = infoHeight - (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. })