|
|
@@ -109,33 +109,21 @@ const cacheManager = (function() {
|
|
|
}, obj);
|
|
|
}
|
|
|
// 用于新数学产品当前单元节视频看完了 更新完成状态和计算当前单元的进度
|
|
|
- // key : xuexi-shuxue
|
|
|
- // index : 当前单元下的第几个节index
|
|
|
// currentJieId:当前jieId
|
|
|
- function updateStatusAndProess(key, index, currentJieId) {
|
|
|
- let obj = get(key) || {};
|
|
|
- // 更新完成状态
|
|
|
+ function updateStatusAndProess(currentJieId) {
|
|
|
+ let obj = get('xuexi-shuxue') || {};
|
|
|
+ // 标记完成
|
|
|
for (let jie of obj.dagangList) {
|
|
|
- if (jie.jieId == currentJieId && jie.wanchengFlag == 0) {
|
|
|
+ if (jie.jieId == currentJieId) {
|
|
|
jie.wanchengFlag = 1;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- // 统计视频课程数量(排除单元测试)
|
|
|
- const videoSections = obj.dagangList.filter(item => {
|
|
|
- return item.type == 1;
|
|
|
- });
|
|
|
- const videoCount = videoSections.length;
|
|
|
// 计算新进度
|
|
|
- const currentProgress = parseFloat(obj.curProcess) || 0;
|
|
|
- const progressPerVideo = 100 / videoCount;
|
|
|
- let newProgress = currentProgress + progressPerVideo;
|
|
|
- // 确保进度不超过100%
|
|
|
- if (newProgress > 100) {
|
|
|
- newProgress = 100;
|
|
|
- }
|
|
|
+ let newProgress = (parseFloat(obj.curProcess) || 0) + (100 / obj.dagangList.length);
|
|
|
+ if (newProgress > 100) newProgress = 100;
|
|
|
obj.curProcess = newProgress.toFixed(2);
|
|
|
- set(key, obj);
|
|
|
+ set('xuexi-shuxue' obj);
|
|
|
}
|
|
|
return {
|
|
|
set,
|