apply.js 5.8 KB

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