123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- // subpackages/show/show.js
- import { models, db } from '../../utils/cloudbase.js'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- categoriesindex: 1,
- categories: [],
- courses: [
- {
- videoUrl: 'image/123123.mp4',
- title: '活动名称',
- description: '课程介绍课程介绍课程介绍课程介绍课程介绍课程介绍课程介绍课程介绍'
- },
- {
- videoUrl: '"image/123123.mp4"',
- title: '活动名称',
- description: '课程介绍课程介绍课程介绍课程介绍课程介绍课程介绍课程介绍课程介绍'
- },
- {
- videoUrl: '"image/123123.mp4"',
- title: '活动名称',
- description: '课程介绍课程介绍课程介绍课程介绍课程介绍课程介绍课程介绍课程介绍'
- }
- ],
- sou: '',
- show_1: '',
- xiazi: '',
- url: '',
- pdfurl: '',
- ppturl: '',
- audioUrl: '',
- carousel: ''
- },
- onLoad(options) {
- // 获取tab数据
- this.getTabdata();
- const type = Number(options.type) || 1;
- console.log('收到的 type 参数:', type);
- // 根据 type 加载数据
- this.setData({
- categoriesindex: type
- });
- const fileIDs = [
- 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.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/123123.mp4',
- 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/硬盘发票.pdf',
- 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/newfile.ppt',
- 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/许嵩 - 有何不可.mp3',
- 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/banner/carousel_1.jpg'
- ];
-
- // 并发下载多个 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({
- sou: tempFilePaths[0],
- show_1: tempFilePaths[1],
- xiazi: tempFilePaths[2],
- url: tempFilePaths[3],
- pdfurl: tempFilePaths[4],
- ppturl: tempFilePaths[5],
- audioUrl: tempFilePaths[6],
- carousel: tempFilePaths[7]
- });
- }).catch(err => {
- console.error('有文件下载失败:', err);
- });
- },
- // tab数据
- async getTabdata() {
- const { data } = await models.tab.list({
- filter: {
- where: {
- position: 3, // 显示位置
- // layout_type: 0, // 布局类型
- },
- },
- // envType: pre 体验环境, prod 正式环境
- envType: "prod",
- });
-
- // 返回查询到的数据
- console.log(data);
- const sortedRecords = data.records.sort((a, b) => {
- return a.sort - b.sort; // 升序排列
- });
- this.setData({
- categories: sortedRecords
- })
- },
- tabcategories(e) {
- const type = e.currentTarget.dataset.type;
- this.setData({
- categoriesindex: type
- });
- },
- previewPDF() {
- wx.openDocument({
- filePath: this.data.ppturl,
- fileType: 'ppt',
- success(res) {
- console.log('打开 PDF 成功');
- },
- fail(err) {
- console.error('打开 PDF 失败', err);
- }
- });
- }
- })
|