Commit 5ab0ff43 authored by liujiangnan's avatar liujiangnan

feat

parent 73732df5
import { BlendFactor } from './../../../creator.d';
// Learn TypeScript: // Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute: // Learn Attribute:
...@@ -58,6 +56,13 @@ export default class NewClass extends cc.Component { ...@@ -58,6 +56,13 @@ export default class NewClass extends cc.Component {
this.scrollView.opacity = 255; this.scrollView.opacity = 255;
this.loading.active = false; this.loading.active = false;
// 保存关卡数据用于解锁和跳下一关
global.middleLayer.crossArray = this.data;
}
async onDisable() {
global.middleLayer.crossArray = [];
} }
async initData() { async initData() {
......
...@@ -84,6 +84,52 @@ export default class NewClass extends middleLayerBase { ...@@ -84,6 +84,52 @@ export default class NewClass extends middleLayerBase {
// }, 2000); // }, 2000);
} }
saveAnswer(data, callback = null) {
this.callNetworkApiPost(`/api/kyxq/v1/user/saveanswer`, {
syllabus_id: this.courseItem.course_id,
courseware_id: this.courseItem.id,
template_name: this.courseItem.template_name,
score: data ? data.score : 0,
total_count: data ? data.total_count : 0,
right_count: data ? data.right_count : 0,
wrong_count: data ? data.wrong_count : 0,
result: JSON.stringify(data),
study_duration: Date.now() - this.courseOpenTimeStamp
}, (res) => {
if (res.code != 200) {
this.showTips(`保存学情数据失败 [${res.msg}]`);
return;
}
this.saveEnd(callback);
});
}
saveEnd(callback){
if (this.courseIndex<this.courses.length-1) {
return;
}
this.callNetworkApiPost(`/api/kyxq/v1/user/saveend`, {
syllabus_id: this.courseItem.course_id,
}, (res) => {
if (res.code != 200) {
this.showTips(`保存结束状态失败 [${res.msg}]`);
return;
}
callback && callback();
});
}
unlockNext(nextSyllabusId) {
this.callNetworkApiPost(`/api/kyxq/v1/user/unlock`, {
syllabus_id: nextSyllabusId,
}, (res) => {
if (res.code != 200) {
this.showTips(`解锁下一关卡失败 [${res.msg}]`);
return;
}
});
}
onHomeworkFinish(d1 = null, d2 = null) { onHomeworkFinish(d1 = null, d2 = null) {
let data = null; let data = null;
let callback = null; let callback = null;
...@@ -95,7 +141,7 @@ export default class NewClass extends middleLayerBase { ...@@ -95,7 +141,7 @@ export default class NewClass extends middleLayerBase {
callback = d2; callback = d2;
} }
console.log('onHomeworkFinish: ' + JSON.stringify(data)); console.log('onHomeworkFinish: ' + JSON.stringify(data));
callback && callback(); this.saveAnswer(data, callback);
} }
_designSize = null; // 设计分辨率 _designSize = null; // 设计分辨率
...@@ -204,19 +250,19 @@ export default class NewClass extends middleLayerBase { ...@@ -204,19 +250,19 @@ export default class NewClass extends middleLayerBase {
} }
} }
academyArray = []; // 关卡数组 crossArray = []; // 关卡数组
goNextCross() { goNextCross() {
const currentid = this.courseItem.course_id; const currentid = this.courseItem.course_id;
let currentIndex = null; let currentIndex = null;
for (let i = 0; i < this.academyArray.length; i++) { for (let i = 0; i < this.crossArray.length; i++) {
const item = this.academyArray[i]; const item = this.crossArray[i];
if (item.id == currentid) { if (item.id == currentid) {
currentIndex = i; currentIndex = i;
break; break;
} }
} }
if (currentIndex!=null && this.academyArray[currentIndex+1]) { if (currentIndex!=null && this.crossArray[currentIndex+1]) {
this.loadOnlineCourseWare(this.academyArray[currentIndex+1].id, null, null); this.loadOnlineCourseWare(this.crossArray[currentIndex+1].id, null, null);
} else { } else {
this.showTips(`已经是最后一关了`); this.showTips(`已经是最后一关了`);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment