Commit 4fdd2d04 authored by 范雪寒's avatar 范雪寒
parents 9817ea0f 8de5506e
...@@ -189,3 +189,24 @@ export function initAir(_this) { ...@@ -189,3 +189,24 @@ export function initAir(_this) {
}; };
} }
export function timerManager () {
window.timerManager = {};
for(let i=0;i<20;i++){
window.timerManager[`timer${i}`] = {
handler: null,
type: null,
};
}
return {
freeAll() {
for (const key in window.timerManager) {
const obj = window.timerManager[key];
if(obj.handler){
window[obj.type](obj.handler);
}
}
}
}
}
import { initAir } from './air'; import { initAir, timerManager } from './air';
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
...@@ -44,17 +44,14 @@ cc.Class({ ...@@ -44,17 +44,14 @@ cc.Class({
// 统计已加载的数量 // 统计已加载的数量
loadedCount: null, loadedCount: null,
// 统一释放异步资源的方法
freeAll: null,
onLoad() { onLoad() {
this.preloadCount = 0; this.preloadCount = 0;
this.loadedCount = 0; this.loadedCount = 0;
initAir(this); initAir(this);
if (!window.preloadBundleAndSourcesFlag) { this.freeAll = timerManager().freeAll;
// 只加载一次就行了 // this.preloadAll();
window.preloadBundleAndSourcesFlag = true;
cc.find("middleLayer/ui/ProgressLabel").active = true;
cc.find('middleLayer/ui/loadingProgress').active = true;
this.preloadAll();
}
}, },
start() { start() {
...@@ -87,6 +84,13 @@ cc.Class({ ...@@ -87,6 +84,13 @@ cc.Class({
}, },
preloadAll() { preloadAll() {
if(window.preloadBundleAndSourcesFlag){
// 只加载一次就行了
return;
}
window.preloadBundleAndSourcesFlag = true;
cc.find("middleLayer/ui/ProgressLabel").active = true;
cc.find('middleLayer/ui/loadingProgress').active = true;
let platform = "web_desktop"; let platform = "web_desktop";
if (cc.sys.os == cc.sys.OS_IOS) { if (cc.sys.os == cc.sys.OS_IOS) {
platform = "ios"; platform = "ios";
...@@ -191,6 +195,7 @@ cc.Class({ ...@@ -191,6 +195,7 @@ cc.Class({
if (this.loadedCount > this.preloadCount * 0.99) { if (this.loadedCount > this.preloadCount * 0.99) {
cc.find("middleLayer/ui/ProgressLabel").active = false; cc.find("middleLayer/ui/ProgressLabel").active = false;
loadingProgress.active = false; loadingProgress.active = false;
this.showLog("资源全部加载完成");
} }
loadingProgress.getComponent(cc.ProgressBar).progress = this.loadedCount / this.preloadCount; loadingProgress.getComponent(cc.ProgressBar).progress = this.loadedCount / this.preloadCount;
}, },
...@@ -217,6 +222,9 @@ cc.Class({ ...@@ -217,6 +222,9 @@ cc.Class({
.call(() => { .call(() => {
exitBtn.active = false; exitBtn.active = false;
cc.game.removePersistRootNode(this.node); cc.game.removePersistRootNode(this.node);
console.log("======mid========");
this.freeAll();
console.log("======mid1========");
cc.director.loadScene("debug_shell", () => { cc.director.loadScene("debug_shell", () => {
}); });
}) })
...@@ -357,11 +365,9 @@ cc.Class({ ...@@ -357,11 +365,9 @@ cc.Class({
courseIndex: 0, courseIndex: 0,
courseItem: null, courseItem: null,
loadOnlineCourseWare(courseId, linkFlag) { loadOnlineCourseWare(courseId, linkFlag) {
console.log('loadOnlineCourseWare')
this.showWaitingLetters();
console.log('showWaitingLetters');
this.hideUI(); this.hideUI();
console.log('hideUI'); this.showWaitingLetters();
let api = `/api/courseware/v1/${courseId}/list`; let api = `/api/courseware/v1/${courseId}/list`;
if (linkFlag === true) { if (linkFlag === true) {
api = `/api/courseware/v1/${courseId}/eq/level/list`; api = `/api/courseware/v1/${courseId}/eq/level/list`;
...@@ -452,6 +458,7 @@ cc.Class({ ...@@ -452,6 +458,7 @@ cc.Class({
if (this.courseItem.data) { if (this.courseItem.data) {
data = JSON.parse(this.courseItem.data); data = JSON.parse(this.courseItem.data);
} }
this.log("===成功调用getData==="+ this.courseItem.data);
callback && callback(data); callback && callback(data);
} }
window.courseware.nextPage = () => { window.courseware.nextPage = () => {
...@@ -461,11 +468,13 @@ cc.Class({ ...@@ -461,11 +468,13 @@ cc.Class({
this.goPrePage(); this.goPrePage();
} }
window.courseware.sendAnswer = (answerObj) => { window.courseware.sendAnswer = (answerObj) => {
this.log("===成功调用sendAnswer==="+ JSON.stringify(answerObj));
this.callNetworkApiPost(`http://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/saveanswer`, answerObj, (data) => { this.callNetworkApiPost(`http://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/saveanswer`, answerObj, (data) => {
answerObj.callback && answerObj.callback(JSON.stringify(data.row)); answerObj.callback && answerObj.callback(JSON.stringify(data.row));
}); });
} }
window.courseware.getAnswer = (queryObj, callback) => { window.courseware.getAnswer = (queryObj, callback) => {
this.log("===成功调用getAnswer==="+ JSON.stringify(queryObj));
this.callNetworkApiGet(`http://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/getanswer`, queryObj, (datastr) => { this.callNetworkApiGet(`http://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/getanswer`, queryObj, (datastr) => {
const data = JSON.parse(datastr); const data = JSON.parse(datastr);
callback && callback(JSON.stringify(data.rows)); callback && callback(JSON.stringify(data.rows));
......
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