collect.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. Page({
  2. data: {
  3. role: "teacher",
  4. historyList: [
  5. {
  6. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  7. title: '趣味识字卡片',
  8. date: '2023-10-15 14:30',
  9. checked: false
  10. },
  11. {
  12. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  13. title: '趣味识字卡片',
  14. date: '2023-10-15 14:30',
  15. checked: false
  16. },
  17. {
  18. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  19. title: '趣味识字卡片',
  20. date: '2023-10-15 14:30',
  21. checked: false
  22. },
  23. {
  24. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  25. title: '趣味识字卡片',
  26. date: '2023-10-15 14:30',
  27. checked: false
  28. },
  29. {
  30. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  31. title: '趣味识字卡片',
  32. date: '2023-10-15 14:30',
  33. checked: false
  34. },
  35. {
  36. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  37. title: '趣味识字卡片',
  38. date: '2023-10-15 14:30',
  39. checked: false
  40. },
  41. {
  42. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  43. title: '趣味识字卡片',
  44. date: '2023-10-15 14:30',
  45. checked: false
  46. },
  47. {
  48. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  49. title: '趣味识字卡片',
  50. date: '2023-10-15 14:30',
  51. checked: false
  52. },
  53. {
  54. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  55. title: '趣味识字卡片',
  56. date: '2023-10-15 14:30',
  57. checked: false
  58. },
  59. {
  60. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  61. title: '趣味识字卡片',
  62. date: '2023-10-15 14:30',
  63. checked: false
  64. },
  65. // 其他列表项...
  66. ],
  67. isManaging: false,
  68. souchangs: '',
  69. },
  70. onLoad(options) {
  71. // 页面加载时的初始化操作
  72. const fileIDs = [
  73. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/soucangs.png'
  74. ];
  75. // 并发下载多个 fileID
  76. Promise.all(
  77. fileIDs.map(fileID => wx.cloud.downloadFile({ fileID }))
  78. ).then(results => {
  79. // 每个 result 对应一个下载结果
  80. const tempFilePaths = results.map(r => r.tempFilePath);
  81. console.log('全部下载成功:', tempFilePaths);
  82. this.setData({
  83. souchangs: tempFilePaths[0],
  84. });
  85. }).catch(err => {
  86. console.error('有文件下载失败:', err);
  87. });
  88. },
  89. onReachBottom() {
  90. // 上拉触底事件的处理函数
  91. this.loadMore();
  92. },
  93. loadMore() {
  94. // 加载更多数据的逻辑
  95. console.log('加载更多');
  96. },
  97. toggleManageMode() {
  98. const { isManaging, historyList } = this.data;
  99. if (isManaging) {
  100. if (historyList && historyList.length > 0) {
  101. historyList.forEach(item => item.checked = false);
  102. }
  103. this.setData({ isManaging: false });
  104. } else {
  105. this.setData({ isManaging: true });
  106. }
  107. },
  108. selectAll() {
  109. const { historyList } = this.data;
  110. if (historyList && historyList.length > 0) {
  111. const allChecked = historyList.every(item => item.checked);
  112. historyList.forEach(item => item.checked = !allChecked);
  113. this.setData({ historyList });
  114. }
  115. },
  116. deleteItems() {
  117. const { historyList } = this.data;
  118. if (historyList && historyList.length > 0) {
  119. const newList = historyList.filter(item => !item.checked);
  120. this.setData({ historyList: newList });
  121. }
  122. }
  123. });