index.js 3.1 KB

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