Commit 864884b8 authored by 李维's avatar 李维

修改页面为预制体

降低内存占用
parent cb8e5ca8
No preview for this file type
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541", "uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false, "isBundle": true,
"bundleName": "", "bundleName": "middleLayer_for_kyxq",
"priority": 1, "priority": 1,
"compressionType": { "compressionType": {
"android": "default", "android": "default",
......
{
"ver": "1.1.2",
"uuid": "bac86377-cfa0-4d5a-a280-95bd5c5f4b54",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "89955a5d-3779-4cae-b744-d2fb29196f13",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "161f21aa-9d4f-4ff7-9168-495b41252ab5",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
import { asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, playLocalAudio, playAudioByUrl, getSprNodeByUrl, asyncDelay } from "./util"; import { asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, playLocalAudio, playAudioByUrl, getSprNodeByUrl, asyncDelay } from "../../../script/util";
import PageComponentBaseClass from "./PageComponentBase" import PageComponentBaseClass from "../../../script/PageComponentBase";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class HomePageClass extends PageComponentBaseClass { export default class HomePageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
userPage: cc.Node = null; userPage: cc.Node = null;
@property(cc.Node) @property(cc.Node)
topUserPanel: cc.Node = null; topUserPanel: cc.Node = null;
@property(cc.Node) @property(cc.Node)
CourseItem: cc.Node = null; CourseItem: cc.Node = null;
@property(cc.Node) @property(cc.Node)
SvContent: cc.Node = null; SvContent: cc.Node = null;
@property(cc.Node) Viewer: cc.Node = null;
loading: cc.Node = null; loading: cc.Node = null;
_inited = false;
// 点击用户中心 // 点击用户中心
handleClickUserCenter() { handleClickUserCenter() {
this.userPage.active = true; this.userPage.active = true;
...@@ -234,23 +230,25 @@ export default class HomePageClass extends PageComponentBaseClass { ...@@ -234,23 +230,25 @@ export default class HomePageClass extends PageComponentBaseClass {
} }
async start() { async start() {
console.log("start")
console.log(this.node)
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法 // 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node); super.initPageHook(this.node);
this.initBg(); this.initBg();
} }
async beforeMount() {
this.SvContent.removeAllChildren();
}
async mounted() { async mounted() {
console.log("mounted")
await this.getUserInfo(); await this.getUserInfo();
await this.getCourseList(); await this.getCourseList();
this.initTopUserPanel(); this.initTopUserPanel();
} }
async onEnable() { async unmounted(data: any) {
console.log("unmounted")
this.SvContent.removeAllChildren();
} }
// update (dt) {} // update (dt) {}
} }
...@@ -10,24 +10,22 @@ const {ccclass, property} = cc._decorator; ...@@ -10,24 +10,22 @@ const {ccclass, property} = cc._decorator;
@ccclass @ccclass
export default class UserPageClass extends cc.Component { export default class UserPageClass extends cc.Component {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
infoPanel: cc.Node = null; infoPanel: cc.Node = null;
@property(cc.Node) @property(cc.Node)
exitPanel: cc.Node = null; exitPanel: cc.Node = null;
// onLoad () {} // onLoad () {}
Viewer: cc.Node = null;
_canTouch = false; _canTouch = false;
async start () { async start () {
console.log("User start")
this._canTouch = true; this._canTouch = true;
this.initDeleteAccoutBtn(); console.log(this.node)
} this.Viewer = this.node.parent.viewer;
protected onEnable(): void {
this.initDeleteAccoutBtn(); this.initDeleteAccoutBtn();
} }
......
{
"ver": "1.1.2",
"uuid": "a837fbbf-bbb0-4f78-8931-79d30176044a",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "66371197-45fb-4802-bf66-463ddcba99dd",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util"; import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "./PageComponentBase" import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class LibraryPageClass extends PageComponentBaseClass { export default class LibraryPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
btnReading: cc.Node = null; btnReading: cc.Node = null;
...@@ -19,9 +15,6 @@ export default class LibraryPageClass extends PageComponentBaseClass { ...@@ -19,9 +15,6 @@ export default class LibraryPageClass extends PageComponentBaseClass {
@property(cc.Node) @property(cc.Node)
btnWatching: cc.Node = null; btnWatching: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView({ vc.toView({
...@@ -52,8 +45,11 @@ export default class LibraryPageClass extends PageComponentBaseClass { ...@@ -52,8 +45,11 @@ export default class LibraryPageClass extends PageComponentBaseClass {
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
// onLoad () {} // onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() { async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法 // 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node); super.initPageHook(this.node);
this.loading.active = true; this.loading.active = true;
......
{
"ver": "1.1.2",
"uuid": "7d7edf71-28cc-4cc2-915e-9bd2437a270f",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "92db17c9-f404-4d11-9deb-2a28f9420c7b",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util"; import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "./PageComponentBase" import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class LibraryAudioPageClass extends PageComponentBaseClass { export default class LibraryAudioPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
scrollView: cc.Node = null; scrollView: cc.Node = null;
@property(cc.Node) @property(cc.Node)
svItem: cc.Node = null; svItem: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Node) @property(cc.Node)
emptyIcon: cc.Node = null; emptyIcon: cc.Node = null;
...@@ -32,8 +25,12 @@ export default class LibraryAudioPageClass extends PageComponentBaseClass { ...@@ -32,8 +25,12 @@ export default class LibraryAudioPageClass extends PageComponentBaseClass {
} }
// onLoad () {} // onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() { async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法 // 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node); super.initPageHook(this.node);
......
{
"ver": "1.1.2",
"uuid": "784048a0-35d3-445e-bee7-b6d1d71c18f4",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "738994b7-e388-4d7d-a7e3-26273de6494f",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util"; import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "./PageComponentBase" import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class LibraryReadPageClass extends PageComponentBaseClass { export default class LibraryReadPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
scrollView: cc.Node = null; scrollView: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Node) @property(cc.Node)
emptyIcon: cc.Node = null; emptyIcon: cc.Node = null;
...@@ -31,8 +25,11 @@ export default class LibraryReadPageClass extends PageComponentBaseClass { ...@@ -31,8 +25,11 @@ export default class LibraryReadPageClass extends PageComponentBaseClass {
} }
// onLoad () {} // onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() { async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
super.initPageHook(this.node) super.initPageHook(this.node)
} }
......
{
"ver": "1.1.2",
"uuid": "6bca5ce7-a67b-48a4-9e19-ad665b45a5a3",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "1220a28c-cc24-4ae9-af36-e31f221c74e9",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util"; import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "./PageComponentBase" import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class LibraryReadDetailPageClass extends PageComponentBaseClass { export default class LibraryReadDetailPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
scrollView: cc.Node = null; scrollView: cc.Node = null;
@property(cc.Node)
svItem: cc.Node = null;
@property(cc.Node) @property(cc.Node)
loading: cc.Node = null; svItem: cc.Node = null;
@property(cc.Node) @property(cc.Node)
levelChangeBtn: cc.Node = null; levelChangeBtn: cc.Node = null;
...@@ -53,8 +48,11 @@ export default class LibraryReadDetailPageClass extends PageComponentBaseClass { ...@@ -53,8 +48,11 @@ export default class LibraryReadDetailPageClass extends PageComponentBaseClass {
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
// onLoad () {} // onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() { async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法 // 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node); super.initPageHook(this.node);
} }
......
{
"ver": "1.1.2",
"uuid": "7001dee9-7d11-4f95-a2dc-5673bbab829e",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "55289147-6265-4b73-932f-d618bfeaa90d",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util"; import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "./PageComponentBase" import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class LibraryVideoPageClass extends PageComponentBaseClass { export default class LibraryVideoPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
scrollView: cc.Node = null; scrollView: cc.Node = null;
@property(cc.Node) @property(cc.Node)
svItem: cc.Node = null; svItem: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Node) @property(cc.Node)
emptyIcon: cc.Node = null; emptyIcon: cc.Node = null;
...@@ -34,8 +28,11 @@ export default class LibraryVideoPageClass extends PageComponentBaseClass { ...@@ -34,8 +28,11 @@ export default class LibraryVideoPageClass extends PageComponentBaseClass {
} }
// onLoad () {} // onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() { async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法 // 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node); super.initPageHook(this.node);
} }
......
{
"ver": "1.1.2",
"uuid": "f730bd9b-e788-4a1f-a5b4-032d45e2e134",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "d09fd35e-d0f6-43d0-9cd8-3d4aa6b9bd8d",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -5,41 +5,34 @@ ...@@ -5,41 +5,34 @@
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "./util"; import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "../../../script/util";
import PageComponentBaseClass from "./PageComponentBase" import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class MissionPageClass extends PageComponentBaseClass { export default class MissionPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
scrollView: cc.Node = null; scrollView: cc.Node = null;
@property(cc.Node) @property(cc.Node)
listItem: cc.Node = null; listItem: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Material) @property(cc.Material)
gray: cc.Material = null; gray: cc.Material = null;
@property(cc.Node) @property(cc.Node)
btn_preview: cc.Node = null; btn_preview: cc.Node = null;
@property(cc.Node) @property(cc.Node)
btn_report: cc.Node = null; btn_report: cc.Node = null;
@property(cc.Node) @property(cc.Node)
headNode: cc.Node = null; headNode: cc.Node = null;
@property(cc.Label) @property(cc.Label)
nameLbl: cc.Label = null; nameLbl: cc.Label = null;
@property(cc.Node)
LessonPreview: cc.Node = null;
@property(cc.Node)
LessonReport: cc.Node = null;
data = []; data = [];
configData = []; configData = [];
...@@ -58,8 +51,19 @@ export default class MissionPageClass extends PageComponentBaseClass { ...@@ -58,8 +51,19 @@ export default class MissionPageClass extends PageComponentBaseClass {
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
// onLoad () {} // onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
LessonPreview: cc.Node = null;
LessonPreviewPrefab: cc.Prefab = null;
LessonReport: cc.Node = null;
LessonReportPrefab: cc.Prefab = null;
async start() { async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
this.LessonPreviewPrefab = this.node.lessonPreviewPrefab;
this.LessonReportPrefab = this.node.lessonReportPrefab;
// 调用父类中的初始化页面生命周期钩子方法 // 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node); super.initPageHook(this.node);
this.initBg() this.initBg()
...@@ -374,14 +378,19 @@ export default class MissionPageClass extends PageComponentBaseClass { ...@@ -374,14 +378,19 @@ export default class MissionPageClass extends PageComponentBaseClass {
} }
onClickOpenLessonPreview() { onClickOpenLessonPreview() {
this.LessonPreview = cc.instantiate(this.LessonPreviewPrefab)
this.LessonPreview.active = true this.LessonPreview.active = true
this.LessonPreview.getComponent("LessonPreview").setData(this.getConfigData()) this.LessonPreview.getComponent("LessonPreview").setData(this.getConfigData())
this.LessonPreview.getComponent("LessonPreview").refreshUI() this.LessonPreview.getComponent("LessonPreview").refreshUI()
this.node.addChild(this.LessonPreview)
} }
onClickOpenLessonReport() { onClickOpenLessonReport() {
this.LessonReport = cc.instantiate(this.LessonReportPrefab)
this.LessonReport.active = true this.LessonReport.active = true
this.LessonReport.getComponent("LessonReport").setData(this.getReportData()) this.LessonReport.getComponent("LessonReport").setData(this.getReportData())
this.LessonReport.getComponent("LessonReport").refreshUI() this.LessonReport.getComponent("LessonReport").refreshUI()
this.node.addChild(this.LessonReport)
} }
async onClickDebug() { async onClickDebug() {
......
{
"ver": "1.1.2",
"uuid": "3b8bef10-cf5a-4df5-84e7-4d35d05ae021",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "ad7b72f8-a6f5-4ab6-a9ce-15f10b0699e6",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -6,31 +6,23 @@ ...@@ -6,31 +6,23 @@
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncDelay } from "./util"; import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncDelay } from "../../../script/util";
import PageComponentBaseClass from "./PageComponentBase" import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class UnitPageClass extends PageComponentBaseClass { export default class UnitPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
unitScrollView: cc.Node = null; unitScrollView: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Node) @property(cc.Node)
btn_preview: cc.Node = null; btn_preview: cc.Node = null;
@property(cc.Node)
btn_works: cc.Node = null;
@property(cc.Node) @property(cc.Node)
LessonBrief: cc.Node = null; btn_works: cc.Node = null;
pData = null; pData = null;
syllabus_pid = ""; syllabus_pid = "";
handleClickBackBtn() { handleClickBackBtn() {
...@@ -45,25 +37,26 @@ export default class UnitPageClass extends PageComponentBaseClass { ...@@ -45,25 +37,26 @@ export default class UnitPageClass extends PageComponentBaseClass {
// onLoad () {} // onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
LessonBrief: cc.Node = null;
lessonBriefPrefab: cc.Prefab = null;
async start() { async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
this.lessonBriefPrefab = this.node.lessonBriefPrefab;
// 调用父类中的初始化页面生命周期钩子方法 // 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node); super.initPageHook(this.node);
this.initBg(); this.initBg();
this.listItem = cc.find("view/item", this.unitScrollView); this.listItem = cc.find("view/item", this.unitScrollView);
}
// 页面即将显示
async beforeMount() {
this.isDestroy = false;
} }
// 页面显示 // 页面显示
async mounted(data) { async mounted(data) {
this.syllabus_pid = this.setPageRouterData(this.syllabus_pid, data.syllabus_pid); this.syllabus_pid = data.syllabus_pid;
this.pData = this.setPageRouterData(this.pData, data.pData); this.pData = data.pData;
console.log(this.syllabus_pid, this.pData)
this.listItem = cc.find("view/item", this.unitScrollView); this.listItem = cc.find("view/item", this.unitScrollView);
const sv = this.unitScrollView.getComponent(cc.ScrollView); const sv = this.unitScrollView.getComponent(cc.ScrollView);
this.svContent = sv.content; this.svContent = sv.content;
...@@ -352,9 +345,11 @@ export default class UnitPageClass extends PageComponentBaseClass { ...@@ -352,9 +345,11 @@ export default class UnitPageClass extends PageComponentBaseClass {
} }
onClickPreview() { onClickPreview() {
this.LessonBrief = cc.instantiate(this.lessonBriefPrefab);
this.LessonBrief.active = true this.LessonBrief.active = true
this.LessonBrief.getComponent("LessonBrief").setData(this.configData.introduces) this.LessonBrief.getComponent("LessonBrief").setData(this.configData.introduces)
this.LessonBrief.getComponent("LessonBrief").refreshUI() this.LessonBrief.getComponent("LessonBrief").refreshUI()
this.node.addChild(this.LessonBrief)
} }
onClickMyWork(evt: cc.Event) { onClickMyWork(evt: cc.Event) {
......
{
"ver": "1.1.2",
"uuid": "569bb24d-225c-4bf5-9bf3-ee4e36f7be5d",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "78aad02e-e9e9-48d9-baa3-f0046b2987aa",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -5,17 +5,14 @@ ...@@ -5,17 +5,14 @@
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { asyncCallNetworkApiPost } from "./util"; import { asyncCallNetworkApiPost } from "../../../script/util";
import PageComponentBaseClass from "./PageComponentBase" import PageComponentBaseClass from "../../../script/PageComponentBase"
const {ccclass, property} = cc._decorator; const {ccclass, property} = cc._decorator;
@ccclass @ccclass
export default class LoginPageClass extends PageComponentBaseClass { export default class LoginPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node) @property(cc.Node)
panelNode: cc.Node = null; panelNode: cc.Node = null;
...@@ -42,7 +39,9 @@ export default class LoginPageClass extends PageComponentBaseClass { ...@@ -42,7 +39,9 @@ export default class LoginPageClass extends PageComponentBaseClass {
canClick: boolean = true; canClick: boolean = true;
isAgreement: boolean = false; isAgreement: boolean = false;
Viewer: cc.Node = null;
start () { start () {
this.Viewer = this.node.viewer;
super.initPageHook(this.node) super.initPageHook(this.node)
this.initData(); this.initData();
this.initListener(); this.initListener();
......
{
"ver": "1.1.2",
"uuid": "81955dc9-74a3-450a-a2b9-0c0a68bd471a",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "72a568ad-886d-4891-b264-31396e4476a9",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "360b689b-e2c4-45eb-a94a-14ba4f00a34f",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import {playAudioByUrl, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "./util"; import {playAudioByUrl, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "../../../script/util";
const {ccclass, property} = cc._decorator; const {ccclass, property} = cc._decorator;
......
{
"ver": "1.1.2",
"uuid": "4e8125af-dee9-488a-a251-0707b0da4f41",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{ {
"ver": "1.2.9", "ver": "1.2.9",
"uuid": "03c1b5e6-9991-4cc6-8702-213478636da2", "uuid": "6d90d390-ba53-481c-9821-55879cc26f73",
"optimizationPolicy": "AUTO", "optimizationPolicy": "AUTO",
"asyncLoadAssets": false, "asyncLoadAssets": false,
"readonly": false, "readonly": false,
......
...@@ -4,16 +4,12 @@ ...@@ -4,16 +4,12 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { playAudioByUrl, playAnimationOnNode, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "./util"; import { playAudioByUrl, playAnimationOnNode, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "../../../script/util";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class LessonPreviewClass extends cc.Component { export default class LessonPreviewClass extends cc.Component {
@property(cc.Node)
MissionPage: cc.Node = null;
@property(cc.Label) @property(cc.Label)
lessonTitle: cc.Label = null; lessonTitle: cc.Label = null;
@property(cc.Node) @property(cc.Node)
......
{
"ver": "1.1.2",
"uuid": "e72a1ec3-7d8f-49ed-9ce8-bad34f74d025",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "908ab075-174d-4592-990e-09a777c1ba24",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { playAudioByUrl, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay, dateFormate } from "./util"; import { playAudioByUrl, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay, dateFormate } from "../../../script/util";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
......
...@@ -18,37 +18,31 @@ const PageMap = { ...@@ -18,37 +18,31 @@ const PageMap = {
MissionPage: "missionPage", MissionPage: "missionPage",
} }
const prefabPath = {
LoginPage: "prefab/pages/login/LoginPage",
HomePage: "prefab/pages/Home/HomePage",
LibraryPage: "prefab/pages/Library/LibraryPage",
LibraryReadPage: "prefab/pages/LibraryRead/LibraryReadPage",
LibraryAudioPage: "prefab/pages/LibraryAudio/LibraryAudioPage",
LibraryVideoPage: "prefab/pages/LibraryVideo/LibraryVideoPage",
LibraryReadDetailPage: "prefab/pages/LibraryReadDetail/LibraryReadDetailPage",
UnitPage: "prefab/pages/Unit/UnitPage",
MissionPage: "prefab/pages/Mission/MissionPage",
}
const {ccclass, property} = cc._decorator; const {ccclass, property} = cc._decorator;
@ccclass @ccclass
export default class PageViewerClass extends cc.Component { export default class PageViewerClass extends cc.Component {
@property(cc.Node) @property(cc.Prefab)
loginPage: cc.Node = null; p_lessonPreview: cc.Prefab = null;
@property(cc.Node)
homePage: cc.Node = null;
@property(cc.Node)
libraryPage: cc.Node = null;
@property(cc.Node)
libraryReadPage: cc.Node = null;
@property(cc.Node)
libraryReadDetailPage: cc.Node = null;
@property(cc.Node)
libraryAudioPage: cc.Node = null;
@property(cc.Node)
libraryVideoPage: cc.Node = null;
@property(cc.Node) @property(cc.Prefab)
unitPage: cc.Node = null; p_lessonReport: cc.Prefab = null;
@property(cc.Node) @property(cc.Prefab)
missionPage: cc.Node = null; p_lessonBrief: cc.Prefab = null;
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
...@@ -57,7 +51,7 @@ export default class PageViewerClass extends cc.Component { ...@@ -57,7 +51,7 @@ export default class PageViewerClass extends cc.Component {
status = { status = {
} }
setStatus(key, value) { setStatus(key, value) {
this.status[key] = value; this.status[key] = value;
} }
...@@ -66,6 +60,15 @@ export default class PageViewerClass extends cc.Component { ...@@ -66,6 +60,15 @@ export default class PageViewerClass extends cc.Component {
return this.status[key]; return this.status[key];
} }
homePage: cc.Node = null;
unitPage: cc.Node = null;
loginPage: cc.Node = null;
libraryPage: cc.Node = null;
libraryReadPage: cc.Node = null;
libraryReadDetailPage: cc.Node = null;
libraryAudioPage: cc.Node = null;
libraryVideoPage: cc.Node = null;
missionPage: cc.Node = null;
// 统一管理获取用户信息接口 // 统一管理获取用户信息接口
async getUserInfo() { async getUserInfo() {
const userInfo = this.getStatus("userInfo"); const userInfo = this.getStatus("userInfo");
...@@ -130,7 +133,7 @@ export default class PageViewerClass extends cc.Component { ...@@ -130,7 +133,7 @@ export default class PageViewerClass extends cc.Component {
_currentViewName = "" _currentViewName = ""
_currentViewNode = null _currentViewNode = null
async toView(param, data = {}) { async toView(param, data = null) {
let viewName = ""; let viewName = "";
let animation = ""; let animation = "";
if(typeof param == 'object') { if(typeof param == 'object') {
...@@ -146,30 +149,46 @@ export default class PageViewerClass extends cc.Component { ...@@ -146,30 +149,46 @@ export default class PageViewerClass extends cc.Component {
return return
} }
if(!this[PageMap[viewName]]) { // if(!this[PageMap[viewName]]) {
cc.log(`没有找到viewName: ${viewName}`) // cc.log(`没有找到viewName: ${viewName}`)
return // return
// }
if(data) {
this.setStatus(`_pageData_${viewName}`, data)
} else {
data = this.getStatus(`_pageData_${viewName}`)
} }
global.middleLayer.loadPrefabByBundleName("middleLayer_for_kyxq", prefabPath[viewName], async (err, prefab) => {
// this[PageMap[viewName]] = cc.instantiate(this[`p_${PageMap[viewName]}`]);
this[PageMap[viewName]] = cc.instantiate(prefab);
this[PageMap[viewName]].attr({
viewer: this.node,
loading: cc.find("middleLayer/loading"),
lessonPreviewPrefab: this.p_lessonPreview,
lessonReportPrefab: this.p_lessonReport,
lessonBriefPrefab: this.p_lessonBrief,
})
this.node.addChild(this[PageMap[viewName]])
// 切换页面
await this.switchView(this[PageMap[viewName]], this._currentViewNode, animation);
this._currentViewName = viewName;
this._currentViewNode = this[PageMap[viewName]];
// mounted
this._currentViewNode.emit("mounted", data)
})
// 触发页面beforeMount生命周期
this[PageMap[viewName]].emit("beforeMount");
// 切换页面
await this.switchView(this[PageMap[viewName]], this._currentViewNode, animation);
this._currentViewName = viewName;
this._currentViewNode = this[PageMap[viewName]];
// mounted
this._currentViewNode.emit("mounted", data)
} }
switchView(inPage, outPage, aniType) { switchView(inPage, outPage, aniType) {
// 页面切换两秒后 执行垃圾回收 // 执行垃圾回收
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_ANDROID) { this.runGC();
setTimeout(()=>{
cc.sys.garbageCollect()
}, 2000)
}
if(inPage.active == false) { if(inPage.active == false) {
inPage.active = true inPage.active = true;
} }
if(aniType == "leftIn" || aniType == "rightIn") { if(aniType == "leftIn" || aniType == "rightIn") {
let targetX = -this.node.width; let targetX = -this.node.width;
...@@ -191,8 +210,9 @@ export default class PageViewerClass extends cc.Component { ...@@ -191,8 +210,9 @@ export default class PageViewerClass extends cc.Component {
}) })
.call(() => { .call(() => {
outPage.active = false; outPage.active = false;
outPage.emit("unmounted") outPage.emit("unmounted");
resovle(true) this.destroyPage(outPage);
resovle(true);
}) })
.start(); .start();
}) })
...@@ -216,21 +236,25 @@ export default class PageViewerClass extends cc.Component { ...@@ -216,21 +236,25 @@ export default class PageViewerClass extends cc.Component {
}) })
.call(() => { .call(() => {
outPage.active = false; outPage.active = false;
outPage.emit("unmounted") outPage.emit("unmounted");
resovle(true) this.destroyPage(outPage);
resovle(true);
}) })
.start(); .start();
}) })
} else { } else {
if(outPage) { if(outPage) {
outPage.active = false; outPage.active = false;
outPage.emit("unmounted") outPage.emit("unmounted");
this.destroyPage(outPage);
} else { } else {
// 未传移除页面 则全部移除 // 未传移除页面 则全部移除
for(let key in PageMap) { this.node.children.forEach(child=>{
this[PageMap[key]].active = false; if(child.name != inPage.name) {
this[PageMap[key]].emit("unmounted"); child.removeFromParent();
} child.destroy();
}
})
} }
inPage.active = true; inPage.active = true;
inPage.x = 0; inPage.x = 0;
...@@ -243,17 +267,37 @@ export default class PageViewerClass extends cc.Component { ...@@ -243,17 +267,37 @@ export default class PageViewerClass extends cc.Component {
} }
} }
destroyPage(node) {
node.removeFromParent();
node.destroy();
this.releaseAssets();
}
releaseAssets() {
cc.assetManager.assets.forEach(item => {
if (item.nativeUrl.indexOf(`h5template`) == -1 && item.nativeUrl.indexOf(`dist`) == -1 && item.nativeUrl.indexOf(`http`) > -1) {
console.log("Release: " + item.nativeUrl)
cc.assetManager.releaseAsset(item);
}
});
}
// 执行垃圾回收
runGC() {
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_ANDROID) {
setTimeout(()=>{
cc.sys.garbageCollect()
}, 5000)
}
}
courseBackViewName = ""; courseBackViewName = "";
courseOpen(viewName) { courseOpen(viewName) {
if(!this[PageMap[viewName]]) { if(!this[PageMap[viewName]]) {
return return
} }
// 页面切换两秒后 执行垃圾回收 // 执行垃圾回收
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_ANDROID) { this.runGC();
setTimeout(()=>{
cc.sys.garbageCollect()
}, 2000)
}
this.courseBackViewName = viewName; this.courseBackViewName = viewName;
this[PageMap[viewName]].active = false; this[PageMap[viewName]].active = false;
this[PageMap[viewName]].emit("unmounted"); this[PageMap[viewName]].emit("unmounted");
...@@ -264,6 +308,8 @@ export default class PageViewerClass extends cc.Component { ...@@ -264,6 +308,8 @@ export default class PageViewerClass extends cc.Component {
console.error("返回页面【courseBackViewName】不能为空") console.error("返回页面【courseBackViewName】不能为空")
return return
} }
// 执行垃圾回收
this.runGC();
// 触发页面beforeMount生命周期 // 触发页面beforeMount生命周期
this[PageMap[this.courseBackViewName]].emit("beforeMount"); this[PageMap[this.courseBackViewName]].emit("beforeMount");
......
...@@ -387,6 +387,42 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -387,6 +387,42 @@ export abstract class middleLayerBase extends cc.Component {
}); });
} }
/**
* 根据Bundle name装载预制体
* @param bundleName Bundle的名字
* @param prefabPath 预制体的路径
* @param callback 装载后的回调, 参数列表(error, prefab)
*/
async loadPrefabByBundleName(bundleName: string, prefabPath: string, callback: Function) {
const bundle = cc.assetManager.getBundle(bundleName);
this.showPreloadWaiting();
if(!bundle) {
cc.log(`[F: loadPrefabByBundleName] Bundle: ${bundleName} 不存在尝试远程拉取信息`)
cc.assetManager.loadBundle(bundleName, (err, bundle: cc.AssetManager.Bundle) => {
bundle.load(prefabPath, cc.Prefab, (finish, total, item) => {
this.setLoadingProgressBar(Math.floor(finish / total * 100));
}, async (err, prefab: cc.Prefab) => {
if(err) {
cc.log(`加载Prefab出错. 信息[BundleName: ${bundleName}, PrefabPath: ${prefabPath}]`)
}
callback(err, prefab)
this.hidePreloadWaiting();
});
})
} else {
bundle.load(prefabPath, cc.Prefab, (finish, total, item) => {
this.setLoadingProgressBar(Math.floor(finish / total * 100));
}, async (err, prefab: cc.Prefab) => {
if(err) {
cc.log(`加载Prefab出错. 信息[BundleName: ${bundleName}, PrefabPath: ${prefabPath}]`)
}
callback(err, prefab)
this.hidePreloadWaiting();
});
}
}
loadPageBundle(callback = null) { loadPageBundle(callback = null) {
let sceneName, version, bondleUrl = ""; let sceneName, version, bondleUrl = "";
this.getEngineInfo().then(engineInfo => { this.getEngineInfo().then(engineInfo => {
......
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