import { models, db } from '../../utils/cloudbase.js' Page({ data: { categoriesindex: 1, categories: [], goods: [ { image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500', title: '儿童大颗粒积木 安全无毒 益智玩具', price: '68.00', originalPrice: '88.00', sold: 256 }, { image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500', title: '幼儿启蒙绘本 10册套装', price: '68.00', originalPrice: '88.00', sold: 256 }, { image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500', title: '防摔儿童保温水杯 350ml', price: '68.00', originalPrice: '88.00', sold: 256 }, { image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500', title: '可水洗儿童彩笔24色套装', price: '68.00', originalPrice: '88.00', sold: 256 } ], sou: '', // show_1: '', // xiazi: '', }, onLoad(options) { // 获取tab数据 this.getTabdata(); // const title = options.title ? decodeURIComponent(options.title) : '商品列表'; // this.setData({ title }); // wx.setNavigationBarTitle({ title }); 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', ]; // 并发下载多个 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], }); }).catch(err => { console.error('有文件下载失败:', err); }); }, // tab数据 async getTabdata() { const { data } = await models.tab.list({ filter: { where: { position: 4, // 显示位置 // 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 }); }, navigateToDetail(e) { const index = e.currentTarget.dataset.index; const item = this.data.goods[index]; wx.navigateTo({ url: '/subpackages/productdetails/productdetails?data=' + encodeURIComponent(JSON.stringify(item)) }); console.log('走进来了'); } });