// subpackagestow/details/details.js import { models, db, _ } from '../../utils/cloudbase.js' Page({ /** * 页面的初始数据 */ data: { fileType: 'video', viewType: 'grid', courseList: [], shouchang: '', show_1: '', xiazi: '', xia: '', itemlist: {} }, onLoad(options) { // 获取传递过来的数据 const itemStr = decodeURIComponent(options.item); const item = JSON.parse(itemStr); // 设置到页面数据中 this.setData({ itemlist: item }, () => { // 相关推荐 this.getcourseList() }); // 获取图片 const fileIDs = [ 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/shouchang.png', 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/show_1.png', 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xiazi.png', 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/xia_1.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({ shouchang: tempFilePaths[0], show_1: tempFilePaths[1], xiazi: tempFilePaths[2], xia: tempFilePaths[3], }); }).catch(err => { console.error('有文件下载失败:', err); }); }, // 相关课件推荐 async getcourseList() { console.log(this.data.itemlist.range, 'this.data.itemlist.range'); const { data } = await models.file_manage.list({ filter: { where: { range: db.command.in(['小班', '中班']), tag_id: this.data.itemlist.tag_id } }, // envType: pre 体验环境, prod 正式环境 envType: "prod", }); // 返回查询到的数据列表 records 和 总数 total console.log(data); this.setData({ courseList: data.records }) }, goToGoodsLists(event) { // 获取绑定的数据 const item = event.currentTarget.dataset.item; // 将数据转换为 JSON 字符串并传递 const itemStr = encodeURIComponent(JSON.stringify(item)); wx.navigateTo({ url: `/subpackagestow/down/down?item=${itemStr}` }); }, goToGoodsList(event) { // 获取绑定的数据 const item = event.currentTarget.dataset.item; // 将数据转换为 JSON 字符串并传递 const itemStr = encodeURIComponent(JSON.stringify(item)); wx.navigateTo({ url: `/subpackagestow/details/details?item=${itemStr}` }); } })