apply.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. const moment = require("../../utils/moment.min")
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. frameStyle: { useTop: false, name: '团队审核', leftArrow: true, useBar: false },
  11. user_id: '',
  12. user_name: '',
  13. apply_time: '',
  14. ids: '',
  15. src: '/image/adimges.jpg',
  16. isshow: true,
  17. // 主体高度
  18. infoHeight: '',
  19. //团队详情
  20. teamlist: [],
  21. //加入团队列表
  22. addlist: [],
  23. },
  24. tabPath(e) {
  25. let query = e.detail.detail;
  26. if (query) wx.redirectTo({ url: `/pages/${query}/index` })
  27. },
  28. //点击申请加入
  29. add: function (e) {
  30. let obj = e.currentTarget.dataset;
  31. let forms = {
  32. team_id: obj.id,
  33. team_name: obj.name,
  34. apply_time: this.data.apply_time,
  35. apply_user: this.data.user_name,
  36. apply_id: this.data.user_id
  37. }
  38. wx.showModal({
  39. title: '',
  40. content: '是否申请加入',
  41. success(res) {
  42. if (res.confirm) {
  43. wx.request({
  44. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply`, //接口地址
  45. method: 'post',
  46. data: forms,
  47. success(res) {
  48. if (res.data.errcode == 0) {
  49. wx.showToast({ title: `申请加入成功`, icon: 'success', duration: 2000 }) //创建成功提示
  50. } else {
  51. wx.showToast({
  52. title: res.data.errmsg,
  53. icon: 'none',
  54. duration: 2000
  55. })
  56. }
  57. }
  58. })
  59. } else if (res.cancel) {
  60. }
  61. }
  62. })
  63. },
  64. back: function () {
  65. wx.navigateBack({ url: '/pages/team/index' })
  66. },
  67. //点击退出团队
  68. out() {
  69. var team_id = this.data.teamlist.id;
  70. var user_id = this.data.user_id;
  71. wx.showModal({
  72. title: '',
  73. content: '是否确认退出团队',
  74. success(res) {
  75. if (res.confirm) {
  76. wx.request({
  77. url: `${app.globalData.publicUrl}/courtAdmin/api/team/leaves`, //接口地址
  78. method: 'get',
  79. data: {
  80. "team_id": team_id,
  81. "user_id": user_id
  82. },
  83. success(res) {
  84. if (res.data.errcode == 0) {
  85. wx.showToast({ title: `退出团队成功`, icon: 'success', duration: 2000 }) //创建成功提示
  86. that.back()
  87. } else {
  88. wx.showToast({
  89. title: res.data.errmsg,
  90. icon: 'none',
  91. duration: 2000
  92. })
  93. }
  94. }
  95. })
  96. } else if (res.cancel) {
  97. }
  98. }
  99. })
  100. },
  101. /**
  102. * 生命周期函数--监听页面加载
  103. */
  104. onLoad: function (options) {
  105. this.setData({ ids: options.id });
  106. //获取当前时间
  107. let apply_time = moment().format('YYYY-MM-DD HH:mm:ss');
  108. this.setData({
  109. apply_time: apply_time,
  110. });
  111. // 计算高度
  112. this.searchHeight()
  113. // 监听用户是否登录
  114. this.watchLogin();
  115. },
  116. // 监听用户是否登录
  117. watchLogin: function () {
  118. var that = this;
  119. let id = that.data.ids
  120. wx.getStorage({
  121. key: 'token',
  122. success: res => {
  123. that.setData({
  124. user_id: res.data.id,
  125. user_name: res.data.nickname
  126. })
  127. let user_id = res.data.id;
  128. //查询数据
  129. wx.request({
  130. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`, //接口地址
  131. method: 'get',
  132. data: '',
  133. success(res) {
  134. if (res.data.errcode == 0) {
  135. let datas = res.data.data
  136. let members = datas.members
  137. for (let i = 0; i < members.length; i++) {
  138. if (user_id == members[i].id) {
  139. that.setData({
  140. isshow: false,
  141. });
  142. }
  143. }
  144. that.setData({
  145. teamlist: datas,
  146. });
  147. //加入团队列表
  148. wx.request({
  149. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply`, //接口地址
  150. method: "get",
  151. data: { team_id: id },
  152. header: {},
  153. success: res => {
  154. that.setData({ addlist: res.data.data })
  155. },
  156. error: err => {
  157. }
  158. })
  159. } else {
  160. wx.showToast({
  161. title: res.data.errmsg,
  162. icon: 'none',
  163. duration: 2000
  164. })
  165. }
  166. }
  167. })
  168. },
  169. fail: res => {
  170. return wx.redirectTo({ url: '/pages/login/index', })
  171. }
  172. })
  173. },
  174. // 计算高度
  175. searchHeight: function () {
  176. let frameStyle = this.data.frameStyle;
  177. let client = app.globalData.client;
  178. let infoHeight = client.windowHeight;
  179. // 是否去掉状态栏
  180. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  181. // 是否减去底部菜单
  182. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  183. if (infoHeight) this.setData({ infoHeight: infoHeight })
  184. },
  185. /**
  186. * 生命周期函数--监听页面初次渲染完成
  187. */
  188. onReady: function () {
  189. },
  190. /**
  191. * 生命周期函数--监听页面显示
  192. */
  193. onShow: function () {
  194. },
  195. /**
  196. * 生命周期函数--监听页面隐藏
  197. */
  198. onHide: function () {
  199. },
  200. /**
  201. * 生命周期函数--监听页面卸载
  202. */
  203. onUnload: function () {
  204. },
  205. /**
  206. * 页面相关事件处理函数--监听用户下拉动作
  207. */
  208. onPullDownRefresh: function () {
  209. },
  210. /**
  211. * 页面上拉触底事件的处理函数
  212. */
  213. onReachBottom: function () {
  214. },
  215. /**
  216. * 用户点击右上角分享
  217. */
  218. onShareAppMessage: function () {
  219. }
  220. })