Commit c72879a1 authored by liujiangnan's avatar liujiangnan

feat

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