Commit 774e1f7e authored by 范雪寒's avatar 范雪寒

style: 格式化

parent 1720e51d
...@@ -3,16 +3,16 @@ cc.Class({ ...@@ -3,16 +3,16 @@ cc.Class({
properties: {}, properties: {},
getData(callBack) { getData(callBack) {
const uri = 'courseware/v1/getdata'; const uri = "courseware/v1/getdata";
let syllabus_id; let syllabus_id;
if (this.bundleType == 'StoryBox') { if (this.bundleType == "StoryBox") {
syllabus_id = this.syllabus_id; syllabus_id = this.syllabus_id;
} else if (this.bundleType == 'WW') { } else if (this.bundleType == "WW") {
syllabus_id = this.bundleInfoList[this.currentBundleIndex].syllabus_id; syllabus_id = this.bundleInfoList[this.currentBundleIndex].syllabus_id;
} }
const data = { const data = {
courseid: syllabus_id courseid: syllabus_id,
}; };
this.callNetworkApiGet(uri, data, (data) => { this.callNetworkApiGet(uri, data, (data) => {
cc.debug.setDisplayStats(false); cc.debug.setDisplayStats(false);
...@@ -21,44 +21,44 @@ cc.Class({ ...@@ -21,44 +21,44 @@ cc.Class({
}, },
onHomeworkFinish(callBack) { onHomeworkFinish(callBack) {
if (this.role == 'teacher') { if (this.role == "teacher") {
return; return;
} }
const uri = 'app_source/v1/student/homework/finished'; const uri = "app_source/v1/student/homework/finished";
const data = { const data = {
syllabus_id: this.syllabus_id, syllabus_id: this.syllabus_id,
homework_id: this.homework_id, homework_id: this.homework_id,
token: this.token, token: this.token,
score: 100 score: 100,
}; };
console.log('data = ' + JSON.stringify(data)); console.log("data = " + JSON.stringify(data));
this.callNetworkApiPost(uri, data, callBack); this.callNetworkApiPost(uri, data, callBack);
}, },
callNetworkApiGet(uri, data, callBack) { callNetworkApiGet(uri, data, callBack) {
let queryStr = ''; let queryStr = "";
for (const key in data) { for (const key in data) {
if (Object.hasOwnProperty.call(data, key)) { if (Object.hasOwnProperty.call(data, key)) {
const value = data[key]; const value = data[key];
if (queryStr == '') { if (queryStr == "") {
queryStr += '?'; queryStr += "?";
} }
if (queryStr != '?') { if (queryStr != "?") {
queryStr += '&'; queryStr += "&";
} }
queryStr += `${key}=${value}`; queryStr += `${key}=${value}`;
} }
} }
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => { xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) { if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 400) {
const responseData = JSON.parse(xhr.responseText); const responseData = JSON.parse(xhr.responseText);
callBack(responseData); callBack(responseData);
} }
}; };
const url = `${this.baseUrl}${uri}${queryStr}`; const url = `${this.baseUrl}${uri}${queryStr}`;
console.log('url = ' + url); console.log("url = " + url);
xhr.open('GET', url, true); xhr.open("GET", url, true);
xhr.send(); xhr.send();
}, },
...@@ -66,17 +66,16 @@ cc.Class({ ...@@ -66,17 +66,16 @@ cc.Class({
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
const url = `${this.baseUrl}${uri}`; const url = `${this.baseUrl}${uri}`;
xhr.open("POST", url, true); xhr.open("POST", url, true);
xhr.setRequestHeader('content-type', 'application/json'); xhr.setRequestHeader("content-type", "application/json");
xhr.onreadystatechange = () => { xhr.onreadystatechange = () => {
if (xhr.readyState == 4) { if (xhr.readyState == 4) {
callBack(JSON.parse(xhr.responseText)); callBack(JSON.parse(xhr.responseText));
} }
} };
xhr.send(JSON.stringify(data)); xhr.send(JSON.stringify(data));
}, },
start() { start() {
this.node.zIndex = 9999; this.node.zIndex = 9999;
this.showWaitingLetters(); this.showWaitingLetters();
...@@ -94,7 +93,7 @@ cc.Class({ ...@@ -94,7 +93,7 @@ cc.Class({
// }); // });
// this.bundleType = 'StoryBox'; // this.bundleType = 'StoryBox';
this.log('汪汪汪'); this.log("汪汪汪");
}, },
asyncDelayLog(str) { asyncDelayLog(str) {
...@@ -107,17 +106,21 @@ cc.Class({ ...@@ -107,17 +106,21 @@ cc.Class({
}, },
getBundleInfoList() { getBundleInfoList() {
const jsonStr = this.callNativeFunction({ name: 'loadSceneList', value: '' }); const jsonStr = this.callNativeFunction({
name: "loadSceneList",
value: "",
});
if (!jsonStr) { if (!jsonStr) {
console.error('没有jsonStr!!') console.error("没有jsonStr!!");
return; return;
} }
const { bundleInfoList, defaultBundleIdx, bundleType, bundleInfo } = JSON.parse(jsonStr); const { bundleInfoList, defaultBundleIdx, bundleType, bundleInfo } =
JSON.parse(jsonStr);
if (bundleType == 'PetRoom') { if (bundleType == "PetRoom") {
this.bundleType = 'PetRoom'; this.bundleType = "PetRoom";
this.baseUrl = bundleInfo.baseUrl; this.baseUrl = bundleInfo.baseUrl;
this.token = bundleInfo.token; this.token = bundleInfo.token;
this.homework_id = bundleInfo.homework_id; this.homework_id = bundleInfo.homework_id;
...@@ -125,19 +128,23 @@ cc.Class({ ...@@ -125,19 +128,23 @@ cc.Class({
this.role = bundleInfo.role; this.role = bundleInfo.role;
this.initPetRoomView(bundleInfo); this.initPetRoomView(bundleInfo);
} else if (bundleType == "StoryBox") { } else if (bundleType == "StoryBox") {
this.bundleType = 'StoryBox'; this.bundleType = "StoryBox";
const descLabel = cc.find('middleLayer/storyBox/menu/menuBase/title/name'); const descLabel = cc.find(
descLabel.getComponent(cc.Label).string = bundleInfo.coursewareDescription; "middleLayer/storyBox/menu/menuBase/title/name"
);
descLabel.getComponent(cc.Label).string =
bundleInfo.coursewareDescription;
const nameLabel = cc.find('middleLayer/storyBox/menu/menuBase/title/Lession'); const nameLabel = cc.find(
"middleLayer/storyBox/menu/menuBase/title/Lession"
);
nameLabel.getComponent(cc.Label).string = bundleInfo.coursewareName; nameLabel.getComponent(cc.Label).string = bundleInfo.coursewareName;
this.baseUrl = bundleInfo.baseUrl; this.baseUrl = bundleInfo.baseUrl;
this.initStoryBoxView(bundleInfo); this.initStoryBoxView(bundleInfo);
} else { } else {
this.bundleType = 'WW'; this.bundleType = "WW";
// WW模板 // WW模板
this.bundleInfoList = bundleInfoList; this.bundleInfoList = bundleInfoList;
this.jumpToBundleByIndex(defaultBundleIdx); this.jumpToBundleByIndex(defaultBundleIdx);
...@@ -153,62 +160,67 @@ cc.Class({ ...@@ -153,62 +160,67 @@ cc.Class({
this.hideWWView(); this.hideWWView();
// this.showLog(bundleInfo.coursewareId); // this.showLog(bundleInfo.coursewareId);
this.callNetworkApiGet('syllabus/v1/tree', { orgid: 483, pid: bundleInfo.coursewareId }, (data) => { this.callNetworkApiGet(
"syllabus/v1/tree",
{ orgid: 483, pid: bundleInfo.coursewareId },
(data) => {
console.log(data); console.log(data);
const defaultBondle = data.rows.find(row => row.name == '默认'); const defaultBondle = data.rows.find((row) => row.name == "默认");
if (!defaultBondle) { if (!defaultBondle) {
cc.find('middleLayer/storyBox/bg').active = true; cc.find("middleLayer/storyBox/bg").active = true;
console.error('没有默认课件!'); console.error("没有默认课件!");
return; return;
} }
cc.find('middleLayer/storyBox/bg').active = false; cc.find("middleLayer/storyBox/bg").active = false;
this.syllabus_id = defaultBondle.children[0].id; this.syllabus_id = defaultBondle.children[0].id;
this.loadBundleByConf(defaultBondle.children[0].conf, () => { this.loadBundleByConf(defaultBondle.children[0].conf, () => {
const ExitBtn = cc.find('middleLayer/storyBox/ExitBtn'); const ExitBtn = cc.find("middleLayer/storyBox/ExitBtn");
ExitBtn.active = true; ExitBtn.active = true;
}); });
this.menuItemNodeList = []; this.menuItemNodeList = [];
data.rows.filter((row) => { data.rows
return row.name != '默认'; .filter((row) => {
}).forEach((data, idx, arr) => { return row.name != "默认";
})
.forEach((data, idx, arr) => {
console.log(data.name, idx); console.log(data.name, idx);
const node = cc.instantiate(cc.find('middleLayer/menuItem')); const node = cc.instantiate(cc.find("middleLayer/menuItem"));
node.name = 'menuItem_' + idx; node.name = "menuItem_" + idx;
node.parent = cc.find('middleLayer/storyBox/menu/menuBase'); node.parent = cc.find("middleLayer/storyBox/menu/menuBase");
node.active = true; node.active = true;
node.x = 0; node.x = 0;
node.y = 50 + (arr.length - 1 - idx) * 100; node.y = 50 + (arr.length - 1 - idx) * 100;
this.menuItemNodeList.push(node); this.menuItemNodeList.push(node);
const menuBase = cc.find('bubbleBase', node); const menuBase = cc.find("bubbleBase", node);
const label = cc.find('label', node); const label = cc.find("label", node);
label.getComponent(cc.Label).string = data.name; label.getComponent(cc.Label).string = data.name;
label.active = true; label.active = true;
const labelSelected = cc.find('labelSelected', node); const labelSelected = cc.find("labelSelected", node);
labelSelected.getComponent(cc.Label).string = data.name; labelSelected.getComponent(cc.Label).string = data.name;
labelSelected.active = false; labelSelected.active = false;
const btn = cc.find('btn', node); const btn = cc.find("btn", node);
const btnLight = cc.find('btnHightLight', node); const btnLight = cc.find("btnHightLight", node);
const btnSelected = cc.find('btnSelected', node); const btnSelected = cc.find("btnSelected", node);
btn.active = true; btn.active = true;
btnLight.active = false; btnLight.active = false;
btnSelected.active = false; btnSelected.active = false;
btn.addComponent(cc.Button); btn.addComponent(cc.Button);
btn.on('click', () => { btn.on("click", () => {
console.log(data); console.log(data);
cc.tween(btn) cc.tween(btn)
.to(0.1, { scale: 1.1 }) .to(0.1, { scale: 1.1 })
.to(0.1, { scale: 1.0 }) .to(0.1, { scale: 1.0 })
.call(() => { .call(() => {
if (data.has_child == '0') { if (data.has_child == "0") {
this.hideAllSubmenu(); this.hideAllSubmenu();
this.resetAllMenu(); this.resetAllMenu();
this.hideMenu(); this.hideMenu();
...@@ -218,11 +230,11 @@ cc.Class({ ...@@ -218,11 +230,11 @@ cc.Class({
labelSelected.active = true; labelSelected.active = true;
if (!data.children[0]) { if (!data.children[0]) {
cc.find('middleLayer/storyBox/bg').active = true; cc.find("middleLayer/storyBox/bg").active = true;
console.error('沒有課件!'); console.error("沒有課件!");
return; return;
} }
cc.find('middleLayer/storyBox/bg').active = false; cc.find("middleLayer/storyBox/bg").active = false;
this.syllabus_id = data.children[0].id; this.syllabus_id = data.children[0].id;
this.loadBundleByConf(data.children[0].conf); this.loadBundleByConf(data.children[0].conf);
...@@ -241,8 +253,8 @@ cc.Class({ ...@@ -241,8 +253,8 @@ cc.Class({
.start(); .start();
}); });
btnLight.addComponent(cc.Button) btnLight.addComponent(cc.Button);
btnLight.on('click', () => { btnLight.on("click", () => {
cc.tween(btnLight) cc.tween(btnLight)
.to(0.1, { scale: 1.1 }) .to(0.1, { scale: 1.1 })
.to(0.1, { scale: 1.0 }) .to(0.1, { scale: 1.0 })
...@@ -259,27 +271,33 @@ cc.Class({ ...@@ -259,27 +271,33 @@ cc.Class({
.start(); .start();
}); });
btnSelected.addComponent(cc.Button) btnSelected.addComponent(cc.Button);
btnSelected.on('click', () => { btnSelected.on("click", () => {
this.hideMenu(); this.hideMenu();
}); });
if (data.has_child == '1') { if (data.has_child == "1") {
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
const optionNode = cc.find(`bubbleBase/bubbleBg/option_${i}`, node); const optionNode = cc.find(
`bubbleBase/bubbleBg/option_${i}`,
node
);
console.log("optionNode = " + optionNode); console.log("optionNode = " + optionNode);
optionNode.active = false; optionNode.active = false;
} }
data.children.forEach((menuData, idx) => { data.children.forEach((menuData, idx) => {
const optionNode = cc.find(`bubbleBase/bubbleBg/option_${idx}`, node); const optionNode = cc.find(
`bubbleBase/bubbleBg/option_${idx}`,
node
);
optionNode.active = true; optionNode.active = true;
const label = cc.find('label', optionNode); const label = cc.find("label", optionNode);
label.getComponent(cc.Label).string = menuData.name; label.getComponent(cc.Label).string = menuData.name;
optionNode.on('click', () => { optionNode.on("click", () => {
cc.tween(optionNode) cc.tween(optionNode)
.to(0.1, { scale: 1.05 }) .to(0.1, { scale: 1.05 })
.to(0.1, { scale: 1.00 }) .to(0.1, { scale: 1.0 })
.call(() => { .call(() => {
this.hideMenu(); this.hideMenu();
this.syllabus_id = menuData.children[0].id; this.syllabus_id = menuData.children[0].id;
...@@ -291,45 +309,47 @@ cc.Class({ ...@@ -291,45 +309,47 @@ cc.Class({
} }
}); });
this.storyBoxMenuLength = this.menuItemNodeList.filter(node => node.active).length; this.storyBoxMenuLength = this.menuItemNodeList.filter(
(node) => node.active
).length;
const titleNode = cc.find('middleLayer/storyBox/menu/menuBase/title'); const titleNode = cc.find("middleLayer/storyBox/menu/menuBase/title");
titleNode.y = 30 + this.storyBoxMenuLength * 100; titleNode.y = 30 + this.storyBoxMenuLength * 100;
const storyBox = cc.find("middleLayer/storyBox");
const storyBox = cc.find('middleLayer/storyBox');
storyBox.active = true; storyBox.active = true;
this.initStoryBoxListener(); this.initStoryBoxListener();
}); }
);
}, },
hideAllSubmenu() { hideAllSubmenu() {
this.menuItemNodeList.forEach(node => { this.menuItemNodeList.forEach((node) => {
const menuBase = cc.find('bubbleBase', node); const menuBase = cc.find("bubbleBase", node);
menuBase.active = false; menuBase.active = false;
}); });
}, },
resetAllMenu() { resetAllMenu() {
this.menuItemNodeList.forEach(node => { this.menuItemNodeList.forEach((node) => {
const btn = cc.find('btn', node); const btn = cc.find("btn", node);
const btnLight = cc.find('btnHightLight', node); const btnLight = cc.find("btnHightLight", node);
const btnSelected = cc.find('btnSelected', node); const btnSelected = cc.find("btnSelected", node);
btn.active = true; btn.active = true;
btnLight.active = false; btnLight.active = false;
btnSelected.active = false; btnSelected.active = false;
const label = cc.find('label', node); const label = cc.find("label", node);
const labelSelected = cc.find('labelSelected', node); const labelSelected = cc.find("labelSelected", node);
label.active = true; label.active = true;
labelSelected.active = false; labelSelected.active = false;
}); });
}, },
initStoryBoxListener() { initStoryBoxListener() {
const ExitBtn = cc.find('middleLayer/storyBox/ExitBtn'); const ExitBtn = cc.find("middleLayer/storyBox/ExitBtn");
ExitBtn.on('click', () => { ExitBtn.on("click", () => {
cc.tween(ExitBtn) cc.tween(ExitBtn)
.to(0.1, { scaleX: 0.9, scaleY: 1.1 }) .to(0.1, { scaleX: 0.9, scaleY: 1.1 })
.to(0.1, { scaleX: 1.1, scaleY: 0.9 }) .to(0.1, { scaleX: 1.1, scaleY: 0.9 })
...@@ -340,8 +360,10 @@ cc.Class({ ...@@ -340,8 +360,10 @@ cc.Class({
.start(); .start();
}); });
const lineBtnShow = cc.find('middleLayer/storyBox/menu/menuBase/lineBtnShow'); const lineBtnShow = cc.find(
lineBtnShow.on('click', () => { "middleLayer/storyBox/menu/menuBase/lineBtnShow"
);
lineBtnShow.on("click", () => {
cc.tween(lineBtnShow) cc.tween(lineBtnShow)
.to(0.1, { scale: 1.1 }) .to(0.1, { scale: 1.1 })
.to(0.1, { scale: 1.0 }) .to(0.1, { scale: 1.0 })
...@@ -351,8 +373,10 @@ cc.Class({ ...@@ -351,8 +373,10 @@ cc.Class({
.start(); .start();
}); });
const lineBtnHide = cc.find('middleLayer/storyBox/menu/menuBase/lineBtnHide') const lineBtnHide = cc.find(
lineBtnHide.on('click', () => { "middleLayer/storyBox/menu/menuBase/lineBtnHide"
);
lineBtnHide.on("click", () => {
cc.tween(lineBtnHide) cc.tween(lineBtnHide)
.to(0.1, { scale: 1.1 }) .to(0.1, { scale: 1.1 })
.to(0.1, { scale: 1.0 }) .to(0.1, { scale: 1.0 })
...@@ -364,19 +388,27 @@ cc.Class({ ...@@ -364,19 +388,27 @@ cc.Class({
}, },
showMenu() { showMenu() {
const lineBtnShow = cc.find('middleLayer/storyBox/menu/menuBase/lineBtnShow'); const lineBtnShow = cc.find(
const lineBtnHide = cc.find('middleLayer/storyBox/menu/menuBase/lineBtnHide') "middleLayer/storyBox/menu/menuBase/lineBtnShow"
);
const lineBtnHide = cc.find(
"middleLayer/storyBox/menu/menuBase/lineBtnHide"
);
lineBtnHide.active = true; lineBtnHide.active = true;
lineBtnShow.active = false; lineBtnShow.active = false;
const canvas = cc.find('Canvas'); const canvas = cc.find("Canvas");
console.log('canvas.width = ' + canvas.width); console.log("canvas.width = " + canvas.width);
console.log('canvas.height = ' + canvas.height); console.log("canvas.height = " + canvas.height);
const menuBase = cc.find('middleLayer/storyBox/menu/menuBase'); const menuBase = cc.find("middleLayer/storyBox/menu/menuBase");
cc.tween(menuBase) cc.tween(menuBase)
.to(1, { y: this.storyBoxMenuLength * -100 - 80 }, { easing: 'bounceOut' }) .to(
1,
{ y: this.storyBoxMenuLength * -100 - 80 },
{ easing: "bounceOut" }
)
.start(); .start();
}, },
...@@ -384,24 +416,26 @@ cc.Class({ ...@@ -384,24 +416,26 @@ cc.Class({
this.hideAllSubmenu(); this.hideAllSubmenu();
this.resetAllMenu(); this.resetAllMenu();
const lineBtnShow = cc.find('middleLayer/storyBox/menu/menuBase/lineBtnShow'); const lineBtnShow = cc.find(
const lineBtnHide = cc.find('middleLayer/storyBox/menu/menuBase/lineBtnHide') "middleLayer/storyBox/menu/menuBase/lineBtnShow"
);
const lineBtnHide = cc.find(
"middleLayer/storyBox/menu/menuBase/lineBtnHide"
);
lineBtnShow.active = true; lineBtnShow.active = true;
lineBtnHide.active = false; lineBtnHide.active = false;
const menuBase = cc.find('middleLayer/storyBox/menu/menuBase'); const menuBase = cc.find("middleLayer/storyBox/menu/menuBase");
cc.tween(menuBase) cc.tween(menuBase).to(1, { y: 0 }, { easing: "cubicInOut" }).start();
.to(1, { y: 0 }, { easing: 'cubicInOut' })
.start();
}, },
hideWWView() { hideWWView() {
const exitBtn = cc.find('middleLayer/ExitBtn'); const exitBtn = cc.find("middleLayer/ExitBtn");
exitBtn.active = false; exitBtn.active = false;
const BtnLeft = cc.find('middleLayer/BtnLeft'); const BtnLeft = cc.find("middleLayer/BtnLeft");
BtnLeft.active = false; BtnLeft.active = false;
const BtnRight = cc.find('middleLayer/BtnRight'); const BtnRight = cc.find("middleLayer/BtnRight");
BtnRight.active = false; BtnRight.active = false;
}, },
...@@ -409,17 +443,15 @@ cc.Class({ ...@@ -409,17 +443,15 @@ cc.Class({
this.currentBundleIndex = index; this.currentBundleIndex = index;
const currentBundleInfo = this.bundleInfoList[this.currentBundleIndex]; const currentBundleInfo = this.bundleInfoList[this.currentBundleIndex];
const btnLeft = this.node.getChildByName('BtnLeft'); const btnLeft = this.node.getChildByName("BtnLeft");
const btnRight = this.node.getChildByName('BtnRight'); const btnRight = this.node.getChildByName("BtnRight");
btnLeft.active = true; btnLeft.active = true;
btnRight.active = true; btnRight.active = true;
if (this.currentBundleIndex == 0) { if (this.currentBundleIndex == 0) {
btnLeft.active = false; btnLeft.active = false;
} }
if (this.currentBundleIndex == this.bundleInfoList.length - 1) { if (this.currentBundleIndex == this.bundleInfoList.length - 1) {
btnRight.active = false; btnRight.active = false;
} }
...@@ -433,9 +465,7 @@ cc.Class({ ...@@ -433,9 +465,7 @@ cc.Class({
}, },
loadDefaultBundle() { loadDefaultBundle() {
const jsonStr = this.callNativeFunction({ name: "loadScene", value: "" });
const jsonStr = this.callNativeFunction({ name: 'loadScene', value: '' });
const { const {
sceneName, sceneName,
...@@ -445,10 +475,9 @@ cc.Class({ ...@@ -445,10 +475,9 @@ cc.Class({
baseUrl, baseUrl,
homework_id, homework_id,
syllabus_id, syllabus_id,
role role,
} = JSON.parse(jsonStr); } = JSON.parse(jsonStr);
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
this.token = token; this.token = token;
this.homework_id = homework_id; this.homework_id = homework_id;
...@@ -459,8 +488,8 @@ cc.Class({ ...@@ -459,8 +488,8 @@ cc.Class({
}, },
initListener() { initListener() {
const exitBtn = this.node.getChildByName('ExitBtn'); const exitBtn = this.node.getChildByName("ExitBtn");
exitBtn.on('click', () => { exitBtn.on("click", () => {
cc.tween(exitBtn) cc.tween(exitBtn)
.to(0.1, { scaleX: 0.9, scaleY: 1.1 }) .to(0.1, { scaleX: 0.9, scaleY: 1.1 })
.to(0.1, { scaleX: 1.1, scaleY: 0.9 }) .to(0.1, { scaleX: 1.1, scaleY: 0.9 })
...@@ -471,34 +500,34 @@ cc.Class({ ...@@ -471,34 +500,34 @@ cc.Class({
.start(); .start();
}); });
const btnLeft = this.node.getChildByName('BtnLeft'); const btnLeft = this.node.getChildByName("BtnLeft");
btnLeft.on('click', () => { btnLeft.on("click", () => {
if (this.currentBundleIndex - 1 < 0) { if (this.currentBundleIndex - 1 < 0) {
return; return;
} }
this.jumpToBundleByIndex(this.currentBundleIndex - 1); this.jumpToBundleByIndex(this.currentBundleIndex - 1);
}); });
const btnRight = this.node.getChildByName('BtnRight'); const btnRight = this.node.getChildByName("BtnRight");
btnRight.on('click', () => { btnRight.on("click", () => {
if (this.currentBundleIndex + 1 >= this.bundleInfoList.length) { if (this.currentBundleIndex + 1 >= this.bundleInfoList.length) {
return; return;
} }
this.jumpToBundleByIndex(this.currentBundleIndex + 1); this.jumpToBundleByIndex(this.currentBundleIndex + 1);
}); });
const btnClose = cc.find('middleLayer/ConsoleNode/BtnClose'); const btnClose = cc.find("middleLayer/ConsoleNode/BtnClose");
const btnOpen = cc.find('middleLayer/ConsoleNode/BtnOpen'); const btnOpen = cc.find("middleLayer/ConsoleNode/BtnOpen");
const consoleNode = cc.find('middleLayer/ConsoleNode/Console'); const consoleNode = cc.find("middleLayer/ConsoleNode/Console");
const consoleBg = cc.find('middleLayer/ConsoleNode/bg'); const consoleBg = cc.find("middleLayer/ConsoleNode/bg");
btnOpen.on('click', () => { btnOpen.on("click", () => {
btnClose.active = true; btnClose.active = true;
btnOpen.active = false; btnOpen.active = false;
consoleNode.active = true; consoleNode.active = true;
consoleBg.active = true; consoleBg.active = true;
}); });
btnClose.on('click', () => { btnClose.on("click", () => {
btnClose.active = false; btnClose.active = false;
btnOpen.active = true; btnOpen.active = true;
consoleNode.active = false; consoleNode.active = false;
...@@ -509,11 +538,11 @@ cc.Class({ ...@@ -509,11 +538,11 @@ cc.Class({
log(str) { log(str) {
const logStr = `${new Date().toLocaleString()}: ${str}`; const logStr = `${new Date().toLocaleString()}: ${str}`;
console.log(logStr); console.log(logStr);
const content = cc.instantiate(cc.find('middleLayer/ConsoleNode/content')); const content = cc.instantiate(cc.find("middleLayer/ConsoleNode/content"));
content.active = true; content.active = true;
const label = content.getChildByName('label'); const label = content.getChildByName("label");
label.getComponent(cc.Label).string = logStr; label.getComponent(cc.Label).string = logStr;
const consoleContent = cc.find('middleLayer/ConsoleNode/Console/content'); const consoleContent = cc.find("middleLayer/ConsoleNode/Console/content");
consoleContent.addChild(content); consoleContent.addChild(content);
consoleContent.getComponent(cc.Layout).updateLayout(); consoleContent.getComponent(cc.Layout).updateLayout();
}, },
...@@ -521,23 +550,32 @@ cc.Class({ ...@@ -521,23 +550,32 @@ cc.Class({
callNativeFunction(param) { callNativeFunction(param) {
const paramStr = JSON.stringify(param); const paramStr = JSON.stringify(param);
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) { if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
return jsb.reflection.callStaticMethod('CocosMng', 'cocosWithNativeProtocol:', paramStr); return jsb.reflection.callStaticMethod(
"CocosMng",
"cocosWithNativeProtocol:",
paramStr
);
} else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { } else if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
return jsb.reflection.callStaticMethod('com/iplayabc/cocos/AppActivity', 'cocosWithNativeProtocol', '(Ljava/lang/String;)Ljava/lang/String;', paramStr); return jsb.reflection.callStaticMethod(
"com/iplayabc/cocos/AppActivity",
"cocosWithNativeProtocol",
"(Ljava/lang/String;)Ljava/lang/String;",
paramStr
);
} else { } else {
console.error('非源生环境'); console.error("非源生环境");
} }
}, },
showWaitingLetters() { showWaitingLetters() {
const waitingLayer = cc.find('middleLayer/waitingLayer'); const waitingLayer = cc.find("middleLayer/waitingLayer");
waitingLayer.active = true; waitingLayer.active = true;
const colorList = this.getRainbowColorList(); const colorList = this.getRainbowColorList();
const layout = cc.find('middleLayer/layout'); const layout = cc.find("middleLayer/layout");
layout.removeAllChildren(); layout.removeAllChildren();
layout.active = true; layout.active = true;
const str = 'Now Loading...'; const str = "Now Loading...";
str.split('').forEach((word, idx) => { str.split("").forEach((word, idx) => {
const node = new cc.Node(); const node = new cc.Node();
const label = node.addComponent(cc.Label); const label = node.addComponent(cc.Label);
label.string = word; label.string = word;
...@@ -545,8 +583,8 @@ cc.Class({ ...@@ -545,8 +583,8 @@ cc.Class({
node.color = colorList[idx]; node.color = colorList[idx];
cc.tween(node) cc.tween(node)
.delay(idx / 4) .delay(idx / 4)
.by(0.3, { y: 50 }, { easing: 'sineOut' }) .by(0.3, { y: 50 }, { easing: "sineOut" })
.by(0.3, { y: -50 }, { easing: 'sineIn' }) .by(0.3, { y: -50 }, { easing: "sineIn" })
.delay((str.length - idx) / 4) .delay((str.length - idx) / 4)
.union() .union()
.repeatForever() .repeatForever()
...@@ -559,9 +597,9 @@ cc.Class({ ...@@ -559,9 +597,9 @@ cc.Class({
}, },
hideWaitingLetters() { hideWaitingLetters() {
const layout = cc.find('middleLayer/layout'); const layout = cc.find("middleLayer/layout");
layout.active = false; layout.active = false;
const waitingLayer = cc.find('middleLayer/waitingLayer'); const waitingLayer = cc.find("middleLayer/waitingLayer");
waitingLayer.active = false; waitingLayer.active = false;
}, },
...@@ -590,10 +628,7 @@ cc.Class({ ...@@ -590,10 +628,7 @@ cc.Class({
node.x = this.node.width / 4; node.x = this.node.width / 4;
node.y = -this.node.height / 2; node.y = -this.node.height / 2;
node.parent = this.node; node.parent = this.node;
cc.tween(node) cc.tween(node).to(5, { y: this.node.height }).removeSelf().start();
.to(5, { y: this.node.height })
.removeSelf()
.start();
setTimeout(() => { setTimeout(() => {
this.logList.shift(); this.logList.shift();
this.showOneLog(); this.showOneLog();
...@@ -602,28 +637,32 @@ cc.Class({ ...@@ -602,28 +637,32 @@ cc.Class({
loadBundle(conf, callback) { loadBundle(conf, callback) {
this.showWaitingLetters(); this.showWaitingLetters();
cc.assetManager.loadBundle(conf.bondleUrl, { version: conf.version }, async (err, bundle) => { cc.assetManager.loadBundle(
conf.bondleUrl,
{ version: conf.version },
async (err, bundle) => {
if (err) { if (err) {
return this.asyncDelayLog(err); return this.asyncDelayLog(err);
} }
bundle.loadScene(conf.sceneName, (err, scene) => { bundle.loadScene(conf.sceneName, (err, scene) => {
if (err) { if (err) {
this.asyncDelayLog('err: ', err); this.asyncDelayLog("err: ", err);
} }
cc.audioEngine.stopAll(); cc.audioEngine.stopAll();
cc.director.runScene(scene, null, () => { cc.director.runScene(scene, null, () => {
console.log('sceneName = ' + conf.sceneName); console.log("sceneName = " + conf.sceneName);
const canvas = cc.find('Canvas'); const canvas = cc.find("Canvas");
const middleLayer = cc.find('middleLayer'); const middleLayer = cc.find("middleLayer");
this.hideWaitingLetters(); this.hideWaitingLetters();
callback && callback(); callback && callback();
if (this.bundleType == 'StoryBox') { if (this.bundleType == "StoryBox") {
this.node.removeComponent(cc.Widget); this.node.removeComponent(cc.Widget);
this.updateScale(); this.updateScale();
} }
}); });
}); });
}); }
);
}, },
updateScale() { updateScale() {
...@@ -678,7 +717,6 @@ cc.Class({ ...@@ -678,7 +717,6 @@ cc.Class({
} }
}, },
loadBundleByConf(conf, callback) { loadBundleByConf(conf, callback) {
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) { if (cc.sys.isNative && cc.sys.os == cc.sys.OS_IOS) {
this.loadBundle(conf.ios, callback); this.loadBundle(conf.ios, callback);
...@@ -686,14 +724,14 @@ cc.Class({ ...@@ -686,14 +724,14 @@ cc.Class({
this.loadBundle(conf.android, callback); this.loadBundle(conf.android, callback);
} else { } else {
this.loadBundle(conf.web_desktop, callback); this.loadBundle(conf.web_desktop, callback);
console.error('非源生环境'); console.error("非源生环境");
} }
}, },
exit() { exit() {
cc.game.removePersistRootNode(this.node); cc.game.removePersistRootNode(this.node);
cc.director.loadScene("emptyScene", () => { cc.director.loadScene("emptyScene", () => {
this.callNativeFunction({ name: 'exit', value: '' }); this.callNativeFunction({ name: "exit", value: "" });
}); });
}, },
...@@ -717,5 +755,5 @@ cc.Class({ ...@@ -717,5 +755,5 @@ cc.Class({
cc.color(0, 0, 255), cc.color(0, 0, 255),
cc.color(128, 0, 255), cc.color(128, 0, 255),
]; ];
} },
}); });
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