1234567891011121314151617181920212223242526272829303132333435363738394041 |
- // subpackagestow/down/down.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- fuzhi: '',
- itemlist: {},
- },
- onLoad(options) {
- // 获取传递过来的数据
- const itemStr = decodeURIComponent(options.item);
- const item = JSON.parse(itemStr);
- // 设置到页面数据中
- this.setData({
- itemlist: item
- });
- const fileIDs = [
- 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/fuzhi.png',
- ];
-
- // 并发下载多个 fileID
- Promise.all(
- fileIDs.map(fileID => wx.cloud.downloadFile({ fileID }))
- ).then(results => {
- // 每个 result 对应一个下载结果
- const tempFilePaths = results.map(r => r.tempFilePath);
- console.log('全部下载成功:', tempFilePaths);
- this.setData({
- fuzhi: tempFilePaths[0],
- });
- }).catch(err => {
- console.error('有文件下载失败:', err);
- });
- },
- })
|