index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. showModal: false,
  10. // 主体高度
  11. infoHeight: '',
  12. frameStyle: { useTop: true, name: '比赛信息', leftArrow: true, useBar: false },
  13. form: {},
  14. id: ''
  15. },
  16. back: function () {
  17. wx.navigateBack({ url: '/pages/me/index' })
  18. },
  19. //显示对话框
  20. clickme: function () {
  21. this.setData({
  22. showModal: true
  23. })
  24. },
  25. preventTouchMove: function () {
  26. },
  27. //关闭弹窗
  28. go: function () {
  29. this.setData({
  30. showModal: false
  31. })
  32. },
  33. //提交
  34. formSubmit: function (e) {
  35. let value = e.detail.value;
  36. let id = this.data.id;
  37. wx.request({
  38. url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`,
  39. method: "post",
  40. data: value,
  41. header: {},
  42. success: res => {
  43. wx.showToast({
  44. title: '上传比分成功',
  45. icon: 'success',
  46. duration: 2000
  47. })
  48. this.setData({ showModal: false })
  49. },
  50. error: err => {
  51. }
  52. })
  53. },
  54. /**
  55. * 生命周期函数--监听页面加载
  56. */
  57. onLoad: function (options) {
  58. this.setData({ id: options.id })
  59. // 计算高度
  60. this.searchHeight()
  61. // 监听用户是否登录
  62. this.watchLogin();
  63. },
  64. // 监听用户是否登录
  65. watchLogin: function () {
  66. const that = this;
  67. let id = that.data.id;
  68. wx.getStorage({
  69. key: 'token',
  70. success: res => {
  71. wx.request({
  72. url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`,
  73. method: "get",
  74. data: {},
  75. header: {},
  76. success: res => {
  77. console.log(res.data.data);
  78. that.setData({ match: res.data.data })
  79. },
  80. error: err => {
  81. }
  82. })
  83. },
  84. fail: res => {
  85. wx.redirectTo({ url: '/pages/login/index', })
  86. }
  87. })
  88. },
  89. // 计算高度
  90. searchHeight: function () {
  91. let frameStyle = this.data.frameStyle;
  92. let client = app.globalData.client;
  93. let infoHeight = client.windowHeight;
  94. // 是否去掉状态栏
  95. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  96. // 是否减去底部菜单
  97. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  98. if (infoHeight) this.setData({ infoHeight: infoHeight })
  99. },
  100. /**
  101. * 生命周期函数--监听页面初次渲染完成
  102. */
  103. onReady: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面显示
  107. */
  108. onShow: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload: function () {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh: function () {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom: function () {
  129. },
  130. /**
  131. * 用户点击右上角分享
  132. */
  133. onShareAppMessage: function () {
  134. }
  135. })