Commit f457fb4c authored by 李维's avatar 李维

优化运行内存占用

parent 07ad5cb2
...@@ -2222,7 +2222,7 @@ ...@@ -2222,7 +2222,7 @@
} }
], ],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 0,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
...@@ -5714,7 +5714,7 @@ ...@@ -5714,7 +5714,7 @@
} }
], ],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 0,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
...@@ -6661,7 +6661,7 @@ ...@@ -6661,7 +6661,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 99.4, "width": 0,
"height": 50.4 "height": 50.4
}, },
"_anchorPoint": { "_anchorPoint": {
...@@ -6917,7 +6917,7 @@ ...@@ -6917,7 +6917,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 133.48, "width": 0,
"height": 50.4 "height": 50.4
}, },
"_anchorPoint": { "_anchorPoint": {
...@@ -13501,7 +13501,7 @@ ...@@ -13501,7 +13501,7 @@
} }
], ],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 0,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
...@@ -14799,7 +14799,7 @@ ...@@ -14799,7 +14799,7 @@
"horizontal": true, "horizontal": true,
"vertical": false, "vertical": false,
"inertia": true, "inertia": true,
"brake": 0.3, "brake": 0.1,
"elastic": true, "elastic": true,
"bounceDuration": 0.23, "bounceDuration": 0.23,
"scrollEvents": [], "scrollEvents": [],
...@@ -14823,11 +14823,7 @@ ...@@ -14823,11 +14823,7 @@
"_parent": { "_parent": {
"__id__": 326 "__id__": 326
}, },
"_children": [ "_children": [],
{
"__id__": 329
}
],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
...@@ -14890,6 +14886,9 @@ ...@@ -14890,6 +14886,9 @@
"__id__": 319 "__id__": 319
}, },
"_children": [ "_children": [
{
"__id__": 327
},
{ {
"__id__": 325 "__id__": 325
} }
...@@ -14897,10 +14896,10 @@ ...@@ -14897,10 +14896,10 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 327 "__id__": 355
}, },
{ {
"__id__": 328 "__id__": 356
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -14951,78 +14950,31 @@ ...@@ -14951,78 +14950,31 @@
"groupIndex": 0, "groupIndex": 0,
"_id": "16Ee3RAltNSq6ywFjGSc+9" "_id": "16Ee3RAltNSq6ywFjGSc+9"
}, },
{
"__type__": "cc.Mask",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 326
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_spriteFrame": null,
"_type": 0,
"_segments": 64,
"_N$alphaThreshold": 0,
"_N$inverted": false,
"_id": "87fhMa41NMAroj+avlPSZC"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 326
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 40,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1920,
"_originalHeight": 0,
"_id": "becVdD2FBPx7Yq9xNFms1v"
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "item", "_name": "item",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 325 "__id__": 326
}, },
"_children": [ "_children": [
{ {
"__id__": 330 "__id__": 328
}, },
{ {
"__id__": 332 "__id__": 330
}, },
{ {
"__id__": 335 "__id__": 333
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 355 "__id__": 353
}, },
{ {
"__id__": 356 "__id__": 354
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15048,7 +15000,7 @@ ...@@ -15048,7 +15000,7 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
85.5, -874.5,
0, 0,
0, 0,
0, 0,
...@@ -15078,13 +15030,13 @@ ...@@ -15078,13 +15030,13 @@
"_name": "label", "_name": "label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 329 "__id__": 327
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 331 "__id__": 329
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15140,7 +15092,7 @@ ...@@ -15140,7 +15092,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 330 "__id__": 328
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -15175,16 +15127,16 @@ ...@@ -15175,16 +15127,16 @@
"_name": "cards", "_name": "cards",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 329 "__id__": 327
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 333 "__id__": 331
}, },
{ {
"__id__": 334 "__id__": 332
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15240,7 +15192,7 @@ ...@@ -15240,7 +15192,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 332 "__id__": 330
}, },
"_enabled": false, "_enabled": false,
"_materials": [ "_materials": [
...@@ -15272,7 +15224,7 @@ ...@@ -15272,7 +15224,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 332 "__id__": 330
}, },
"_enabled": true, "_enabled": true,
"_layoutSize": { "_layoutSize": {
...@@ -15304,29 +15256,29 @@ ...@@ -15304,29 +15256,29 @@
"_name": "sub_item", "_name": "sub_item",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 329 "__id__": 327
}, },
"_children": [ "_children": [
{ {
"__id__": 336 "__id__": 334
}, },
{ {
"__id__": 343 "__id__": 341
}, },
{ {
"__id__": 345 "__id__": 343
}, },
{ {
"__id__": 349 "__id__": 347
}, },
{ {
"__id__": 350 "__id__": 348
} }
], ],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 354 "__id__": 352
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15382,14 +15334,14 @@ ...@@ -15382,14 +15334,14 @@
"_name": "point", "_name": "point",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 335 "__id__": 333
}, },
"_children": [ "_children": [
{ {
"__id__": 337 "__id__": 335
}, },
{ {
"__id__": 339 "__id__": 337
} }
], ],
"_active": true, "_active": true,
...@@ -15447,13 +15399,13 @@ ...@@ -15447,13 +15399,13 @@
"_name": "bg", "_name": "bg",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 336 "__id__": 334
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 338 "__id__": 336
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15509,7 +15461,7 @@ ...@@ -15509,7 +15461,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 337 "__id__": 335
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -15541,17 +15493,17 @@ ...@@ -15541,17 +15493,17 @@
"_name": "blue", "_name": "blue",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 336 "__id__": 334
}, },
"_children": [ "_children": [
{ {
"__id__": 340 "__id__": 338
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 342 "__id__": 340
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15607,13 +15559,13 @@ ...@@ -15607,13 +15559,13 @@
"_name": "icon_check", "_name": "icon_check",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 339 "__id__": 337
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 341 "__id__": 339
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15669,7 +15621,7 @@ ...@@ -15669,7 +15621,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 340 "__id__": 338
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -15701,7 +15653,7 @@ ...@@ -15701,7 +15653,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 339 "__id__": 337
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -15733,13 +15685,13 @@ ...@@ -15733,13 +15685,13 @@
"_name": "label", "_name": "label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 335 "__id__": 333
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 344 "__id__": 342
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15795,7 +15747,7 @@ ...@@ -15795,7 +15747,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 343 "__id__": 341
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -15830,17 +15782,17 @@ ...@@ -15830,17 +15782,17 @@
"_name": "mask", "_name": "mask",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 335 "__id__": 333
}, },
"_children": [ "_children": [
{ {
"__id__": 346 "__id__": 344
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 348 "__id__": 346
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15896,13 +15848,13 @@ ...@@ -15896,13 +15848,13 @@
"_name": "pic_frame", "_name": "pic_frame",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 345 "__id__": 343
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 347 "__id__": 345
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -15958,7 +15910,7 @@ ...@@ -15958,7 +15910,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 346 "__id__": 344
}, },
"_enabled": false, "_enabled": false,
"_materials": [ "_materials": [
...@@ -15990,7 +15942,7 @@ ...@@ -15990,7 +15942,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 345 "__id__": 343
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -16012,7 +15964,7 @@ ...@@ -16012,7 +15964,7 @@
"_name": "pint_layer", "_name": "pint_layer",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 335 "__id__": 333
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
...@@ -16070,17 +16022,17 @@ ...@@ -16070,17 +16022,17 @@
"_name": "bg_cover_mask", "_name": "bg_cover_mask",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 335 "__id__": 333
}, },
"_children": [ "_children": [
{ {
"__id__": 351 "__id__": 349
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 353 "__id__": 351
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -16136,13 +16088,13 @@ ...@@ -16136,13 +16088,13 @@
"_name": "icon_lock", "_name": "icon_lock",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 350 "__id__": 348
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 352 "__id__": 350
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -16198,7 +16150,7 @@ ...@@ -16198,7 +16150,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 351 "__id__": 349
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -16230,7 +16182,7 @@ ...@@ -16230,7 +16182,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 350 "__id__": 348
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -16262,7 +16214,7 @@ ...@@ -16262,7 +16214,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 335 "__id__": 333
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -16294,7 +16246,7 @@ ...@@ -16294,7 +16246,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 329 "__id__": 327
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -16326,7 +16278,7 @@ ...@@ -16326,7 +16278,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 329 "__id__": 327
}, },
"_enabled": true, "_enabled": true,
"_layoutSize": { "_layoutSize": {
...@@ -16353,6 +16305,53 @@ ...@@ -16353,6 +16305,53 @@
"_N$affectedByScale": false, "_N$affectedByScale": false,
"_id": "78jW+6mPJHeJ7L1xUmTDvX" "_id": "78jW+6mPJHeJ7L1xUmTDvX"
}, },
{
"__type__": "cc.Mask",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 326
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_spriteFrame": null,
"_type": 0,
"_segments": 64,
"_N$alphaThreshold": 0,
"_N$inverted": false,
"_id": "87fhMa41NMAroj+avlPSZC"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 326
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 40,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1920,
"_originalHeight": 0,
"_id": "becVdD2FBPx7Yq9xNFms1v"
},
{ {
"__type__": "cc.Layout", "__type__": "cc.Layout",
"_name": "", "_name": "",
...@@ -18386,7 +18385,7 @@ ...@@ -18386,7 +18385,7 @@
} }
], ],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 0,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
...@@ -34699,7 +34698,7 @@ ...@@ -34699,7 +34698,7 @@
} }
], ],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 0,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
...@@ -36567,7 +36566,7 @@ ...@@ -36567,7 +36566,7 @@
} }
], ],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 0,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
...@@ -39148,7 +39147,7 @@ ...@@ -39148,7 +39147,7 @@
} }
], ],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 0,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
...@@ -43629,7 +43628,7 @@ ...@@ -43629,7 +43628,7 @@
} }
], ],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 0,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
...@@ -46176,7 +46175,7 @@ ...@@ -46176,7 +46175,7 @@
} }
], ],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 0,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
......
...@@ -45,7 +45,6 @@ export default class MissionPageClass extends PageComponentBaseClass { ...@@ -45,7 +45,6 @@ export default class MissionPageClass extends PageComponentBaseClass {
configData = []; configData = [];
userInfo = null userInfo = null
nameLblStr = ""; nameLblStr = "";
headSprStr = "";
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
...@@ -76,6 +75,15 @@ export default class MissionPageClass extends PageComponentBaseClass { ...@@ -76,6 +75,15 @@ export default class MissionPageClass extends PageComponentBaseClass {
// unitConfigData 是从Unit层传进来的config配置参数,如果是从模板返回到Mission层,这个配置文件是没有的 // unitConfigData 是从Unit层传进来的config配置参数,如果是从模板返回到Mission层,这个配置文件是没有的
const customBgUrl = unitConfigData && unitConfigData.mission_bg_url ? unitConfigData.mission_bg_url : ""; const customBgUrl = unitConfigData && unitConfigData.mission_bg_url ? unitConfigData.mission_bg_url : "";
this.initCustomBg(customBgUrl); this.initCustomBg(customBgUrl);
const headSprStr = unitConfigData && unitConfigData.teacher_avatar ? unitConfigData.teacher_avatar : "";
if(headSprStr) {
getSprNodeByUrl(headSprStr, (spr) => {
this.headNode.addChild(spr.node);
spr.srcBlendFactor = cc.macro.BlendFactor.ONE;
setSprNodeMaxLen(spr.node, this.headNode.width, this.headNode.height);
this.headNode.active = true;
});
}
this.loading.active = true; this.loading.active = true;
this.scrollView.opacity = 0; this.scrollView.opacity = 0;
...@@ -125,12 +133,17 @@ export default class MissionPageClass extends PageComponentBaseClass { ...@@ -125,12 +133,17 @@ export default class MissionPageClass extends PageComponentBaseClass {
let _data = JSON.parse(rows[0].data) let _data = JSON.parse(rows[0].data)
this.configData = _data.pages; this.configData = _data.pages;
this.nameLblStr = _data.title; this.nameLblStr = _data.title;
this.headSprStr = _data.teacher_avatar;
bgImageUrl = _data.bg_image_url; bgImageUrl = _data.bg_image_url;
} }
} }
this.refreshConfig() if (this.configData && this.configData.length > 0) {
this.btn_preview.active = true;
this.headNode.active = false;
} else {
this.btn_preview.active = false;
this.headNode.active = false;
}
// 数据汇报 // 数据汇报
if (this.node["pData"] && this.node["pData"].id != null) { if (this.node["pData"] && this.node["pData"].id != null) {
...@@ -147,22 +160,6 @@ export default class MissionPageClass extends PageComponentBaseClass { ...@@ -147,22 +160,6 @@ export default class MissionPageClass extends PageComponentBaseClass {
} }
} }
refreshConfig() {
if (this.configData && this.configData.length > 0) {
this.btn_preview.active = true;
this.headNode.active = false;
getSprNodeByUrl(this.headSprStr, (spr) => {
this.headNode.addChild(spr.node);
spr.srcBlendFactor = cc.macro.BlendFactor.ONE;
setSprNodeMaxLen(spr.node, this.headNode.width, this.headNode.height);
this.headNode.active = true;
});
} else {
this.btn_preview.active = false;
this.headNode.active = false;
}
}
getConfigData() { getConfigData() {
return this.configData return this.configData
} }
......
...@@ -20,16 +20,16 @@ export default class PageComponentBaseClass extends cc.Component { ...@@ -20,16 +20,16 @@ export default class PageComponentBaseClass extends cc.Component {
initPageHook(node: cc.Node) { initPageHook(node: cc.Node) {
// 注册PageViwer发来的beforeMount事件 [页面即将被显示] // 注册PageViwer发来的beforeMount事件 [页面即将被显示]
node.on("beforeMount", ()=>this.beforeMount()); node.on("beforeMount", (data)=>this.beforeMount(data));
// 注册PageViwer发来的mounted事件 [页面已经切换完毕] // 注册PageViwer发来的mounted事件 [页面已经切换完毕]
node.on("mounted", ()=>this.mounted()); node.on("mounted", (data)=>this.mounted(data));
// 注册PageViwer发来的unmounted事件 [页面已经切换完毕] // 注册PageViwer发来的unmounted事件 [页面已经切换完毕]
node.on("unmounted", ()=>this.unmounted()); node.on("unmounted", (data)=>this.unmounted(data));
} }
// 页面即将被显示 // 页面即将被显示
beforeMount() {} beforeMount(data) {}
mounted() {} mounted(data) {}
unmounted() {} unmounted(data) {}
// update (dt) {} // update (dt) {}
} }
...@@ -162,14 +162,23 @@ export default class PageViewerClass extends cc.Component { ...@@ -162,14 +162,23 @@ export default class PageViewerClass extends cc.Component {
} }
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) {
setTimeout(()=>{
cc.sys.garbageCollect()
}, 2000)
}
if(inPage.active == false) {
inPage.active = true
}
if(aniType == "leftIn" || aniType == "rightIn") { if(aniType == "leftIn" || aniType == "rightIn") {
let targetX = -this.node.width; let targetX = -this.node.width;
if(aniType == "leftIn") { if(aniType == "leftIn") {
targetX = -targetX targetX = -targetX
} }
inPage.active = true; inPage.opacity = 255;
inPage.x = -targetX; inPage.x = -targetX;
outPage.active = true; outPage.opacity = 255;
cc.tween(inPage) cc.tween(inPage)
.to(0.2, { .to(0.2, {
x: 0 x: 0
...@@ -181,7 +190,7 @@ export default class PageViewerClass extends cc.Component { ...@@ -181,7 +190,7 @@ export default class PageViewerClass extends cc.Component {
x: targetX x: targetX
}) })
.call(() => { .call(() => {
outPage.active = false; outPage.opacity = 0;
outPage.emit("unmounted") outPage.emit("unmounted")
resovle(true) resovle(true)
}) })
...@@ -193,8 +202,8 @@ export default class PageViewerClass extends cc.Component { ...@@ -193,8 +202,8 @@ export default class PageViewerClass extends cc.Component {
targetY = -targetY targetY = -targetY
} }
inPage.y = -targetY; inPage.y = -targetY;
inPage.active = true; inPage.opacity = 255;
outPage.active = true; outPage.opacity = 255;
cc.tween(inPage) cc.tween(inPage)
.to(0.2, { .to(0.2, {
y: 0 y: 0
...@@ -206,7 +215,7 @@ export default class PageViewerClass extends cc.Component { ...@@ -206,7 +215,7 @@ export default class PageViewerClass extends cc.Component {
y: targetY y: targetY
}) })
.call(() => { .call(() => {
outPage.active = false; outPage.opacity = 0;
outPage.emit("unmounted") outPage.emit("unmounted")
resovle(true) resovle(true)
}) })
...@@ -214,16 +223,16 @@ export default class PageViewerClass extends cc.Component { ...@@ -214,16 +223,16 @@ export default class PageViewerClass extends cc.Component {
}) })
} else { } else {
if(outPage) { if(outPage) {
outPage.active = false; outPage.opacity = 0;
outPage.emit("unmounted") outPage.emit("unmounted")
} else { } else {
// 未传移除页面 则全部移除 // 未传移除页面 则全部移除
for(let key in PageMap) { for(let key in PageMap) {
this[PageMap[key]].active = false; this[PageMap[key]].opacity = 0;
this[PageMap[key]].emit("unmounted"); this[PageMap[key]].emit("unmounted");
} }
} }
inPage.active = true; inPage.opacity = 255;
inPage.x = 0; inPage.x = 0;
inPage.y = 0; inPage.y = 0;
return new Promise((resovle, reject)=>{ return new Promise((resovle, reject)=>{
...@@ -232,6 +241,7 @@ export default class PageViewerClass extends cc.Component { ...@@ -232,6 +241,7 @@ export default class PageViewerClass extends cc.Component {
}, 200) }, 200)
}) })
} }
} }
// update (dt) {} // update (dt) {}
} }
...@@ -48,30 +48,34 @@ export default class UnitPageClass extends PageComponentBaseClass { ...@@ -48,30 +48,34 @@ export default class UnitPageClass extends PageComponentBaseClass {
// 调用父类中的初始化页面生命周期钩子方法 // 调用父类中的初始化页面生命周期钩子方法
super.initPageHook(this.node); super.initPageHook(this.node);
this.initBg(); this.initBg();
this.listItem = cc.find("view/content/item", this.unitScrollView); this.listItem = cc.find("view/item", this.unitScrollView);
} }
// 页面即将显示 // 页面即将显示
async beforeMount() { async beforeMount() {
this.isDestory = false; this.isDestory = false;
const svNode = this.unitScrollView;
const sv = svNode.getComponent(cc.ScrollView);
const content = sv.content;
content.removeAllChildren();
} }
// 页面显示 // 页面显示
async mounted() { async mounted() {
this.listItem = cc.find("view/item", this.unitScrollView);
const sv = this.unitScrollView.getComponent(cc.ScrollView);
this.svContent = sv.content;
await this.initView(); await this.initView();
} }
// 页面隐藏 // 页面隐藏
isDestory = false; isDestory = false;
async unmounted() { async unmounted() {
const sv = cc.find("middleLayer/Views/UnitPage/unit_list_node/scrollView") const content = this.svContent;
sv.off("scrolling") this.unitScrollView.off("scrolling")
content.destroyAllChildren();
this.isDestory = true; this.isDestory = true;
this.lastUpdate = 0; this.lastUpdate = 0;
this.allListItemNodes.forEach(node => {
node && node.destroy()
})
this.allListItemNodes = []; this.allListItemNodes = [];
} }
...@@ -187,9 +191,7 @@ export default class UnitPageClass extends PageComponentBaseClass { ...@@ -187,9 +191,7 @@ export default class UnitPageClass extends PageComponentBaseClass {
this.allListItemNodes = []; this.allListItemNodes = [];
const svNode = this.unitScrollView; const svNode = this.unitScrollView;
svNode.opacity = 0; svNode.opacity = 0;
const n1Date = new Date()
const resData = await this.Viewer.getComponent("PageViewer").getSyllabusTreeByPid(this.node['syllabus_pid']) const resData = await this.Viewer.getComponent("PageViewer").getSyllabusTreeByPid(this.node['syllabus_pid'])
console.log("接口SyllabusTree`响应时间:", new Date() - n1Date)
let rows = [] let rows = []
this.configData = null this.configData = null
let bgImageUrl = null; let bgImageUrl = null;
...@@ -206,29 +208,20 @@ export default class UnitPageClass extends PageComponentBaseClass { ...@@ -206,29 +208,20 @@ export default class UnitPageClass extends PageComponentBaseClass {
} }
if (rows.length == 0) { if (rows.length == 0) {
const svNode = this.unitScrollView; this.svContent.destroyAllChildren();
const sv = svNode.getComponent(cc.ScrollView);
const content = sv.content;
content.removeAllChildren();
return; return;
} }
this.initCustomBg(bgImageUrl); this.initCustomBg(bgImageUrl);
const n2Date = new Date()
await this.getAndStoreSyllabusStatus(rows); await this.getAndStoreSyllabusStatus(rows);
console.log("接口SyllabusStatus响应时间:", new Date() - n2Date)
// const svNode = this.unitScrollView; // const svNode = this.unitScrollView;
const view = cc.find("view", svNode); const view = cc.find("view", svNode);
view.width = svNode.width; view.width = svNode.width;
view.height = svNode.height; view.height = svNode.height;
const nowDate = new Date();
const sv = svNode.getComponent(cc.ScrollView); const sv = svNode.getComponent(cc.ScrollView);
this.getUnitItemDataArr(rows, sv); this.getUnitItemDataArr(rows, sv);
const time = new Date() - nowDate
console.log("创建节点时间: ", time)
svNode.opacity = 255; svNode.opacity = 255;
this.refreshConfig() this.refreshConfig()
} }
...@@ -243,15 +236,13 @@ export default class UnitPageClass extends PageComponentBaseClass { ...@@ -243,15 +236,13 @@ export default class UnitPageClass extends PageComponentBaseClass {
} }
listItem; listItem;
g_content = null; svContent = null;
async getUnitItemDataArr(dataArr, sv) { async getUnitItemDataArr(dataArr, sv) {
const content = this.g_content = sv.content; const content = sv.content;
content.removeAllChildren();
sv.scrollToTop(); sv.scrollToTop();
content.width = sv.node.width; content.width = sv.node.width;
content.height = sv.node.height; content.height = sv.node.height;
content.removeAllChildren();
let listItem = this.listItem; let listItem = this.listItem;
let subItem = cc.find("/sub_item", listItem); let subItem = cc.find("/sub_item", listItem);
...@@ -263,6 +254,7 @@ export default class UnitPageClass extends PageComponentBaseClass { ...@@ -263,6 +254,7 @@ export default class UnitPageClass extends PageComponentBaseClass {
} }
const data = dataArr[i]; const data = dataArr[i];
const itemNode = cc.instantiate(listItem); const itemNode = cc.instantiate(listItem);
itemNode.active = true;
const cardsContainer = cc.find("/cards", itemNode) const cardsContainer = cc.find("/cards", itemNode)
let listLabel = cc.find("/label", itemNode); let listLabel = cc.find("/label", itemNode);
itemNode['data'] = data; itemNode['data'] = data;
...@@ -364,8 +356,11 @@ export default class UnitPageClass extends PageComponentBaseClass { ...@@ -364,8 +356,11 @@ export default class UnitPageClass extends PageComponentBaseClass {
lastUpdate = 0; lastUpdate = 0;
update (dt) { update (dt) {
if(this.isDestory) {
return
}
if(this.lastUpdate < this.allListItemNodes.length) { if(this.lastUpdate < this.allListItemNodes.length) {
this.allListItemNodes[this.lastUpdate++].parent = this.g_content this.allListItemNodes[this.lastUpdate++].parent = this.svContent
} }
} }
} }
......
...@@ -116,7 +116,6 @@ export function playAudioByUrl(audio_url, cb = null) { ...@@ -116,7 +116,6 @@ export function playAudioByUrl(audio_url, cb = null) {
} }
} }
export function btnClickAnima(btn, time = 0.15, rate = 1.05) { export function btnClickAnima(btn, time = 0.15, rate = 1.05) {
btn.tmpScale = btn.scale; btn.tmpScale = btn.scale;
btn.on(cc.Node.EventType.TOUCH_START, () => { btn.on(cc.Node.EventType.TOUCH_START, () => {
...@@ -138,12 +137,15 @@ export function btnClickAnima(btn, time = 0.15, rate = 1.05) { ...@@ -138,12 +137,15 @@ export function btnClickAnima(btn, time = 0.15, rate = 1.05) {
export function getSpriteFrimeByUrl(url, cb) { export function getSpriteFrimeByUrl(url, cb) {
cc.loader.load({ url }, (err, img) => { if(!url) {
const spriteFrame = new cc.SpriteFrame(img) return
}
cc.assetManager.loadRemote(url, (error, texture2D) => {
const spriteFrame = new cc.SpriteFrame(texture2D)
if (cb) { if (cb) {
cb(spriteFrame); cb(spriteFrame);
} }
}) });
} }
export function appearAnim(node, time=1, callback=null) { export function appearAnim(node, time=1, callback=null) {
......
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