|
@@ -1,4 +1,5 @@
|
|
// subpackages/course/course.js
|
|
// subpackages/course/course.js
|
|
|
|
+import { models, db } from '../../utils/cloudbase.js'
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -6,39 +7,29 @@ Page({
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
categoriesindex: 1,
|
|
categoriesindex: 1,
|
|
- categories: [
|
|
|
|
- {
|
|
|
|
- title: '阅读',
|
|
|
|
- type: 1,
|
|
|
|
- },{
|
|
|
|
- title: '思维',
|
|
|
|
- type: 2,
|
|
|
|
- },{
|
|
|
|
- title: '动手动脑',
|
|
|
|
- type: 3,
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
|
|
+ categories: [],
|
|
viewType: 'grid',
|
|
viewType: 'grid',
|
|
courseList: [
|
|
courseList: [
|
|
- { id: 1, title: '趣味识字 – 动物世界', type: 'PDF', grade: '小班', subject: '语文', views: 128 },
|
|
|
|
- { id: 2, title: '数字王国探险记', type: '视频', grade: '中班', subject: '数学', views: 128 },
|
|
|
|
- { id: 3, title: '儿歌大全 – 春天在哪里', type: '音频', grade: '大班', subject: '音乐', views: 128 },
|
|
|
|
- { id: 4, title: '创意绘画 – 我的小房子', type: 'PPT', grade: '中班', subject: '美术', views: 128 }
|
|
|
|
|
|
+ // { id: 1, title: '趣味识字 – 动物世界', type: 'PDF', grade: '小班', subject: '语文', views: 128 },
|
|
|
|
+ // { id: 2, title: '数字王国探险记', type: '视频', grade: '中班', subject: '数学', views: 128 },
|
|
|
|
+ // { id: 3, title: '儿歌大全 – 春天在哪里', type: '音频', grade: '大班', subject: '音乐', views: 128 },
|
|
|
|
+ // { id: 4, title: '创意绘画 – 我的小房子', type: 'PPT', grade: '中班', subject: '美术', views: 128 }
|
|
],
|
|
],
|
|
sou: '',
|
|
sou: '',
|
|
show_1: '',
|
|
show_1: '',
|
|
xiazi: '',
|
|
xiazi: '',
|
|
goods_9: '',
|
|
goods_9: '',
|
|
|
|
+ categorieslist: {}
|
|
},
|
|
},
|
|
|
|
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
- const type = Number(options.type) || 1;
|
|
|
|
- console.log('收到的 type 参数:', type);
|
|
|
|
- // 根据 type 加载数据
|
|
|
|
- this.setData({
|
|
|
|
- categoriesindex: type
|
|
|
|
- });
|
|
|
|
|
|
+ // 存储 options 到 this 中
|
|
|
|
+ this.options = options;
|
|
|
|
|
|
|
|
+ // 获取tab数据
|
|
|
|
+ this.getTabdata();
|
|
|
|
+
|
|
|
|
+ // 获取图片
|
|
const fileIDs = [
|
|
const fileIDs = [
|
|
'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
|
|
'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/show_1.png',
|
|
@@ -65,8 +56,69 @@ Page({
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // tab数据 async
|
|
|
|
+ async getTabdata() {
|
|
|
|
+ const { data } = await models.tab.list({
|
|
|
|
+ filter: {
|
|
|
|
+ where: {
|
|
|
|
+ position: 0, // 显示位置
|
|
|
|
+ // 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
|
|
|
|
+ }, () => {
|
|
|
|
+ // 在 setData 回调中执行逻辑,确保 categories 已经更新
|
|
|
|
+ const type = Number(this.options.type) || 1;
|
|
|
|
+ this.data.categories.forEach((item, index) => {
|
|
|
|
+ if (item.sort === type) {
|
|
|
|
+ this.setData({
|
|
|
|
+ categorieslist: item,
|
|
|
|
+ categoriesindex: type
|
|
|
|
+ });
|
|
|
|
+ // 获取列表数据
|
|
|
|
+ this.getdatalist()
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 列表数据
|
|
|
|
+ async getdatalist() {
|
|
|
|
+ console.log(this.data.categorieslist, '123123');
|
|
|
|
+ const { data } = await models.file_manage.list({
|
|
|
|
+ filter: {
|
|
|
|
+ where: {
|
|
|
|
+ tag_id: this.data.categorieslist._id,
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ pageSize: 10, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效
|
|
|
|
+ pageNumber: 1, // 第几页
|
|
|
|
+ getCount: true, // 开启用来获取总数
|
|
|
|
+ // envType: pre 体验环境, prod 正式环境
|
|
|
|
+ envType: "prod",
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 返回查询到的数据列表 records 和 总数 total
|
|
|
|
+ console.log(data, '123123');
|
|
|
|
+ this.setData({
|
|
|
|
+ courseList: data.records
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // async
|
|
tabcategories(e) {
|
|
tabcategories(e) {
|
|
- const type = e.currentTarget.dataset.type;
|
|
|
|
|
|
+ const types = e.currentTarget.dataset.type;
|
|
|
|
|
|
// if (type === 2) {
|
|
// if (type === 2) {
|
|
// this.setData({ viewType: 'list' });
|
|
// this.setData({ viewType: 'list' });
|
|
@@ -75,13 +127,52 @@ Page({
|
|
// }
|
|
// }
|
|
|
|
|
|
this.setData({
|
|
this.setData({
|
|
- categoriesindex: type
|
|
|
|
|
|
+ categoriesindex: types
|
|
|
|
+ }, () => {
|
|
|
|
+ // 在 setData 回调中执行逻辑,确保 categories 已经更新
|
|
|
|
+ const type = Number(types) || 1;
|
|
|
|
+ this.data.categories.forEach((item, index) => {
|
|
|
|
+ if (item.sort === type) {
|
|
|
|
+ this.setData({
|
|
|
|
+ categorieslist: item,
|
|
|
|
+ categoriesindex: type
|
|
|
|
+ });
|
|
|
|
+ // 获取列表数据
|
|
|
|
+ this.getdatalist()
|
|
|
|
+ }
|
|
|
|
+ });
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ // const { data } = await models.file_manage.create({
|
|
|
|
+ // data: {
|
|
|
|
+ // level: 1, // 级别
|
|
|
|
+ // range: ['中班'], // 适用范围
|
|
|
|
+ // remark: "备注文本字段", // 备注
|
|
|
|
+ // type: 3, // 文件类型 0-视频 1-音频 2-pdf 3-ppt 4-图文
|
|
|
|
+ // url: ['cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/newfile.ppt'], // 路径
|
|
|
|
+ // download_count: 1, // 下载人数
|
|
|
|
+ // dan: 0, // 段位
|
|
|
|
+ // cover: "cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/未命名的设计.png", // 封面
|
|
|
|
+ // size: "123.12KB", // 文件大小
|
|
|
|
+ // name: "PPT-文件名33", // 文件名
|
|
|
|
+ // tag_id: "BT6QJSE5RS", // 标签id
|
|
|
|
+ // describe: "描述文本字段", // 描述
|
|
|
|
+ // },
|
|
|
|
+ // // envType: pre 体验环境, prod 正式环境
|
|
|
|
+ // envType: "prod",
|
|
|
|
+ // });
|
|
|
|
+
|
|
|
|
+ // // 返回创建的数据 id
|
|
|
|
+ // console.log(data, '234234');
|
|
},
|
|
},
|
|
|
|
|
|
- goToGoodsList() {
|
|
|
|
|
|
+ goToGoodsList(event) {
|
|
|
|
+ // 获取绑定的数据
|
|
|
|
+ const item = event.currentTarget.dataset.item;
|
|
|
|
+ // 将数据转换为 JSON 字符串并传递
|
|
|
|
+ const itemStr = encodeURIComponent(JSON.stringify(item));
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
- url: '/subpackagestow/details/details'
|
|
|
|
|
|
+ url: `/subpackagestow/details/details?item=${itemStr}`
|
|
});
|
|
});
|
|
}
|
|
}
|
|
})
|
|
})
|