Commit 6276e71f authored by 范雪寒's avatar 范雪寒

feat: callMiddleLayerFunction - NS_login

parent 7d405dda
......@@ -83,22 +83,24 @@ cc.Class({
uiNode.scale = scale;
initAir(this);
// this.preloadAll();
this.role = 'student';
},
getBaseUrl(callback) {
if(window.air.engineInfo){
const {isDev} = JSON.parse(window.air.engineInfo);
if(isDev==1){
if (window.air.engineInfo) {
const { isDev } = JSON.parse(window.air.engineInfo);
if (isDev == 1) {
callback('https://staging-teach.ireadabc.com');
}else{
} else {
callback('https://iteachabc.com');
}
}else{
window.courseware.getEngineInfo(()=>{
const {isDev} = JSON.parse(window.air.engineInfo);
if(isDev==1){
} else {
window.courseware.getEngineInfo(() => {
const { isDev } = JSON.parse(window.air.engineInfo);
if (isDev == 1) {
callback('https://staging-teach.ireadabc.com');
}else{
} else {
callback('https://iteachabc.com');
}
});
......@@ -264,6 +266,40 @@ cc.Class({
loadingProgress.getComponent(cc.ProgressBar).progress = this.loadedCount / this.preloadCount;
},
onHomeworkFinish(callBack, data = null) {
console.log('this.courseIndex = ' + JSON.stringify(this.currentBundleInfo));
if (this.currentBundleInfo.sceneName == 'ls_fly') {
const rightCount = data.reduce((preValue, right) => {
if (right) {
return preValue + 1;
} else {
return preValue;
}
}, 0);
console.log('rightCount = ' + rightCount);
}
console.log('onHomeworkFinish: ' + JSON.stringify(data));
},
callMiddleLayerFunction(apiName, data, callback) {
switch (apiName) {
case 'NS_login':
if (data.userName == 'admin' && data.password == '123456') {
this.showLog('登陆成功!');
callback('登陆成功!');
// this.goNextPage();
// this.goPrePage();
} else {
this.showLog('密码错误!');
callback('密码错误!');
}
break;
default:
this.showLog('未定义接口: ' + apiName);
break;
}
},
asyncDelayLog(str) {
console.log(str);
return new Promise((resolve, reject) => {
......@@ -291,7 +327,7 @@ cc.Class({
window.courseware.freeAllOcMethod();
const flag = cc.director.loadScene("debug_shell", null, null, (err, scene) => {
});
if(!flag){
if (!flag) {
// 没有壳的情况下,直接加载中间层场景
cc.director.loadScene("middleLayer_for_debug", null, null, (err, scene) => {
});
......@@ -655,7 +691,7 @@ cc.Class({
const canvas = cc.find("Canvas");
const bg = layout.addComponent(cc.Graphics);
bg.fillRect(-canvas.width / 2, -canvas.height / 2, canvas.width, canvas.height);
const laodingLayer = cc.find('middleLayer/loadingLayer');
laodingLayer.active = true;
......@@ -671,15 +707,15 @@ cc.Class({
script.setProgress(changeObj.value);
}, 1);
const changeObj = {value: 0};
const changeObj = { value: 0 };
cc.tween(changeObj)
.to(5, {value: 0.9})
.to(5, { value: 0.9 })
.call(() => {
clearInterval(id);
})
.start();
// const colorList = this.getRainbowColorList();
// const layout = cc.find('middleLayer/layout');
......@@ -705,7 +741,7 @@ cc.Class({
// return width + node.width;
// }, 0);
// layout.width = totalWidth;
},
hideWaitingLetters() {
......@@ -755,13 +791,13 @@ cc.Class({
this.showOneLog();
}, 1000);
},
exit() {
cc.game.removePersistRootNode(this.node);
cc.director.loadScene("emptyScene", () => {
this.callNativeFunction({ name: 'exit', value: '' });
});
},
this.callNativeFunction({ name: 'exit', value: '' });
});
},
getRainbowColorList() {
return [
......
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