detail.js 3.6 KB

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