apply.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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/home/index' })
  66. },
  67. //点击退出团队
  68. out() {
  69. wx.showModal({
  70. title: '',
  71. content: '是否确认退出团队',
  72. success(res) {
  73. if (res.confirm) {
  74. var team_id = this.data.teamlist.id;
  75. var user_id = this.data.user_id;
  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. } else {
  87. wx.showToast({
  88. title: res.data.errmsg,
  89. icon: 'none',
  90. duration: 2000
  91. })
  92. }
  93. }
  94. })
  95. } else if (res.cancel) {
  96. }
  97. }
  98. })
  99. },
  100. /**
  101. * 生命周期函数--监听页面加载
  102. */
  103. onLoad: function (options) {
  104. this.setData({ ids: options.id });
  105. //获取当前时间
  106. let apply_time = moment().format('YYYY-MM-DD HH:mm:ss');
  107. this.setData({
  108. apply_time: apply_time,
  109. });
  110. // 计算高度
  111. this.searchHeight()
  112. // 监听用户是否登录
  113. this.watchLogin();
  114. },
  115. // 监听用户是否登录
  116. watchLogin: function () {
  117. var that = this;
  118. let id = that.data.ids
  119. wx.getStorage({
  120. key: 'token',
  121. success: res => {
  122. that.setData({
  123. user_id: res.data.id,
  124. user_name: res.data.nickname
  125. })
  126. let user_id = res.data.id;
  127. //查询数据
  128. wx.request({
  129. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`, //接口地址
  130. method: 'get',
  131. data: '',
  132. success(res) {
  133. if (res.data.errcode == 0) {
  134. let datas = res.data.data
  135. let members = datas.members
  136. for (let i = 0; i < members.length; i++) {
  137. if (user_id == members[i].id) {
  138. that.setData({
  139. isshow: false,
  140. });
  141. }
  142. }
  143. that.setData({
  144. teamlist: datas,
  145. });
  146. //加入团队列表
  147. wx.request({
  148. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply`, //接口地址
  149. method: "get",
  150. data: { team_id: id },
  151. header: {},
  152. success: res => {
  153. that.setData({ addlist: res.data.data })
  154. },
  155. error: err => {
  156. }
  157. })
  158. } else {
  159. wx.showToast({
  160. title: res.data.errmsg,
  161. icon: 'none',
  162. duration: 2000
  163. })
  164. }
  165. }
  166. })
  167. },
  168. fail: res => {
  169. return wx.redirectTo({ url: '/pages/login/index', })
  170. }
  171. })
  172. },
  173. // 计算高度
  174. searchHeight: function () {
  175. let frameStyle = this.data.frameStyle;
  176. let client = app.globalData.client;
  177. let infoHeight = client.windowHeight;
  178. // 是否去掉状态栏
  179. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  180. // 是否减去底部菜单
  181. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  182. if (infoHeight) this.setData({ infoHeight: infoHeight })
  183. },
  184. /**
  185. * 生命周期函数--监听页面初次渲染完成
  186. */
  187. onReady: function () {
  188. },
  189. /**
  190. * 生命周期函数--监听页面显示
  191. */
  192. onShow: function () {
  193. },
  194. /**
  195. * 生命周期函数--监听页面隐藏
  196. */
  197. onHide: function () {
  198. },
  199. /**
  200. * 生命周期函数--监听页面卸载
  201. */
  202. onUnload: function () {
  203. },
  204. /**
  205. * 页面相关事件处理函数--监听用户下拉动作
  206. */
  207. onPullDownRefresh: function () {
  208. },
  209. /**
  210. * 页面上拉触底事件的处理函数
  211. */
  212. onReachBottom: function () {
  213. },
  214. /**
  215. * 用户点击右上角分享
  216. */
  217. onShareAppMessage: function () {
  218. }
  219. })