apply.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. add: function (e) {
  63. let obj = e.currentTarget.dataset;
  64. let forms = {
  65. team_id: obj.id,
  66. team_name: obj.name,
  67. apply_time: this.data.apply_time,
  68. apply_user: obj.user,
  69. // apply_id: '1'
  70. apply_id: obj.cid
  71. }
  72. wx.showModal({
  73. title: '',
  74. content: '是否申请加入',
  75. success(res) {
  76. if (res.confirm) {
  77. wx.request({
  78. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply`, //接口地址
  79. method: 'post',
  80. data: forms,
  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. console.log('用户点击取消')
  95. }
  96. }
  97. })
  98. },
  99. back: function () {
  100. wx.navigateBack({ url: '/pages/home/index' })
  101. },
  102. out() {
  103. wx.showModal({
  104. title: '',
  105. content: '是否确认退出团队',
  106. success(res) {
  107. if (res.confirm) {
  108. var team_id =this.data.list.id;
  109. var user_id =this.data.user_id;
  110. wx.request({
  111. url: `${app.globalData.publicUrl}/courtAdmin/api/team/leaves`, //接口地址
  112. method: 'get',
  113. data: {
  114. "team_id":team_id,
  115. "user_id":user_id
  116. },
  117. success(res) {
  118. if (res.data.errcode == 0) {
  119. wx.showToast({ title: `退出团队成功`, icon: 'success', duration: 2000 }) //创建成功提示
  120. } else {
  121. wx.showToast({
  122. title: res.data.errmsg,
  123. icon: 'none',
  124. duration: 2000
  125. })
  126. }
  127. }
  128. })
  129. } else if (res.cancel) {
  130. console.log('用户点击取消')
  131. }
  132. }
  133. })
  134. },
  135. /**
  136. * 生命周期函数--监听页面加载
  137. */
  138. onLoad: function (options) {
  139. let apply_time = moment().format('YYYY-MM-DD HH:mm:ss');
  140. this.setData({
  141. apply_time: apply_time,
  142. });
  143. // 计算高度
  144. this.searchHeight()
  145. this.ids = options.id;
  146. // 监听用户是否登录
  147. this.watchLogin();
  148. },
  149. // 计算高度
  150. searchHeight: function () {
  151. let frameStyle = this.data.frameStyle;
  152. let client = app.globalData.client;
  153. // 减去状态栏
  154. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  155. // 是否减去底部菜单
  156. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  157. if (infoHeight) this.setData({ infoHeight: infoHeight })
  158. },
  159. /**
  160. * 生命周期函数--监听页面初次渲染完成
  161. */
  162. onReady: function () {
  163. },
  164. /**
  165. * 生命周期函数--监听页面显示
  166. */
  167. onShow: function () {
  168. },
  169. /**
  170. * 生命周期函数--监听页面隐藏
  171. */
  172. onHide: function () {
  173. },
  174. /**
  175. * 生命周期函数--监听页面卸载
  176. */
  177. onUnload: function () {
  178. },
  179. /**
  180. * 页面相关事件处理函数--监听用户下拉动作
  181. */
  182. onPullDownRefresh: function () {
  183. },
  184. /**
  185. * 页面上拉触底事件的处理函数
  186. */
  187. onReachBottom: function () {
  188. },
  189. /**
  190. * 用户点击右上角分享
  191. */
  192. onShareAppMessage: function () {
  193. }
  194. })