index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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: '2018-09-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. console.log(res.data);
  43. if (res.data.errcode == 0) {
  44. wx.showToast({ title: `申请加入成功`, icon: 'success', duration: 2000 }) //创建成功提示
  45. wx.navigateTo({ url: '/pages/team/apply?id=' + team_id })// 跳转页面
  46. } else {
  47. wx.showToast({
  48. title: res.data.errmsg,
  49. icon: 'none',
  50. duration: 2000
  51. })
  52. }
  53. }
  54. })
  55. },
  56. // 监听用户是否登录
  57. watchLogin: function () {
  58. wx.getStorage({
  59. key: 'token',
  60. success: res => {
  61. console.log(res);
  62. },
  63. fail: res => {
  64. return wx.redirectTo({ url: '/pages/login/index', })
  65. }
  66. })
  67. },
  68. //日期选择器
  69. bindDateChange3: function (e) {
  70. console.log('picker发送选择改变,携带值为', e.detail.value)
  71. this.setData({
  72. singledate: e.detail.value
  73. })
  74. },
  75. //时间选择器
  76. bindTimeChange: function (e) {
  77. console.log('picker发送选择改变,携带值为', e.detail.value)
  78. this.setData({
  79. time: e.detail.value
  80. })
  81. },
  82. // 时间段选择
  83. bindDateChange(e) {
  84. let that = this;
  85. console.log(e.detail.value)
  86. that.setData({
  87. date: e.detail.value,
  88. })
  89. },
  90. bindDateChange2(e) {
  91. let that = this;
  92. that.setData({
  93. date2: e.detail.value,
  94. })
  95. },
  96. //返回
  97. back: function () {
  98. wx.navigateBack({ url: '/pages/home/index' })
  99. },
  100. //跳转页面
  101. backup: function () {
  102. let form = this.data.form;
  103. var team_id = form.team_id;
  104. wx.navigateTo({ url: '/pages/team/apply?id=' + team_id })// 跳转页面
  105. },
  106. /**
  107. * 生命周期函数--监听页面加载
  108. */
  109. onLoad: function (options) {
  110. // 监听用户是否登录
  111. this.watchLogin();
  112. // 计算高度
  113. this.searchHeight()
  114. var myObject = JSON.parse(decodeURIComponent(options.obj));
  115. let forms = {
  116. team_id: myObject.id,
  117. team_name: myObject.name,
  118. apply_time: '2022-03-22',
  119. apply_user: myObject.user,
  120. apply_id: myObject.cid
  121. }
  122. this.setData({
  123. form: forms
  124. });
  125. },
  126. // 计算高度
  127. searchHeight: function () {
  128. let frameStyle = this.data.frameStyle;
  129. let client = app.globalData.client;
  130. // 减去状态栏
  131. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  132. // 是否减去底部菜单
  133. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  134. if (infoHeight) this.setData({ infoHeight: infoHeight })
  135. },
  136. /**
  137. * 生命周期函数--监听页面初次渲染完成
  138. */
  139. onReady: function () {
  140. },
  141. /**
  142. * 生命周期函数--监听页面显示
  143. */
  144. onShow: function () {
  145. },
  146. /**
  147. * 生命周期函数--监听页面隐藏
  148. */
  149. onHide: function () {
  150. },
  151. /**
  152. * 生命周期函数--监听页面卸载
  153. */
  154. onUnload: function () {
  155. },
  156. /**
  157. * 页面相关事件处理函数--监听用户下拉动作
  158. */
  159. onPullDownRefresh: function () {
  160. },
  161. /**
  162. * 页面上拉触底事件的处理函数
  163. */
  164. onReachBottom: function () {
  165. },
  166. /**
  167. * 用户点击右上角分享
  168. */
  169. onShareAppMessage: function () {
  170. }
  171. })