index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. console.log(file);
  71. wx.uploadFile({
  72. url: `${app.globalData.imageUrl}/files/court/elimg/upload`,
  73. filePath: file.url,
  74. name: 'file',
  75. formData: {},
  76. success: (res) => {
  77. console.log(res);
  78. if (res.statusCode == '200') {
  79. let data = [{ name: JSON.parse(res.data).name, url: `${app.globalData.imageUrl}` + JSON.parse(res.data).uri }]
  80. const { fileList = [] } = this.data;
  81. fileList.push({ ...file, url: res.data });
  82. this.setData({ fileList });
  83. } else {
  84. wx.showToast({ title: `${res.data.errmsg}`, icon: 'fail', duration: 2000 })
  85. }
  86. },
  87. });
  88. },
  89. back: function () {
  90. wx.navigateBack({ url: '/pages/home/index' })
  91. },
  92. /**
  93. * 生命周期函数--监听页面加载
  94. */
  95. onLoad: function (options) {
  96. // 计算高度
  97. this.searchHeight()
  98. },
  99. // 计算高度
  100. searchHeight: function () {
  101. let frameStyle = this.data.frameStyle;
  102. let client = app.globalData.client;
  103. // 减去状态栏
  104. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  105. // 是否减去底部菜单
  106. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  107. if (infoHeight) this.setData({ infoHeight: infoHeight })
  108. },
  109. /**
  110. * 生命周期函数--监听页面初次渲染完成
  111. */
  112. onReady: function () {
  113. },
  114. /**
  115. * 生命周期函数--监听页面显示
  116. */
  117. onShow: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面隐藏
  121. */
  122. onHide: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面卸载
  126. */
  127. onUnload: function () {
  128. },
  129. /**
  130. * 页面相关事件处理函数--监听用户下拉动作
  131. */
  132. onPullDownRefresh: function () {
  133. },
  134. /**
  135. * 页面上拉触底事件的处理函数
  136. */
  137. onReachBottom: function () {
  138. },
  139. /**
  140. * 用户点击右上角分享
  141. */
  142. onShareAppMessage: function () {
  143. }
  144. })