index.js 4.2 KB

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