detail.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. console.log(res);
  68. return wx.redirectTo({ url: '/pages/me/index' })
  69. },
  70. error: err => {
  71. }
  72. })
  73. } else if (res.cancel) {
  74. }
  75. }
  76. })
  77. }
  78. },
  79. /**
  80. * 生命周期函数--监听页面加载
  81. */
  82. onLoad: function (options) {
  83. // 计算高度
  84. this.searchHeight()
  85. this.setData({ ids: options.id })
  86. // 监听用户是否登录
  87. this.watchLogin();
  88. },
  89. // 监听用户是否登录
  90. watchLogin: function () {
  91. const that = this;
  92. let id = that.data.ids
  93. wx.getStorage({
  94. key: 'token',
  95. success: res => {
  96. that.setData({ type: res.data.type })
  97. that.setData({ id1: res.data.id })
  98. wx.request({
  99. url: `${app.globalData.publicUrl}/courtAdmin/api/team/` + id,
  100. method: 'get',
  101. data: '',
  102. success(res) {
  103. that.setData({ list: res.data.data });
  104. }
  105. })
  106. },
  107. fail: res => {
  108. return wx.redirectTo({ url: '/pages/login/index', })
  109. }
  110. })
  111. },
  112. // 计算高度
  113. searchHeight: function () {
  114. let frameStyle = this.data.frameStyle;
  115. let client = app.globalData.client;
  116. let infoHeight = client.windowHeight;
  117. // 是否去掉状态栏
  118. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  119. // 是否减去底部菜单
  120. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  121. if (infoHeight) this.setData({ infoHeight: infoHeight })
  122. },
  123. /**
  124. * 生命周期函数--监听页面初次渲染完成
  125. */
  126. onReady: function () {
  127. },
  128. /**
  129. * 生命周期函数--监听页面显示
  130. */
  131. onShow: function () {
  132. },
  133. /**
  134. * 生命周期函数--监听页面隐藏
  135. */
  136. onHide: function () {
  137. },
  138. /**
  139. * 生命周期函数--监听页面卸载
  140. */
  141. onUnload: function () {
  142. },
  143. /**
  144. * 页面相关事件处理函数--监听用户下拉动作
  145. */
  146. onPullDownRefresh: function () {
  147. },
  148. /**
  149. * 页面上拉触底事件的处理函数
  150. */
  151. onReachBottom: function () {
  152. },
  153. /**
  154. * 用户点击右上角分享
  155. */
  156. onShareAppMessage: function () {
  157. }
  158. })