Commit 5da57ac7 authored by 范雪寒's avatar 范雪寒

feat: 调用停止之前先check

parent 84c4f7e6
...@@ -90,9 +90,11 @@ export function initAir(_this) { ...@@ -90,9 +90,11 @@ export function initAir(_this) {
}, },
startRecord(testText) { startRecord(testText) {
_this.log(`===成功调用startRecord=== testText == ${testText}`); _this.log(`===成功调用startRecord=== testText == ${testText}`);
window.courseware.hasCalledStartRecord = true;
window.courseware.callOcMethod("startRecord", { "params": testText }); window.courseware.callOcMethod("startRecord", { "params": testText });
}, },
stopRecord(_isgradepapers, _callback) { stopRecord(_isgradepapers, _callback) {
window.courseware.hasCalledStartRecord = false;
_this.log(`===成功调用stopRecord=== _isgradepapers == ${_isgradepapers}`); _this.log(`===成功调用stopRecord=== _isgradepapers == ${_isgradepapers}`);
let callback = _callback; let callback = _callback;
let isgradepapers; let isgradepapers;
...@@ -115,10 +117,12 @@ export function initAir(_this) { ...@@ -115,10 +117,12 @@ export function initAir(_this) {
window.courseware.callOcMethod("stopRecord", { isBreak: 0, isGradePapers: isgradepapers }); window.courseware.callOcMethod("stopRecord", { isBreak: 0, isGradePapers: isgradepapers });
}, },
startTest(testText) { startTest(testText) {
window.courseware.hasCalledStartTest = true;
_this.log(`===成功调用startTest=== testText == ${testText}`); _this.log(`===成功调用startTest=== testText == ${testText}`);
window.courseware.callOcMethod("startTest", { "params": testText }); window.courseware.callOcMethod("startTest", { "params": testText });
}, },
stopTest(callback) { stopTest(callback) {
window.courseware.hasCalledStartTest = false;
_this.log(`===成功调用stopTest===`); _this.log(`===成功调用stopTest===`);
if (!callback) { if (!callback) {
// 不传回调函数就表示取消评测 // 不传回调函数就表示取消评测
...@@ -150,26 +154,32 @@ export function initAir(_this) { ...@@ -150,26 +154,32 @@ export function initAir(_this) {
window.courseware.callOcMethod("getEngineInfo", {}); window.courseware.callOcMethod("getEngineInfo", {});
}, },
openOsmo() { openOsmo() {
window.courseware.hasCalledOpenOsmo = true;
_this.log(`===成功调用openOsmo===`); _this.log(`===成功调用openOsmo===`);
window.courseware.callOcMethod("openOsmo", {}); window.courseware.callOcMethod("openOsmo", {});
}, },
closeOsmo() { closeOsmo() {
window.courseware.hasCalledOpenOsmo = false;
_this.log(`===成功调用closeOsmo===`); _this.log(`===成功调用closeOsmo===`);
window.courseware.callOcMethod("closeOsmo", {}); window.courseware.callOcMethod("closeOsmo", {});
}, },
openOsmoHandwriting() { openOsmoHandwriting() {
window.courseware.hasCalledOpenOsmoHandwriting = true;
_this.log(`===成功调用openOsmoHandwriting===`); _this.log(`===成功调用openOsmoHandwriting===`);
window.courseware.callOcMethod("openOsmoHandwriting", {}); window.courseware.callOcMethod("openOsmoHandwriting", {});
}, },
closeOsmoHandwriting() { closeOsmoHandwriting() {
window.courseware.hasCalledOpenOsmoHandwriting = false;
_this.log(`===成功调用closeOsmoHandwriting===`); _this.log(`===成功调用closeOsmoHandwriting===`);
window.courseware.callOcMethod("closeOsmoHandwriting", {}); window.courseware.callOcMethod("closeOsmoHandwriting", {});
}, },
openOsmoFingerRead() { openOsmoFingerRead() {
window.courseware.hasCalledOpenOsmoFingerRead = true;
_this.log(`===成功调用openOsmoFingerRead===`); _this.log(`===成功调用openOsmoFingerRead===`);
window.courseware.callOcMethod("openOsmoFingerRead", {}); window.courseware.callOcMethod("openOsmoFingerRead", {});
}, },
closeOsmoFingerRead() { closeOsmoFingerRead() {
window.courseware.hasCalledOpenOsmoFingerRead = false;
_this.log(`===成功调用closeOsmoFingerRead===`); _this.log(`===成功调用closeOsmoFingerRead===`);
window.courseware.callOcMethod("closeOsmoFingerRead", {}); window.courseware.callOcMethod("closeOsmoFingerRead", {});
}, },
...@@ -187,12 +197,21 @@ export function initAir(_this) { ...@@ -187,12 +197,21 @@ export function initAir(_this) {
} }
}, },
freeAllOcMethod() { freeAllOcMethod() {
window.courseware.stopRecord(); if (window.courseware.hasCalledStartRecord) {
window.courseware.stopTest(); window.courseware.stopRecord();
window.courseware.closeOsmo(); }
window.courseware.closeOsmoHandwriting(); if (window.courseware.hasCalledStartTest) {
window.courseware.closeOsmoFingerRead(); window.courseware.stopTest();
}
if (window.courseware.hasCalledOpenOsmo) {
window.courseware.closeOsmo();
}
if (window.courseware.hasCalledOpenOsmoHandwriting) {
window.courseware.closeOsmoHandwriting();
}
if (window.courseware.hasCalledOpenOsmoFingerRead) {
window.courseware.closeOsmoFingerRead();
}
} }
}; };
} }
...@@ -82,7 +82,7 @@ cc.Class({ ...@@ -82,7 +82,7 @@ cc.Class({
}, },
preloadAll() { preloadAll() {
if(window.preloadBundleAndSourcesFlag){ if (window.preloadBundleAndSourcesFlag) {
// 只加载一次就行了 // 只加载一次就行了
return; return;
} }
...@@ -312,7 +312,7 @@ cc.Class({ ...@@ -312,7 +312,7 @@ cc.Class({
if (!this.courses || index == this.courseIndex || index < 0 || index > this.courses.length - 1) { if (!this.courses || index == this.courseIndex || index < 0 || index > this.courses.length - 1) {
return; return;
} }
window.courseware.freeAllOcMethod(); window.courseware.freeAllOcMethod();
this.courseIndex = index; this.courseIndex = index;
...@@ -457,7 +457,7 @@ cc.Class({ ...@@ -457,7 +457,7 @@ cc.Class({
if (this.courseItem.data) { if (this.courseItem.data) {
data = JSON.parse(this.courseItem.data); data = JSON.parse(this.courseItem.data);
} }
this.log("===成功调用getData==="+ this.courseItem.data); this.log("===成功调用getData===" + this.courseItem.data);
callback && callback(data); callback && callback(data);
} }
window.courseware.nextPage = () => { window.courseware.nextPage = () => {
...@@ -467,13 +467,13 @@ cc.Class({ ...@@ -467,13 +467,13 @@ cc.Class({
this.goPrePage(); this.goPrePage();
} }
window.courseware.sendAnswer = (answerObj) => { window.courseware.sendAnswer = (answerObj) => {
this.log("===成功调用sendAnswer==="+ JSON.stringify(answerObj)); this.log("===成功调用sendAnswer===" + JSON.stringify(answerObj));
this.callNetworkApiPost(`http://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/saveanswer`, answerObj, (data) => { this.callNetworkApiPost(`http://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/saveanswer`, answerObj, (data) => {
answerObj.callback && answerObj.callback(JSON.stringify(data.row)); answerObj.callback && answerObj.callback(JSON.stringify(data.row));
}); });
} }
window.courseware.getAnswer = (queryObj, callback) => { window.courseware.getAnswer = (queryObj, callback) => {
this.log("===成功调用getAnswer==="+ JSON.stringify(queryObj)); this.log("===成功调用getAnswer===" + JSON.stringify(queryObj));
this.callNetworkApiGet(`http://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/getanswer`, queryObj, (datastr) => { this.callNetworkApiGet(`http://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/getanswer`, queryObj, (datastr) => {
const data = JSON.parse(datastr); const data = JSON.parse(datastr);
callback && callback(JSON.stringify(data.rows)); callback && callback(JSON.stringify(data.rows));
......
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