index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '申请加入', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. singledate: '2022-01-01',
  13. time: '12:01',
  14. form: {
  15. team_id: '1',// 团队id
  16. team_name: '团队名称', // 团队名称
  17. apply_time: '2022-03-22',// 申请时间
  18. apply_user: '申请人',// 申请人
  19. apply_id: '1',// 申请人id
  20. },
  21. },
  22. // 申请加入
  23. onSubmit: function (e) {
  24. let form = this.data.form;
  25. var team_id = form.team_id;
  26. var team_name = form.team_name;
  27. var apply_time = form.apply_time + ' ' + this.data.time;
  28. var apply_user = form.apply_user;
  29. var apply_id = form.apply_id;
  30. const params = {
  31. "team_id": team_id,
  32. "team_name": team_name,
  33. "apply_time": apply_time,
  34. "apply_user": apply_user,
  35. "apply_id": apply_id,
  36. };
  37. wx.request({
  38. url: `${app.globalData.publicUrl}/courtAdmin/api/joinapply`, //接口地址
  39. method: 'post',
  40. data: params,
  41. success(res) {
  42. if (res.data.errcode == 0) {
  43. wx.showToast({ title: `申请加入成功`, icon: 'success', duration: 2000 }) //创建成功提示
  44. wx.navigateTo({ url: '/pages/team/apply?id=' + team_id })// 跳转页面
  45. } else {
  46. wx.showToast({
  47. title: res.data.errmsg,
  48. icon: 'none',
  49. duration: 2000
  50. })
  51. }
  52. }
  53. })
  54. },
  55. //日期选择器
  56. bindDateChange3: function (e) {
  57. this.setData({
  58. singledate: e.detail.value
  59. })
  60. },
  61. //时间选择器
  62. bindTimeChange: function (e) {
  63. this.setData({
  64. time: e.detail.value
  65. })
  66. },
  67. // 时间段选择
  68. bindDateChange(e) {
  69. let that = this;
  70. that.setData({
  71. date: e.detail.value,
  72. })
  73. },
  74. // 时间段选择
  75. bindDateChange2(e) {
  76. let that = this;
  77. that.setData({
  78. date2: e.detail.value,
  79. })
  80. },
  81. //返回
  82. back: function () {
  83. wx.navigateBack({ url: '/pages/home/index' })
  84. },
  85. //跳转页面
  86. backup: function () {
  87. let form = this.data.form;
  88. var team_id = form.team_id;
  89. wx.navigateTo({ url: '/pages/team/apply?id=' + team_id })// 跳转页面
  90. },
  91. /**
  92. * 生命周期函数--监听页面加载
  93. */
  94. onLoad: function (options) {
  95. // 监听用户是否登录
  96. this.watchLogin();
  97. // 计算高度
  98. this.searchHeight()
  99. //跳转传回数据
  100. var myObject = JSON.parse(decodeURIComponent(options.obj));
  101. let forms = {
  102. team_id: myObject.id,
  103. team_name: myObject.name,
  104. apply_time: '2022-03-22',
  105. apply_user: myObject.user,
  106. apply_id: myObject.cid
  107. }
  108. this.setData({
  109. form: forms
  110. });
  111. },
  112. // 监听用户是否登录
  113. watchLogin: function () {
  114. wx.getStorage({
  115. key: 'token',
  116. success: res => {
  117. },
  118. fail: res => {
  119. return wx.redirectTo({ url: '/pages/login/index', })
  120. }
  121. })
  122. },
  123. // 计算高度
  124. searchHeight: function () {
  125. let frameStyle = this.data.frameStyle;
  126. let client = app.globalData.client;
  127. let infoHeight = client.windowHeight;
  128. // 是否去掉状态栏
  129. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  130. // 是否减去底部菜单
  131. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  132. if (infoHeight) this.setData({ infoHeight: infoHeight })
  133. },
  134. /**
  135. * 生命周期函数--监听页面初次渲染完成
  136. */
  137. onReady: function () {
  138. },
  139. /**
  140. * 生命周期函数--监听页面显示
  141. */
  142. onShow: function () {
  143. },
  144. /**
  145. * 生命周期函数--监听页面隐藏
  146. */
  147. onHide: function () {
  148. },
  149. /**
  150. * 生命周期函数--监听页面卸载
  151. */
  152. onUnload: function () {
  153. },
  154. /**
  155. * 页面相关事件处理函数--监听用户下拉动作
  156. */
  157. onPullDownRefresh: function () {
  158. },
  159. /**
  160. * 页面上拉触底事件的处理函数
  161. */
  162. onReachBottom: function () {
  163. },
  164. /**
  165. * 用户点击右上角分享
  166. */
  167. onShareAppMessage: function () {
  168. }
  169. })