|
@@ -1,8 +1,9 @@
|
|
|
-import APIClient from '../../../util/API/APIClient'
|
|
|
-import Consts from '../../../util/Consts'
|
|
|
-import CourseItem from '../../../component/CourseItem'
|
|
|
-import GoodsItem from '../../../component/GoodsItem'
|
|
|
-import ScrollEventPlugin from '../../../util/ScrollEventPlugin'
|
|
|
+import APIClient from '../../../util/API/APIClient';
|
|
|
+import Consts from '../../../util/Consts';
|
|
|
+import CourseItem from '../../../component/CourseItem';
|
|
|
+import TrainingItem from '../../../component/TrainingItem';
|
|
|
+import GoodsItem from '../../../component/GoodsItem';
|
|
|
+import ScrollEventPlugin from '../../../util/ScrollEventPlugin';
|
|
|
import ShopCartState from '../../../util/ShopCartState';
|
|
|
import NotificationCenter from '../../../util/NotificationCenter';
|
|
|
|
|
@@ -15,6 +16,7 @@ class CLScene extends scene {
|
|
|
this.hasNextPage = false;
|
|
|
this.currentIndex = 1;
|
|
|
this.noContent = false;
|
|
|
+ this.trainingMap = {};
|
|
|
}
|
|
|
|
|
|
renderLeftTagList(dataset) {
|
|
@@ -46,15 +48,30 @@ class CLScene extends scene {
|
|
|
document.getElementById('no-content-message').style.display = this.noContent ? '' : 'none';
|
|
|
|
|
|
for (let i in dataset) {
|
|
|
- const { id, title, subTitle, coverUrl, auth, goods } = dataset[i];
|
|
|
+ const { id, title, subTitle, coverUrl, auth, goods, imgList, redDot, openTime, closeTime, dateDesc } = dataset[i];
|
|
|
let price = '';
|
|
|
if (goods && goods.length >= 1) {
|
|
|
price = goods[0].terminalPrice;
|
|
|
}
|
|
|
|
|
|
+ // 师训详情图片预加载
|
|
|
+ this.trainingMap[id] = imgList;
|
|
|
+ if (imgList) {
|
|
|
+ for (let index in imgList) {
|
|
|
+ let imgSrc = Consts.IMG_PATH + '/' + imgList[index];
|
|
|
+ let image = new Image();
|
|
|
+ image.src = imgSrc;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let item = document.createElement('li');
|
|
|
+ // 为training item 添加不同样式
|
|
|
+ if (this.sceneType == 'training') {
|
|
|
+ item.setAttribute('class', 'training-item');
|
|
|
+ } else {
|
|
|
+ item.setAttribute('class', 'item');
|
|
|
+ }
|
|
|
item.setAttribute('id', `item-${id}`);
|
|
|
- item.setAttribute('class', 'item');
|
|
|
item.setAttribute('fe-role', 'Widget');
|
|
|
|
|
|
if (0 == i) {
|
|
@@ -68,14 +85,21 @@ class CLScene extends scene {
|
|
|
title,
|
|
|
price,
|
|
|
correlative: subTitle,
|
|
|
- img: Consts.IMG_PATH + '/' + coverUrl
|
|
|
+ img: Consts.IMG_PATH + '/' + coverUrl,
|
|
|
}
|
|
|
+ } else if (this.sceneType == 'training') {
|
|
|
+ itemDataset = {
|
|
|
+ subject: title || '',
|
|
|
+ subjectSub: dateDesc || '',
|
|
|
+ isNew: redDot ? true : false,
|
|
|
+ img: Consts.IMG_PATH + '/' + coverUrl,
|
|
|
+ };
|
|
|
} else {
|
|
|
itemDataset = {
|
|
|
subject: title,
|
|
|
subjectSub: subTitle,
|
|
|
buyed: auth,
|
|
|
- img: Consts.IMG_PATH+ '/' + coverUrl
|
|
|
+ img: Consts.IMG_PATH+ '/' + coverUrl,
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -97,6 +121,8 @@ class CLScene extends scene {
|
|
|
this.loadPeripheryList(this.selectedTagId, 1);
|
|
|
} else if (this.sceneType == 'collection') {
|
|
|
this.loadCollectionList(this.selectedTagId, 1);
|
|
|
+ } else if (this.sceneType == 'training') {
|
|
|
+ this.loadTrainingList(this.selectedTagId, 1);
|
|
|
} else {
|
|
|
this.loadCourseList(this.selectedTagId, 1);
|
|
|
}
|
|
@@ -157,6 +183,18 @@ class CLScene extends scene {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ loadTrainingList(tagId, index) {
|
|
|
+ APIClient.getProductListByTagId(tagId, index, (isTrue, res) => {
|
|
|
+ if (!isTrue) { return; }
|
|
|
+ if (!res.success) { return; }
|
|
|
+ const { pageNo, pageSize, totalSize, list } = res.data || {};
|
|
|
+ this.hasNextPage = pageNo * pageSize < totalSize ? true : false;
|
|
|
+ this.currentIndex = pageNo;
|
|
|
+ this.renderRightContentList(list, TrainingItem, index > 1);
|
|
|
+ this.rightScrollEvent.releaseEventLock();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
loadTagList() {
|
|
|
let type = {
|
|
|
periphery: 'PERIPHERY',
|
|
@@ -187,6 +225,8 @@ class CLScene extends scene {
|
|
|
this.loadPeripheryList(this.selectedTagId, 1);
|
|
|
} else if (this.sceneType == 'collection') {
|
|
|
this.loadCollectionList(this.selectedTagId, 1);
|
|
|
+ } else if (this.sceneType == 'training') {
|
|
|
+ this.loadTrainingList(this.selectedTagId, 1);
|
|
|
} else {
|
|
|
this.loadCourseList(this.selectedTagId, 1);
|
|
|
}
|
|
@@ -253,6 +293,9 @@ class CLScene extends scene {
|
|
|
if (this.sceneType == 'periphery') {
|
|
|
this.showScene(require('./GlobalGoodDetailScene.js'), { id });
|
|
|
return;
|
|
|
+ } else if (this.sceneType == 'training') {
|
|
|
+ this.showScene(require('./TrainingScene.js'), { id, imgList: this.trainingMap[id] });
|
|
|
+ return;
|
|
|
}
|
|
|
// 进入课程详情场景
|
|
|
this.showScene(require(`./CourseScene.js`), { id });
|