Commit cb558fa3 authored by huoshizhe's avatar huoshizhe

feat

parent f367589d
{"ver":"1.1.2","uuid":"c35bb2f6-f24a-4850-ae44-643f2fdc7541","isBundle":false,"bundleName":"","priority":1,"compressionType":{"android":"default","ios":"default"},"optimizeHotUpdate":{"android":false,"ios":false},"inlineSpriteFrames":{"android":false,"ios":false},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}} {
\ No newline at end of file "ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {
"android": "default",
"ios": "default"
},
"optimizeHotUpdate": {
"android": false,
"ios": false
},
"inlineSpriteFrames": {
"android": false,
"ios": false
},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
...@@ -4,17 +4,14 @@ cc.Class({ ...@@ -4,17 +4,14 @@ cc.Class({
getData(callBack) { getData(callBack) {
const scene = cc.director.getScene(); const scene = cc.director.getScene();
if (scene.name == 'PS00') { if (scene.name == 'PS_000') {
if (this.saveData) { if (!this.saveData) {
console.log('汪汪汪1') this.saveData = { step: 0 };
callBack(this.saveData); }
} else { callBack(this.saveData);
console.log('汪汪汪2')
callBack(null);
}
} else { } else {
console.log('汪汪汪3') console.log('汪汪汪_3')
callBack(null); callBack(JSON.parse(this.courseItem.data));
} }
return; return;
if (this.localMode) { if (this.localMode) {
...@@ -31,12 +28,15 @@ cc.Class({ ...@@ -31,12 +28,15 @@ cc.Class({
onHomeworkFinish(callBack) { onHomeworkFinish(callBack) {
if (!this.saveData) { if (!this.saveData) {
console.log('汪汪汪1')
this.saveData = { step: 1 }; this.saveData = { step: 1 };
} else { } else {
console.log('汪汪汪2: ' + this.saveData.step)
this.saveData.step++; this.saveData.step++;
} }
this.loadOnlineBundle('PS00'); console.log(`this.loadOnlineBundle('PS_000');`);
this.loadOnlineBundle('PS_000');
// this.loadLocalBundle('192.168.1.102', '8081'); // this.loadLocalBundle('192.168.1.102', '8081');
// cc.director. // cc.director.
return; return;
...@@ -69,28 +69,28 @@ cc.Class({ ...@@ -69,28 +69,28 @@ cc.Class({
start() { start() {
this.node.zIndex = 9999; this.node.zIndex = 9999;
if (!cc.game.isPersistRootNode(this.node)) { if (!cc.game.isPersistRootNode(this.node)) {
cc.game.addPersistRootNode(this.node); cc.game.addPersistRootNode(this.node);
} }
this.initListener(); this.initListener();
this.loadOnlineBundle('PS00'); this.loadOnlineBundle('PS_000');
// this.loadLocalBundle('192.168.1.102', '8081'); // this.loadLocalBundle('192.168.1.102', '8081');
const addressText = cc.find('middleLayer/ui/address'); // const addressText = cc.find('middleLayer/ui/address');
const str = cc.sys.localStorage.getItem('ip'); // const str = cc.sys.localStorage.getItem('ip');
console.log('str = ' + str); // console.log('str = ' + str);
if (str) { // if (str) {
addressText.getComponent(cc.EditBox).string = str; // addressText.getComponent(cc.EditBox).string = str;
} // }
const nameText = cc.find('middleLayer/ui/bundleName'); // const nameText = cc.find('middleLayer/ui/bundleName');
const bundleName = cc.sys.localStorage.getItem('bundleName'); // const bundleName = cc.sys.localStorage.getItem('bundleName');
if (bundleName) { // if (bundleName) {
nameText.getComponent(cc.EditBox).string = bundleName; // nameText.getComponent(cc.EditBox).string = bundleName;
} // }
}, },
asyncDelayLog(str) { asyncDelayLog(str) {
...@@ -215,7 +215,15 @@ cc.Class({ ...@@ -215,7 +215,15 @@ cc.Class({
} }
this.callNetworkApiGet(`http://staging-teach.ireadabc.com`, `/api/template/v1/${bundleName}`, {}, (datastr) => { this.callNetworkApiGet(`http://staging-teach.ireadabc.com`, `/api/template/v1/${bundleName}`, {}, (datastr) => {
const data = JSON.parse(datastr); const data = JSON.parse(datastr);
const configData = data.data.conf.android; let configData;
if (cc.sys.os == cc.sys.OS_IOS) {
configData = data.data.conf.ios;
} else if (cc.sys.os == cc.sys.OS_ANDROID) {
configData = data.data.conf.android;
} else {
configData = data.data.conf.web_desktop;
}
const sceneName = configData.sceneName; const sceneName = configData.sceneName;
const version = configData.version; const version = configData.version;
const bondleUrl = configData.bondleUrl; const bondleUrl = configData.bondleUrl;
...@@ -224,6 +232,41 @@ cc.Class({ ...@@ -224,6 +232,41 @@ cc.Class({
}); });
}, },
loadOnlineBundleByCourseId(courseId) {
const baseUrl = `http://staging-teach.ireadabc.com/api/`;
let api = `courseware/v1/${courseId}/list`;
// if (linkFlag === true) {
// api = `/api/courseware/v1/${courseId}/eq/level/list`;
// }
this.callNetworkApiGet(baseUrl, api, {}, (datastr) => {
const data = JSON.parse(datastr);
if (data.rows && data.rows.length > 0) {
this.courses = data.rows;
this.courseIndex = data.index || 0;
this.courseItem = data.rows[this.courseIndex];
}
console.log(this.courseItem);
let sceneName, version, bondleUrl = "";
if (cc.sys.os == cc.sys.OS_IOS) {
sceneName = this.courseItem.conf.ios.sceneName;
version = this.courseItem.conf.ios.version;
bondleUrl = this.courseItem.conf.ios.bondleUrl;
} else if (cc.sys.os == cc.sys.OS_ANDROID) {
sceneName = this.courseItem.conf.android.sceneName;
version = this.courseItem.conf.android.version;
bondleUrl = this.courseItem.conf.android.bondleUrl;
} else {
sceneName = this.courseItem.conf.web_desktop.sceneName;
version = this.courseItem.conf.web_desktop.version;
bondleUrl = this.courseItem.conf.web_desktop.bondleUrl;
}
this.loadBundle(sceneName, version, bondleUrl);
});
},
loadLocalBundle(address, port, onSuccess = null) { loadLocalBundle(address, port, onSuccess = null) {
this.callNetworkApiGet(`http://${address}:${port}`, '/publish/config.json', {}, (datastr) => { this.callNetworkApiGet(`http://${address}:${port}`, '/publish/config.json', {}, (datastr) => {
const data = JSON.parse(datastr); const data = JSON.parse(datastr);
......
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