index.js 3.6 KB

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