123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- // 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}`
- });
- }
- })
|