detail.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. type: '',
  20. ids: '',
  21. id1: ''
  22. },
  23. back: function () {
  24. wx.navigateBack({ url: '/pages/home/index' })
  25. },
  26. //删除队员-退出团队
  27. delList: function (e) {
  28. var that = this;
  29. var type = that.data.type;
  30. var members = that.data.list.members;
  31. var list = that.data.list;
  32. var ids = that.data.list.id;
  33. var id1 = that.data.id1;
  34. if (type == 1) {
  35. wx.showModal({
  36. title: '是否删除该名队员',
  37. success(res) {
  38. if (res.confirm) {
  39. let id = e.currentTarget.dataset.id;
  40. for (var i = 0; i < members.length; i++) {
  41. if (members[i].id == id) {
  42. members.splice(i, 1)
  43. }
  44. }
  45. that.setData({ ['list.members']: members })
  46. wx.request({
  47. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${ids}`,
  48. method: "post",
  49. data: list,
  50. header: {},
  51. success: res => {
  52. },
  53. })
  54. } else if (res.cancel) { }
  55. }
  56. })
  57. } else if (type == 2) {
  58. wx.showModal({
  59. title: '是否退出团队',
  60. success(res) {
  61. if (res.confirm) {
  62. wx.request({
  63. url: `${app.globalData.publicUrl}/courtAdmin/api/team/leaves`,
  64. method: "get",
  65. data: { user_id: id1, team_id: ids },
  66. header: {},
  67. success: 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. })