detail.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. src: '/image/detail.jpg',
  11. src1: '/image/head1.png',
  12. // 上传图片
  13. fileList: [],
  14. // 主体高度
  15. infoHeight: '',
  16. id: '',
  17. schedulelist: []
  18. },
  19. //上传图片
  20. imgUpload: function (e) {
  21. const that = this;
  22. let data = that.data.fileList;
  23. data.push(e.detail)
  24. that.setData({ fileList: data })
  25. },
  26. //删除图片
  27. imgDel: function (e) {
  28. const that = this;
  29. let data = that.data.fileList;
  30. let arr = data.filter((i, index) => index != e.detail.index)
  31. that.setData({ fileList: arr })
  32. },
  33. back: function () {
  34. wx.navigateBack({ url: '/pages/home/index' })
  35. },
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */
  39. onLoad: function (options) {
  40. const that = this;
  41. that.setData({ id: options.id })
  42. // 计算高度
  43. this.searchHeight()
  44. // 监听用户是否登录
  45. this.watchLogin();
  46. },
  47. // 监听用户是否登录
  48. watchLogin: function () {
  49. const that = this;
  50. let id = that.data.id;
  51. wx.getStorage({
  52. key: 'token',
  53. success: res => {
  54. wx.request({
  55. url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
  56. method: 'get',
  57. data: {},
  58. success(res) {
  59. that.setData({
  60. schedulelist: res.data.data,
  61. })
  62. }
  63. })
  64. },
  65. fail: res => {
  66. return wx.redirectTo({ url: '/pages/login/index', })
  67. }
  68. })
  69. },
  70. // 计算高度
  71. searchHeight: function () {
  72. let frameStyle = this.data.frameStyle;
  73. let client = app.globalData.client;
  74. // 减去状态栏
  75. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  76. // 是否减去底部菜单
  77. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  78. if (infoHeight) this.setData({ infoHeight: infoHeight })
  79. },
  80. /**
  81. * 生命周期函数--监听页面初次渲染完成
  82. */
  83. onReady: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面显示
  87. */
  88. onShow: function () {
  89. },
  90. /**
  91. * 生命周期函数--监听页面隐藏
  92. */
  93. onHide: function () {
  94. },
  95. /**
  96. * 生命周期函数--监听页面卸载
  97. */
  98. onUnload: function () {
  99. },
  100. /**
  101. * 页面相关事件处理函数--监听用户下拉动作
  102. */
  103. onPullDownRefresh: function () {
  104. },
  105. /**
  106. * 页面上拉触底事件的处理函数
  107. */
  108. onReachBottom: function () {
  109. },
  110. /**
  111. * 用户点击右上角分享
  112. */
  113. onShareAppMessage: function () {
  114. }
  115. })