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

修改页面为预制体

降低内存占用
parent cb8e5ca8
No preview for this file type
{
"ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"isBundle": true,
"bundleName": "middleLayer_for_kyxq",
"priority": 1,
"compressionType": {
"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 PageComponentBaseClass from "./PageComponentBase"
import { asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, playLocalAudio, playAudioByUrl, getSprNodeByUrl, asyncDelay } from "../../../script/util";
import PageComponentBaseClass from "../../../script/PageComponentBase";
const { ccclass, property } = cc._decorator;
@ccclass
export default class HomePageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
userPage: cc.Node = null;
......@@ -22,11 +20,9 @@ export default class HomePageClass extends PageComponentBaseClass {
@property(cc.Node)
SvContent: cc.Node = null;
@property(cc.Node)
Viewer: cc.Node = null;
loading: cc.Node = null;
_inited = false;
// 点击用户中心
handleClickUserCenter() {
this.userPage.active = true;
......@@ -234,23 +230,25 @@ export default class HomePageClass extends PageComponentBaseClass {
}
async start() {
console.log("start")
console.log(this.node)
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node);
this.initBg();
}
async beforeMount() {
this.SvContent.removeAllChildren();
}
async mounted() {
console.log("mounted")
await this.getUserInfo();
await this.getCourseList();
this.initTopUserPanel();
}
async onEnable() {
async unmounted(data: any) {
console.log("unmounted")
this.SvContent.removeAllChildren();
}
// update (dt) {}
}
......@@ -10,8 +10,6 @@ const {ccclass, property} = cc._decorator;
@ccclass
export default class UserPageClass extends cc.Component {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
infoPanel: cc.Node = null;
......@@ -21,13 +19,13 @@ export default class UserPageClass extends cc.Component {
// onLoad () {}
Viewer: cc.Node = null;
_canTouch = false;
async start () {
console.log("User start")
this._canTouch = true;
this.initDeleteAccoutBtn();
}
protected onEnable(): void {
console.log(this.node)
this.Viewer = this.node.parent.viewer;
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 PageComponentBaseClass from "./PageComponentBase"
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator;
@ccclass
export default class LibraryPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
btnReading: cc.Node = null;
......@@ -19,9 +15,6 @@ export default class LibraryPageClass extends PageComponentBaseClass {
@property(cc.Node)
btnWatching: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer");
vc.toView({
......@@ -52,8 +45,11 @@ export default class LibraryPageClass extends PageComponentBaseClass {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node);
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 PageComponentBaseClass from "./PageComponentBase"
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator;
@ccclass
export default class LibraryAudioPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
scrollView: cc.Node = null;
@property(cc.Node)
svItem: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Node)
emptyIcon: cc.Node = null;
......@@ -32,8 +25,12 @@ export default class LibraryAudioPageClass extends PageComponentBaseClass {
}
// onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法
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 PageComponentBaseClass from "./PageComponentBase"
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator;
@ccclass
export default class LibraryReadPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
scrollView: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Node)
emptyIcon: cc.Node = null;
......@@ -31,8 +25,11 @@ export default class LibraryReadPageClass extends PageComponentBaseClass {
}
// onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
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 PageComponentBaseClass from "./PageComponentBase"
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator;
@ccclass
export default class LibraryReadDetailPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
scrollView: cc.Node = null;
@property(cc.Node)
svItem: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
svItem: cc.Node = null;
@property(cc.Node)
levelChangeBtn: cc.Node = null;
......@@ -53,8 +48,11 @@ export default class LibraryReadDetailPageClass extends PageComponentBaseClass {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法
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 PageComponentBaseClass from "./PageComponentBase"
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "../../../script/util";
import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator;
@ccclass
export default class LibraryVideoPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
scrollView: cc.Node = null;
@property(cc.Node)
svItem: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Node)
emptyIcon: cc.Node = null;
......@@ -34,8 +28,11 @@ export default class LibraryVideoPageClass extends PageComponentBaseClass {
}
// onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
// 调用父类中的初始化页面生命周期钩子方法
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 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "./util";
import PageComponentBaseClass from "./PageComponentBase"
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "../../../script/util";
import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator;
@ccclass
export default class MissionPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
scrollView: cc.Node = null;
@property(cc.Node)
listItem: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Material)
gray: cc.Material = null;
@property(cc.Node)
btn_preview: cc.Node = null;
@property(cc.Node)
btn_report: cc.Node = null;
@property(cc.Node)
headNode: cc.Node = null;
@property(cc.Label)
nameLbl: cc.Label = null;
@property(cc.Node)
LessonPreview: cc.Node = null;
@property(cc.Node)
LessonReport: cc.Node = null;
data = [];
configData = [];
......@@ -58,8 +51,19 @@ export default class MissionPageClass extends PageComponentBaseClass {
// LIFE-CYCLE CALLBACKS:
// 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() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
this.LessonPreviewPrefab = this.node.lessonPreviewPrefab;
this.LessonReportPrefab = this.node.lessonReportPrefab;
// 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node);
this.initBg()
......@@ -374,14 +378,19 @@ export default class MissionPageClass extends PageComponentBaseClass {
}
onClickOpenLessonPreview() {
this.LessonPreview = cc.instantiate(this.LessonPreviewPrefab)
this.LessonPreview.active = true
this.LessonPreview.getComponent("LessonPreview").setData(this.getConfigData())
this.LessonPreview.getComponent("LessonPreview").refreshUI()
this.node.addChild(this.LessonPreview)
}
onClickOpenLessonReport() {
this.LessonReport = cc.instantiate(this.LessonReportPrefab)
this.LessonReport.active = true
this.LessonReport.getComponent("LessonReport").setData(this.getReportData())
this.LessonReport.getComponent("LessonReport").refreshUI()
this.node.addChild(this.LessonReport)
}
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,30 +6,22 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncDelay } from "./util";
import PageComponentBaseClass from "./PageComponentBase"
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncDelay } from "../../../script/util";
import PageComponentBaseClass from "../../../script/PageComponentBase"
const { ccclass, property } = cc._decorator;
@ccclass
export default class UnitPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
unitScrollView: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
@property(cc.Node)
btn_preview: cc.Node = null;
@property(cc.Node)
btn_works: cc.Node = null;
@property(cc.Node)
LessonBrief: cc.Node = null;
btn_works: cc.Node = null;
pData = null;
syllabus_pid = "";
......@@ -45,25 +37,26 @@ export default class UnitPageClass extends PageComponentBaseClass {
// onLoad () {}
Viewer: cc.Node = null;
loading: cc.Node = null;
LessonBrief: cc.Node = null;
lessonBriefPrefab: cc.Prefab = null;
async start() {
this.Viewer = this.node.viewer;
this.loading = this.node.loading;
this.lessonBriefPrefab = this.node.lessonBriefPrefab;
// 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node);
this.initBg();
this.listItem = cc.find("view/item", this.unitScrollView);
}
// 页面即将显示
async beforeMount() {
this.isDestroy = false;
}
// 页面显示
async mounted(data) {
this.syllabus_pid = this.setPageRouterData(this.syllabus_pid, data.syllabus_pid);
this.pData = this.setPageRouterData(this.pData, data.pData);
this.syllabus_pid = data.syllabus_pid;
this.pData = data.pData;
console.log(this.syllabus_pid, this.pData)
this.listItem = cc.find("view/item", this.unitScrollView);
const sv = this.unitScrollView.getComponent(cc.ScrollView);
this.svContent = sv.content;
......@@ -352,9 +345,11 @@ export default class UnitPageClass extends PageComponentBaseClass {
}
onClickPreview() {
this.LessonBrief = cc.instantiate(this.lessonBriefPrefab);
this.LessonBrief.active = true
this.LessonBrief.getComponent("LessonBrief").setData(this.configData.introduces)
this.LessonBrief.getComponent("LessonBrief").refreshUI()
this.node.addChild(this.LessonBrief)
}
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 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { asyncCallNetworkApiPost } from "./util";
import PageComponentBaseClass from "./PageComponentBase"
import { asyncCallNetworkApiPost } from "../../../script/util";
import PageComponentBaseClass from "../../../script/PageComponentBase"
const {ccclass, property} = cc._decorator;
@ccclass
export default class LoginPageClass extends PageComponentBaseClass {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
panelNode: cc.Node = null;
......@@ -42,7 +39,9 @@ export default class LoginPageClass extends PageComponentBaseClass {
canClick: boolean = true;
isAgreement: boolean = false;
Viewer: cc.Node = null;
start () {
this.Viewer = this.node.viewer;
super.initPageHook(this.node)
this.initData();
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 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - 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;
......
{
"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",
"uuid": "03c1b5e6-9991-4cc6-8702-213478636da2",
"uuid": "6d90d390-ba53-481c-9821-55879cc26f73",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
......
......@@ -4,16 +4,12 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - 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;
@ccclass
export default class LessonPreviewClass extends cc.Component {
@property(cc.Node)
MissionPage: cc.Node = null;
@property(cc.Label)
lessonTitle: cc.Label = null;
@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 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - 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;
@ccclass
......
......@@ -18,37 +18,31 @@ const PageMap = {
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;
@ccclass
export default class PageViewerClass extends cc.Component {
@property(cc.Node)
loginPage: cc.Node = 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.Prefab)
p_lessonPreview: cc.Prefab = null;
@property(cc.Node)
unitPage: cc.Node = null;
@property(cc.Prefab)
p_lessonReport: cc.Prefab = null;
@property(cc.Node)
missionPage: cc.Node = null;
@property(cc.Prefab)
p_lessonBrief: cc.Prefab = null;
// LIFE-CYCLE CALLBACKS:
......@@ -66,6 +60,15 @@ export default class PageViewerClass extends cc.Component {
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() {
const userInfo = this.getStatus("userInfo");
......@@ -130,7 +133,7 @@ export default class PageViewerClass extends cc.Component {
_currentViewName = ""
_currentViewNode = null
async toView(param, data = {}) {
async toView(param, data = null) {
let viewName = "";
let animation = "";
if(typeof param == 'object') {
......@@ -146,30 +149,46 @@ export default class PageViewerClass extends cc.Component {
return
}
if(!this[PageMap[viewName]]) {
cc.log(`没有找到viewName: ${viewName}`)
return
// if(!this[PageMap[viewName]]) {
// cc.log(`没有找到viewName: ${viewName}`)
// return
// }
if(data) {
this.setStatus(`_pageData_${viewName}`, data)
} else {
data = this.getStatus(`_pageData_${viewName}`)
}
// 触发页面beforeMount生命周期
this[PageMap[viewName]].emit("beforeMount");
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)
})
}
switchView(inPage, outPage, aniType) {
// 页面切换两秒后 执行垃圾回收
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_ANDROID) {
setTimeout(()=>{
cc.sys.garbageCollect()
}, 2000)
}
// 执行垃圾回收
this.runGC();
if(inPage.active == false) {
inPage.active = true
inPage.active = true;
}
if(aniType == "leftIn" || aniType == "rightIn") {
let targetX = -this.node.width;
......@@ -191,8 +210,9 @@ export default class PageViewerClass extends cc.Component {
})
.call(() => {
outPage.active = false;
outPage.emit("unmounted")
resovle(true)
outPage.emit("unmounted");
this.destroyPage(outPage);
resovle(true);
})
.start();
})
......@@ -216,21 +236,25 @@ export default class PageViewerClass extends cc.Component {
})
.call(() => {
outPage.active = false;
outPage.emit("unmounted")
resovle(true)
outPage.emit("unmounted");
this.destroyPage(outPage);
resovle(true);
})
.start();
})
} else {
if(outPage) {
outPage.active = false;
outPage.emit("unmounted")
outPage.emit("unmounted");
this.destroyPage(outPage);
} else {
// 未传移除页面 则全部移除
for(let key in PageMap) {
this[PageMap[key]].active = false;
this[PageMap[key]].emit("unmounted");
this.node.children.forEach(child=>{
if(child.name != inPage.name) {
child.removeFromParent();
child.destroy();
}
})
}
inPage.active = true;
inPage.x = 0;
......@@ -243,17 +267,37 @@ export default class PageViewerClass extends cc.Component {
}
}
courseBackViewName = "";
courseOpen(viewName) {
if(!this[PageMap[viewName]]) {
return
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()
}, 2000)
}, 5000)
}
}
courseBackViewName = "";
courseOpen(viewName) {
if(!this[PageMap[viewName]]) {
return
}
// 执行垃圾回收
this.runGC();
this.courseBackViewName = viewName;
this[PageMap[viewName]].active = false;
this[PageMap[viewName]].emit("unmounted");
......@@ -264,6 +308,8 @@ export default class PageViewerClass extends cc.Component {
console.error("返回页面【courseBackViewName】不能为空")
return
}
// 执行垃圾回收
this.runGC();
// 触发页面beforeMount生命周期
this[PageMap[this.courseBackViewName]].emit("beforeMount");
......
......@@ -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) {
let sceneName, version, bondleUrl = "";
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