detail.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. src: '/image/detail.jpg',
  10. src1: '/image/head1.png',
  11. // 上传图片
  12. fileList: [],
  13. frameStyle: { useTop: true, name: '比赛信息', leftArrow: true, useBar: false },
  14. // 主体高度
  15. infoHeight: '',
  16. listb: [
  17. {
  18. time: '1-15 15:00',
  19. ranks1: '哈拉海队幼儿园组',
  20. score1: '2',
  21. score2: '1',
  22. ranks2: '马尼拉老年组',
  23. state: '未开始'
  24. }
  25. ],
  26. lists: [
  27. {
  28. id: '1', name: '老头1', head: '/image/tou.png'
  29. },
  30. {
  31. id: '1', name: '老头2', head: '/image/tou.png'
  32. },
  33. {
  34. id: '1', name: '老头3', head: '/image/tou.png'
  35. },
  36. {
  37. id: '1', name: '老头4', head: '/image/tou.png'
  38. },
  39. {
  40. id: '1', name: '老头5', head: '/image/tou.png'
  41. }
  42. ],
  43. list: [
  44. {
  45. id: '1', name: '老头1', head: '/image/tou.png'
  46. },
  47. {
  48. id: '1', name: '老头2', head: '/image/tou.png'
  49. },
  50. {
  51. id: '1', name: '老头3', head: '/image/tou.png'
  52. },
  53. {
  54. id: '1', name: '老头4', head: '/image/tou.png'
  55. },
  56. {
  57. id: '1', name: '老头5', head: '/image/tou.png'
  58. },
  59. {
  60. id: '1', name: '老头6', head: '/image/tou.png'
  61. },
  62. {
  63. id: '1', name: '老头7', head: '/image/tou.png'
  64. },
  65. {
  66. id: '1', name: '老头8', head: '/image/tou.png'
  67. },
  68. {
  69. id: '1', name: '老头9', head: '/image/tou.png'
  70. },
  71. {
  72. id: '1', name: '老头10', head: '/image/tou.png'
  73. }
  74. ],
  75. },
  76. //上传图片
  77. afterRead: function (event) {
  78. const { file } = event.detail;
  79. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式app.globalData.fileUrl:
  80. console.log(file);
  81. wx.uploadFile({
  82. url: `${app.globalData.imageUrl}/files/court/elimg/upload`,
  83. filePath: file.url,
  84. name: 'file',
  85. formData: {},
  86. success: (res) => {
  87. console.log(res);
  88. if (res.statusCode == '200') {
  89. let data = [{ name: JSON.parse(res.data).name, url: `${app.globalData.imageUrl}` + JSON.parse(res.data).uri }]
  90. const { fileList = [] } = this.data;
  91. fileList.push({ ...file, url: res.data });
  92. this.setData({ fileList });
  93. } else {
  94. wx.showToast({ title: `${res.data.errmsg}`, icon: 'fail', duration: 2000 })
  95. }
  96. },
  97. });
  98. },
  99. back: function () {
  100. wx.navigateBack({ url: '/pages/home/index' })
  101. },
  102. /**
  103. * 生命周期函数--监听页面加载
  104. */
  105. onLoad: function (options) {
  106. // 计算高度
  107. this.searchHeight()
  108. },
  109. // 计算高度
  110. searchHeight: function () {
  111. let frameStyle = this.data.frameStyle;
  112. let client = app.globalData.client;
  113. // 减去状态栏
  114. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  115. // 是否减去底部菜单
  116. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  117. if (infoHeight) this.setData({ infoHeight: infoHeight })
  118. },
  119. /**
  120. * 生命周期函数--监听页面初次渲染完成
  121. */
  122. onReady: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面显示
  126. */
  127. onShow: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面隐藏
  131. */
  132. onHide: function () {
  133. },
  134. /**
  135. * 生命周期函数--监听页面卸载
  136. */
  137. onUnload: function () {
  138. },
  139. /**
  140. * 页面相关事件处理函数--监听用户下拉动作
  141. */
  142. onPullDownRefresh: function () {
  143. },
  144. /**
  145. * 页面上拉触底事件的处理函数
  146. */
  147. onReachBottom: function () {
  148. },
  149. /**
  150. * 用户点击右上角分享
  151. */
  152. onShareAppMessage: function () {
  153. }
  154. })