Commit c72879a1 authored by liujiangnan's avatar liujiangnan

feat

parent 8b3ccd85
...@@ -1096,8 +1096,8 @@ ...@@ -1096,8 +1096,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 1280, "width": 5000,
"height": 720 "height": 5000
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1497,10 +1497,10 @@ ...@@ -1497,10 +1497,10 @@
"alignMode": 1, "alignMode": 1,
"_target": null, "_target": null,
"_alignFlags": 45, "_alignFlags": 45,
"_left": 0, "_left": -1860,
"_right": 0, "_right": -1860,
"_top": 0, "_top": -2140,
"_bottom": 0, "_bottom": -2140,
"_verticalCenter": 0, "_verticalCenter": 0,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_isAbsLeft": true, "_isAbsLeft": true,
......
...@@ -401,21 +401,31 @@ export default class NewClass extends middleLayerBase { ...@@ -401,21 +401,31 @@ export default class NewClass extends middleLayerBase {
this.data = {}; this.data = {};
cc.sys.localStorage.setItem("token", ""); cc.sys.localStorage.setItem("token", "");
} }
this.callNetworkApiGet(`/api/template/v1/${bundleName}`, {}, (datastr) => {
const data = JSON.parse(datastr); this.callNetworkApiGet(`/api/template/v2/${bundleName}`, {}, (datastr) => {
let configData = null; const data = JSON.parse(datastr).data;
let sceneName, version, bondleUrl = "";
const templateBaseUrl = `${this.DOMAIN}h5template/${data.name}/v${data.last_version}`;
this.getConfigInfo(templateBaseUrl, (conf) => {
if (cc.sys.os == cc.sys.OS_IOS) { if (cc.sys.os == cc.sys.OS_IOS) {
configData = data.data.conf.ios; sceneName = conf.ios.sceneName;
version = conf.ios.version;
bondleUrl = conf.ios.bondleUrl;
} else if (cc.sys.os == cc.sys.OS_ANDROID) { } else if (cc.sys.os == cc.sys.OS_ANDROID) {
configData = data.data.conf.android; sceneName = conf.android.sceneName;
version = conf.android.version;
bondleUrl = conf.android.bondleUrl;
} else { } else {
configData = data.data.conf.web_desktop; sceneName = conf.android.sceneName;
version = "";
bondleUrl = `${templateBaseUrl}/web_desktop`;
} }
const sceneName = configData.sceneName;
const version = configData.version;
const bondleUrl = configData.bondleUrl;
this.loadBundle(sceneName, version, bondleUrl, callback); this.loadBundle(sceneName, version, bondleUrl, callback);
}); });
});
} }
// 重写loadPageBundle方法;主要是添加上报记录“上次学习位置” // 重写loadPageBundle方法;主要是添加上报记录“上次学习位置”
...@@ -566,7 +576,6 @@ export default class NewClass extends middleLayerBase { ...@@ -566,7 +576,6 @@ export default class NewClass extends middleLayerBase {
} }
this.showMask();
this.showWaitingLetters(); this.showWaitingLetters();
this.onMiddleLayerLoadingFinish(); this.onMiddleLayerLoadingFinish();
......
...@@ -68,15 +68,30 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -68,15 +68,30 @@ export abstract class middleLayerBase extends cc.Component {
}); });
} }
getConfigInfo(url, callback) {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
callback(JSON.parse(xhr.responseText));
}
};
console.warn('url = ' + `${url}/config.json`);
xhr.open('GET', `${url}/config.json`, true);
xhr.send();
}
ORG_ID; ORG_ID;
DOMAIN;
async getBaseUrl(callback) { async getBaseUrl(callback) {
const engineInfo = await this.getEngineInfo(); const engineInfo = await this.getEngineInfo();
const { isDev } = JSON.parse(engineInfo); const { isDev } = JSON.parse(engineInfo);
if (isDev == 1) { if (isDev == 1) {
this.ORG_ID = 513; this.ORG_ID = 513;
this.DOMAIN = "http://staging-teach.cdn.ireadabc.com/";
callback('http://staging-openapi.iteachabc.com'); callback('http://staging-openapi.iteachabc.com');
} else { } else {
this.ORG_ID = 512; this.ORG_ID = 512;
this.DOMAIN = "http://teach.cdn.ireadabc.com/";
callback('http://openapi.iteachabc.com'); callback('http://openapi.iteachabc.com');
} }
} }
...@@ -107,24 +122,32 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -107,24 +122,32 @@ export abstract class middleLayerBase extends cc.Component {
}); });
} }
loadOnlineBundle(bundleName) { loadOnlineBundle(bundleName, callback = null) {
cc.find('middleLayer/BtnRight').active = false; cc.find('middleLayer/BtnRight').active = false;
cc.find('middleLayer/BtnLeft').active = false; cc.find('middleLayer/BtnLeft').active = false;
cc.find('middleLayer/ExitBtn').active = false; cc.find('middleLayer/ExitBtn').active = false;
this.callNetworkApiGet(`/api/template/v1/${bundleName}`, {}, (datastr) => { this.callNetworkApiGet(`/api/template/v2/${bundleName}`, {}, (datastr) => {
const data = JSON.parse(datastr); const data = JSON.parse(datastr).data;
let configData = null; let sceneName, version, bondleUrl = "";
const templateBaseUrl = `${this.DOMAIN}h5template/${data.name}/v${data.last_version}`;
this.getConfigInfo(templateBaseUrl, (conf) => {
if (cc.sys.os == cc.sys.OS_IOS) { if (cc.sys.os == cc.sys.OS_IOS) {
configData = data.data.conf.ios; sceneName = conf.ios.sceneName;
version = conf.ios.version;
bondleUrl = conf.ios.bondleUrl;
} else if (cc.sys.os == cc.sys.OS_ANDROID) { } else if (cc.sys.os == cc.sys.OS_ANDROID) {
configData = data.data.conf.android; sceneName = conf.android.sceneName;
version = conf.android.version;
bondleUrl = conf.android.bondleUrl;
} else { } else {
configData = data.data.conf.web_desktop; sceneName = conf.android.sceneName;
version = "";
bondleUrl = `${templateBaseUrl}/web_desktop`;
} }
const sceneName = configData.sceneName; this.loadBundle(sceneName, version, bondleUrl, callback);
const version = configData.version; });
const bondleUrl = configData.bondleUrl;
this.loadBundle(sceneName, version, bondleUrl);
}); });
} }
...@@ -161,7 +184,6 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -161,7 +184,6 @@ export abstract class middleLayerBase extends cc.Component {
this.loadBundleLock = true; // 加锁 this.loadBundleLock = true; // 加锁
this.currentBundleInfo = { sceneName, version, bondleUrl }; this.currentBundleInfo = { sceneName, version, bondleUrl };
console.log("[middleLayer_for_NJ_lite]-[loadBundle] currentBundleInfo=", JSON.stringify(this.currentBundleInfo)) console.log("[middleLayer_for_NJ_lite]-[loadBundle] currentBundleInfo=", JSON.stringify(this.currentBundleInfo))
this.showMask();
this.showWaitingLetters(); this.showWaitingLetters();
const oldSceneName = this.currentBundleInfo?.sceneName; const oldSceneName = this.currentBundleInfo?.sceneName;
...@@ -249,10 +271,11 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -249,10 +271,11 @@ export abstract class middleLayerBase extends cc.Component {
loadOnlineCourseWare(courseId, linkFlag = false, coursewareId = null) { loadOnlineCourseWare(courseId, linkFlag = false, coursewareId = null) {
this.showWaitingLetters(); this.showWaitingLetters();
let api = `/api/courseware/v1/${courseId}/list`; let api = `/api/courseware/v2/${courseId}/list`;
if (linkFlag === true) { if (linkFlag === true) {
api = `/api/courseware/v1/${courseId}/eq/level/list`; api = `/api/courseware/v2/${courseId}/eq/level/list`;
} }
this.callNetworkApiGet(api, {}, (datastr) => { this.callNetworkApiGet(api, {}, (datastr) => {
const data = JSON.parse(datastr); const data = JSON.parse(datastr);
if (data.rows && data.rows.length > 0) { if (data.rows && data.rows.length > 0) {
...@@ -268,6 +291,7 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -268,6 +291,7 @@ export abstract class middleLayerBase extends cc.Component {
this.showTips(`内容还未制作`); this.showTips(`内容还未制作`);
return; return;
} }
this.loadPageBundle(() => {
if (this.courses && this.courses.length > 1 && this.courseIndex < this.courses.length - 1) { if (this.courses && this.courses.length > 1 && this.courseIndex < this.courses.length - 1) {
cc.find('middleLayer/BtnRight').active = true; cc.find('middleLayer/BtnRight').active = true;
} else { } else {
...@@ -276,8 +300,6 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -276,8 +300,6 @@ export abstract class middleLayerBase extends cc.Component {
if (this.courseIndex > 0) { if (this.courseIndex > 0) {
cc.find('middleLayer/BtnLeft').active = false; cc.find('middleLayer/BtnLeft').active = false;
} }
this.reWriteAir();
this.loadPageBundle(() => {
cc.find('middleLayer/ExitBtn').active = true; cc.find('middleLayer/ExitBtn').active = true;
}); });
}); });
...@@ -285,21 +307,24 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -285,21 +307,24 @@ export abstract class middleLayerBase extends cc.Component {
loadPageBundle(callback = null) { loadPageBundle(callback = null) {
let sceneName, version, bondleUrl = ""; let sceneName, version, bondleUrl = "";
const templateBaseUrl = `${this.DOMAIN}h5template/${this.courseItem.template_name}/v${this.courseItem.last_version}`;
this.getConfigInfo(templateBaseUrl, (conf) => {
if (cc.sys.os == cc.sys.OS_IOS) { if (cc.sys.os == cc.sys.OS_IOS) {
sceneName = this.courseItem.conf.ios.sceneName; sceneName = conf.ios.sceneName;
version = this.courseItem.conf.ios.version; version = conf.ios.version;
bondleUrl = this.courseItem.conf.ios.bondleUrl; bondleUrl = conf.ios.bondleUrl;
} else if (cc.sys.os == cc.sys.OS_ANDROID) { } else if (cc.sys.os == cc.sys.OS_ANDROID) {
sceneName = this.courseItem.conf.android.sceneName; sceneName = conf.android.sceneName;
version = this.courseItem.conf.android.version; version = conf.android.version;
bondleUrl = this.courseItem.conf.android.bondleUrl; bondleUrl = conf.android.bondleUrl;
} else { } else {
sceneName = this.courseItem.conf.web_desktop.sceneName; sceneName = conf.android.sceneName;
version = this.courseItem.conf.web_desktop.version; version = "";
bondleUrl = this.courseItem.conf.web_desktop.bondleUrl; bondleUrl = `${templateBaseUrl}/web_desktop`;
} }
this.loadBundle(sceneName, version, bondleUrl, callback); this.loadBundle(sceneName, version, bondleUrl, callback);
});
} }
goPrePage() { goPrePage() {
...@@ -312,7 +337,6 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -312,7 +337,6 @@ export abstract class middleLayerBase extends cc.Component {
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;
} }
this.showMask();
this.showWaitingLetters(); this.showWaitingLetters();
(<any>window).courseware.freeAllOcMethod(); (<any>window).courseware.freeAllOcMethod();
......
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