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