Commit 512734ce authored by huoshizhe's avatar huoshizhe

feat: getData

parent 73ef6105
...@@ -4,7 +4,13 @@ cc.Class({ ...@@ -4,7 +4,13 @@ cc.Class({
getData(callBack) { getData(callBack) {
const uri = 'courseware/v1/getdata'; const uri = 'courseware/v1/getdata';
const syllabus_id = this.bundleInfoList[this.currentBundleIndex].syllabus_id;
let syllabus_id;
if (this.bundleType == 'StoryBox') {
syllabus_id = this.syllabus_id;
} else if (this.bundleType == 'WW') {
syllabus_id = this.bundleInfoList[this.currentBundleIndex].syllabus_id;
}
const data = { const data = {
courseid: syllabus_id courseid: syllabus_id
}; };
...@@ -91,11 +97,11 @@ cc.Class({ ...@@ -91,11 +97,11 @@ cc.Class({
// }) // })
// }, 20000); // }, 20000);
// this.baseUrl = 'http://staging-teach.ireadabc.com/api/'; this.baseUrl = 'http://staging-teach.ireadabc.com/api/';
// this.initStoryBoxView({ this.initStoryBoxView({
// coursewareId: 18307 coursewareId: 18307
// }); });
// this.bundleType = 'StoryBox'; this.bundleType = 'StoryBox';
this.log('汪汪汪'); this.log('汪汪汪');
}, },
...@@ -163,6 +169,7 @@ cc.Class({ ...@@ -163,6 +169,7 @@ cc.Class({
return; return;
} }
this.syllabus_id = defaultBondle.children[0].id;
this.loadBundleByConf(defaultBondle.children[0].conf, () => { this.loadBundleByConf(defaultBondle.children[0].conf, () => {
const ExitBtn = cc.find('middleLayer/storyBox/ExitBtn'); const ExitBtn = cc.find('middleLayer/storyBox/ExitBtn');
ExitBtn.active = true; ExitBtn.active = true;
...@@ -263,14 +270,8 @@ cc.Class({ ...@@ -263,14 +270,8 @@ cc.Class({
btnSelected.on('click', () => { btnSelected.on('click', () => {
this.hideMenu(); this.hideMenu();
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) { this.syllabus_id = data.children[0].id;
this.loadBundle(data.children[0].conf.ios); this.loadBundleByConf(data.children[0].conf);
} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
this.loadBundle(data.children[0].conf.android);
} else {
this.loadBundle(data.children[0].conf.web_desktop);
console.error('非源生环境');
}
}); });
if (data.has_child == '1') { if (data.has_child == '1') {
...@@ -290,6 +291,7 @@ cc.Class({ ...@@ -290,6 +291,7 @@ cc.Class({
.to(0.1, { scale: 1.00 }) .to(0.1, { scale: 1.00 })
.call(() => { .call(() => {
this.hideMenu(); this.hideMenu();
this.syllabus_id = menuData.children[0].id;
this.loadBundleByConf(menuData.children[0].conf); this.loadBundleByConf(menuData.children[0].conf);
}) })
.start(); .start();
...@@ -492,37 +494,37 @@ cc.Class({ ...@@ -492,37 +494,37 @@ cc.Class({
} }
this.jumpToBundleByIndex(this.currentBundleIndex + 1); this.jumpToBundleByIndex(this.currentBundleIndex + 1);
}); });
const btnClose = cc.find('middleLayer/ConsoleNode/BtnClose'); const btnClose = cc.find('middleLayer/ConsoleNode/BtnClose');
const btnOpen = cc.find('middleLayer/ConsoleNode/BtnOpen'); const btnOpen = cc.find('middleLayer/ConsoleNode/BtnOpen');
const consoleNode = cc.find('middleLayer/ConsoleNode/Console'); const consoleNode = cc.find('middleLayer/ConsoleNode/Console');
const consoleBg = cc.find('middleLayer/ConsoleNode/bg'); const consoleBg = cc.find('middleLayer/ConsoleNode/bg');
btnOpen.on('click', () => { btnOpen.on('click', () => {
btnClose.active = true; btnClose.active = true;
btnOpen.active = false; btnOpen.active = false;
consoleNode.active = true; consoleNode.active = true;
consoleBg.active = true; consoleBg.active = true;
}); });
btnClose.on('click', () => { btnClose.on('click', () => {
btnClose.active = false; btnClose.active = false;
btnOpen.active = true; btnOpen.active = true;
consoleNode.active = false; consoleNode.active = false;
consoleBg.active = false; consoleBg.active = false;
}); });
}, },
log(str) { log(str) {
const logStr = `${new Date().toLocaleString()}: ${str}`; const logStr = `${new Date().toLocaleString()}: ${str}`;
console.log(logStr); console.log(logStr);
const content = cc.instantiate(cc.find('middleLayer/ConsoleNode/content')); const content = cc.instantiate(cc.find('middleLayer/ConsoleNode/content'));
content.active = true; content.active = true;
const label = content.getChildByName('label'); const label = content.getChildByName('label');
label.getComponent(cc.Label).string = logStr; label.getComponent(cc.Label).string = logStr;
const consoleContent = cc.find('middleLayer/ConsoleNode/Console/content'); const consoleContent = cc.find('middleLayer/ConsoleNode/Console/content');
consoleContent.addChild(content); consoleContent.addChild(content);
consoleContent.getComponent(cc.Layout).updateLayout(); consoleContent.getComponent(cc.Layout).updateLayout();
}, },
callNativeFunction(param) { callNativeFunction(param) {
const paramStr = JSON.stringify(param); const paramStr = JSON.stringify(param);
......
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