detail.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. //logo
  20. fileList: [],
  21. ids: ''
  22. },
  23. back: function () {
  24. wx.navigateBack({ url: '/pages/home/index' })
  25. },
  26. //点击减号删除队员
  27. delList: function (e) {
  28. var that = this;
  29. var members = that.data.list.members;
  30. // console.log(that.data.list.id);
  31. var list = that.data.list;
  32. var ids = that.data.list.id;
  33. wx.showModal({
  34. title: '是否删除该名队员',
  35. success(res) {
  36. if (res.confirm) {
  37. let id = e.currentTarget.dataset.id;
  38. for (var i = 0; i < members.length; i++) {
  39. if (members[i].id == id) {
  40. members.splice(i, 1)
  41. }
  42. }
  43. that.setData({ ['list.members']: members })
  44. wx.request({
  45. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${ids}`, //接口地址
  46. method: "post",
  47. data: list,
  48. header: {},
  49. success: res => {
  50. console.log(res);
  51. },
  52. })
  53. } else if (res.cancel) { }
  54. }
  55. })
  56. },
  57. //保存
  58. preservation: function (e) {
  59. var that = this;
  60. var id = that.data.list.id;
  61. var list = that.data.list;
  62. wx.request({
  63. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`, //接口地址
  64. method: "post",
  65. data: list,
  66. header: {},
  67. success: res => {
  68. if (res.data.errcode == 0) {
  69. wx.showToast({
  70. title: '保存成功',
  71. icon: 'success',
  72. duration: 4000//延迟两秒
  73. })
  74. return wx.redirectTo({ url: '/pages/me/index' })// 跳转页面
  75. } else {
  76. wx.showToast({
  77. title: '保存失败',
  78. icon: 'success',
  79. duration: 2000
  80. })
  81. }
  82. },
  83. })
  84. },
  85. /**
  86. * 生命周期函数--监听页面加载
  87. */
  88. onLoad: function (options) {
  89. // 计算高度
  90. this.searchHeight()
  91. this.ids = options.id;
  92. // 监听用户是否登录
  93. this.watchLogin();
  94. },
  95. // 监听用户是否登录
  96. watchLogin: function () {
  97. const that = this;
  98. let id = that.ids
  99. wx.getStorage({
  100. key: 'token',
  101. success: res => {
  102. //查询数据
  103. wx.request({
  104. url: `${app.globalData.publicUrl}/courtAdmin/api/team/` + id, //接口地址
  105. method: 'get',
  106. data: '',
  107. success(res) {
  108. that.setData({ list: res.data.data });
  109. }
  110. })
  111. },
  112. fail: res => {
  113. return wx.redirectTo({ url: '/pages/login/index', })
  114. }
  115. })
  116. },
  117. // 计算高度
  118. searchHeight: function () {
  119. let frameStyle = this.data.frameStyle;
  120. let client = app.globalData.client;
  121. // 减去状态栏
  122. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  123. // 是否减去底部菜单
  124. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  125. if (infoHeight) this.setData({ infoHeight: infoHeight })
  126. },
  127. /**
  128. * 生命周期函数--监听页面初次渲染完成
  129. */
  130. onReady: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面显示
  134. */
  135. onShow: function () {
  136. },
  137. /**
  138. * 生命周期函数--监听页面隐藏
  139. */
  140. onHide: function () {
  141. },
  142. /**
  143. * 生命周期函数--监听页面卸载
  144. */
  145. onUnload: function () {
  146. },
  147. /**
  148. * 页面相关事件处理函数--监听用户下拉动作
  149. */
  150. onPullDownRefresh: function () {
  151. },
  152. /**
  153. * 页面上拉触底事件的处理函数
  154. */
  155. onReachBottom: function () {
  156. },
  157. /**
  158. * 用户点击右上角分享
  159. */
  160. onShareAppMessage: function () {
  161. }
  162. })