index.js 3.5 KB

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