apply.js 5.7 KB

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