apply.js 5.0 KB

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