index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // commpents/mobile-frame/mobile-main.js
  2. const app = getApp()
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. options: { multipleSlots: true },
  8. properties: {
  9. list: { type: 'array', value: [] },
  10. count: { type: Number, value: 1 }
  11. },
  12. // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  13. attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
  14. ready: function () { },
  15. pageLifetimes: {
  16. // 组件所在页面的生命周期函数
  17. show: function () { },
  18. hide: function () { },
  19. resize: function () { },
  20. },
  21. /**
  22. * 组件的初始数据
  23. */
  24. data: {
  25. },
  26. /**
  27. * 组件的方法列表
  28. */
  29. methods: {
  30. // 图片上传
  31. imgUpload(event) {
  32. const { file } = event.detail;
  33. wx.uploadFile({
  34. url: `${app.globalData.imageUrl}/files/court/elimg/upload`,
  35. filePath: file.url,
  36. name: 'file',
  37. formData: {},
  38. success: (res) => {
  39. let arr = JSON.parse(res.data);
  40. if (res.statusCode == 200) {
  41. this.triggerEvent('imgUpload', { name: arr.name, url: `${app.globalData.imageUrl}` + arr.uri, uri: arr.uri })
  42. } else {
  43. wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 })
  44. }
  45. }
  46. })
  47. },
  48. // 图片删除
  49. imgDel(e) {
  50. this.triggerEvent('imgDel', { file: e.detail.file, index: e.detail.index })
  51. }
  52. }
  53. })