dahome.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. xiaziimg: '',
  45. showimg: '',
  46. xialaimg: '',
  47. goods_9: '',
  48. },
  49. onLoad() {
  50. const fileIDs = [
  51. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
  52. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiazi.png',
  53. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/show_1.png',
  54. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiala.png',
  55. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/goods/goods_9.jpg'
  56. ];
  57. // 并发下载多个 fileID
  58. Promise.all(
  59. fileIDs.map(fileID => wx.cloud.downloadFile({ fileID }))
  60. ).then(results => {
  61. // 每个 result 对应一个下载结果
  62. const tempFilePaths = results.map(r => r.tempFilePath);
  63. console.log('全部下载成功:', tempFilePaths);
  64. this.setData({
  65. souimg: tempFilePaths[0],
  66. xiaziimg: tempFilePaths[1],
  67. showimg: tempFilePaths[2],
  68. xialaimg: tempFilePaths[3],
  69. goods_9: tempFilePaths[4],
  70. });
  71. }).catch(err => {
  72. console.error('有文件下载失败:', err);
  73. });
  74. },
  75. handleLevelChange(e) {
  76. this.setData({
  77. selectedLevelIndex: e.detail.value
  78. });
  79. },
  80. handleTypeChange(e) {
  81. this.setData({
  82. selectedTypeIndex: e.detail.value
  83. });
  84. }
  85. })