image.js 897 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. Page({
  2. onShareAppMessage() {
  3. return {
  4. title: 'image',
  5. path: 'packageComponent/pages/media/image/image'
  6. }
  7. },
  8. onLoad() {
  9. this.setData({
  10. theme: wx.getSystemInfoSync().theme || 'light'
  11. })
  12. if (wx.onThemeChange) {
  13. wx.onThemeChange(({theme}) => {
  14. this.setData({theme})
  15. })
  16. }
  17. wx.cloud.getTempFileURL({
  18. fileList: [{
  19. fileID: 'cloud://release-b86096.7265-release-b86096-1258211818/开发者社区.webp',
  20. maxAge: 60 * 60,
  21. }]
  22. }).then(res => {
  23. console.log(res)
  24. this.setData({
  25. webpImageUrl: res.fileList[0].tempFileURL
  26. })
  27. return res
  28. }).catch(error => {
  29. console.log('CLOUD:image 临时链接获取失败', error)
  30. })
  31. },
  32. data: {
  33. theme: 'light',
  34. imageUrl: 'cloud://release-b86096.7265-release-b86096-1258211818/demo.jpg',
  35. webpImageURL: '',
  36. }
  37. })