Commit e977c6c7 authored by liujiangnan's avatar liujiangnan

feat: 资源库

parent a52dd163
This source diff could not be displayed because it is too large. You can view the blob instead.
// Learn TypeScript: import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util";
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - 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 { getSprNodeByUrl, setSprNodeMaxLen } from "./util";
const {ccclass, property} = cc._decorator; const {ccclass, property} = cc._decorator;
...@@ -16,15 +9,31 @@ export default class NewClass extends cc.Component { ...@@ -16,15 +9,31 @@ export default class NewClass extends cc.Component {
@property(cc.Node) @property(cc.Node)
Viewer: cc.Node = null; Viewer: cc.Node = null;
data; @property(cc.Node)
btnReading: cc.Node = null;
@property(cc.Node)
btnListening: cc.Node = null;
@property(cc.Node)
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("HomePage", "topIn") vc.toView("HomePage", "topIn")
} }
handleClickReadBook() { handleClickReadBook(evt: cc.Event) {
const syllabusId = evt.currentTarget.syllabus_id;
if (!syllabusId) {
global.middleLayer.showTips(`未制作`);
return;
}
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.libraryReadPage.attr({syllabus_pid: syllabusId});
vc.toView("LibraryReadPage", "rightIn") vc.toView("LibraryReadPage", "rightIn")
} }
...@@ -32,22 +41,18 @@ export default class NewClass extends cc.Component { ...@@ -32,22 +41,18 @@ export default class NewClass extends cc.Component {
// onLoad () {} // onLoad () {}
start () { async start () {
this.initData(); this.loading.active = true;
this.initView(); await this.initView();
} this.loading.active = false;
initData() {
} }
initView() { async initView() {
const {code, rows} = await asyncCallNetworkApiGet(`/api/kyxq/v1/library`, {});
this.btnReading[`syllabus_id`] = rows[0].id;
this.btnListening[`syllabus_id`] = rows[1].id;
this.btnWatching[`syllabus_id`] = rows[2].id;
} }
// update (dt) {} // update (dt) {}
} }
...@@ -85,11 +85,14 @@ export default class NewClass extends middleLayerBase { ...@@ -85,11 +85,14 @@ export default class NewClass extends middleLayerBase {
} }
onHomeworkFinish(d1 = null, d2 = null) { onHomeworkFinish(d1 = null, d2 = null) {
let data = d1; let data = null;
let callback = null; let callback = null;
if (typeof(d1) == 'function') { if (typeof(d1) == 'function') {
data = d2; data = d2;
callback = d1; callback = d1;
} else {
data = d1;
callback = d2;
} }
console.log('onHomeworkFinish: ' + JSON.stringify(data)); console.log('onHomeworkFinish: ' + JSON.stringify(data));
callback && callback(); callback && callback();
...@@ -135,59 +138,6 @@ export default class NewClass extends middleLayerBase { ...@@ -135,59 +138,6 @@ export default class NewClass extends middleLayerBase {
} }
initListener() { initListener() {
const exitBtn = cc.find('middleLayer/ExitBtn');
exitBtn.on('click', () => {
cc.find('middleLayer/BtnRight').active = false;
cc.find('middleLayer/BtnLeft').active = false;
cc.tween(exitBtn)
.to(0.1, { scaleX: 0.4, scaleY: 0.6 })
.to(0.1, { scaleX: 0.6, scaleY: 0.4 })
.to(0.1, { scaleX: 0.5, scaleY: 0.5 })
.call(() => {
exitBtn.active = false;
cc.game.removePersistRootNode(this.node);
// cc.director.getScene().destroy();
cc.audioEngine.stopAll();
(<any>window).courseware.freeAllOcMethod();
const flag = cc.director.loadScene("debug_shell", (err, scene) => {
});
if (!flag) {
// 没有壳的情况下,直接加载中间层场景
cc.director.loadScene("middleLayer_for_HY", (err, scene) => {
});
}
})
.start();
});
cc.find('middleLayer/BtnRight').on('click', () => {
this.goNextPage();
if (this.courseIndex == 0) {
cc.find('middleLayer/BtnLeft').active = false;
} else {
cc.find('middleLayer/BtnLeft').active = false;
}
if (this.courseIndex == this.courses.length - 1) {
cc.find('middleLayer/BtnRight').active = false;
} else {
cc.find('middleLayer/BtnRight').active = false;
}
});
cc.find('middleLayer/BtnLeft').on('click', () => {
this.goPrePage();
if (this.courseIndex == 0) {
cc.find('middleLayer/BtnLeft').active = false;
} else {
cc.find('middleLayer/BtnLeft').active = false;
}
if (this.courseIndex == this.courses.length - 1) {
cc.find('middleLayer/BtnRight').active = false;
} else {
cc.find('middleLayer/BtnRight').active = false;
}
});
} }
backPageNode: cc.Node = null; // 从绘本里返回的界面 backPageNode: cc.Node = null; // 从绘本里返回的界面
...@@ -196,7 +146,7 @@ export default class NewClass extends middleLayerBase { ...@@ -196,7 +146,7 @@ export default class NewClass extends middleLayerBase {
(<any>window).courseware.freeAllOcMethod(); (<any>window).courseware.freeAllOcMethod();
this.hideTips(); this.hideTips();
// 切换到空场景 // 切换到空场景
cc.director.loadScene('middleLayer_for_JJ', () => { cc.director.loadScene('middleLayer_for_kyxq', () => {
this.initSize(); this.initSize();
this.backPageNode.active = true; this.backPageNode.active = true;
this.hideTips(); this.hideTips();
......
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