imghome.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // subpackages/dahome/dahome.js
  2. Page({
  3. data: {
  4. // levelOptions: ['初级', '中级', '高级'],
  5. // selectedLevelIndex: 0,
  6. typeOptions: ['1段', '2段', '3段'],
  7. selectedTypeIndex: 0,
  8. items: [
  9. {
  10. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  11. title: '全脑智能开发答案',
  12. subtitle: '初级1',
  13. downloadCount: 128
  14. },
  15. {
  16. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  17. title: '全脑智能开发答案',
  18. subtitle: '初级1',
  19. downloadCount: 128
  20. },
  21. {
  22. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  23. title: '全脑智能开发答案',
  24. subtitle: '初级1',
  25. downloadCount: 128
  26. },{
  27. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  28. title: '全脑智能开发答案',
  29. subtitle: '初级1',
  30. downloadCount: 128
  31. },{
  32. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  33. title: '全脑智能开发答案',
  34. subtitle: '初级1',
  35. downloadCount: 128
  36. },{
  37. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  38. title: '全脑智能开发答案',
  39. subtitle: '初级1',
  40. downloadCount: 128
  41. },
  42. ],
  43. souimg: '',
  44. xialaimg: '',
  45. goods_9: '',
  46. },
  47. onLoad() {
  48. const fileIDs = [
  49. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
  50. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiala.png',
  51. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/goods/goods_9.jpg'
  52. ];
  53. // 并发下载多个 fileID
  54. Promise.all(
  55. fileIDs.map(fileID => wx.cloud.downloadFile({ fileID }))
  56. ).then(results => {
  57. // 每个 result 对应一个下载结果
  58. const tempFilePaths = results.map(r => r.tempFilePath);
  59. console.log('全部下载成功:', tempFilePaths);
  60. this.setData({
  61. souimg: tempFilePaths[0],
  62. xialaimg: tempFilePaths[1],
  63. goods_9: tempFilePaths[2],
  64. });
  65. }).catch(err => {
  66. console.error('有文件下载失败:', err);
  67. });
  68. },
  69. // handleLevelChange(e) {
  70. // this.setData({
  71. // selectedLevelIndex: e.detail.value
  72. // });
  73. // },
  74. handleTypeChange(e) {
  75. this.setData({
  76. selectedTypeIndex: e.detail.value
  77. });
  78. }
  79. })