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:
// - 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";
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util";
const {ccclass, property} = cc._decorator;
......@@ -16,15 +9,31 @@ export default class NewClass extends cc.Component {
@property(cc.Node)
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() {
const vc = this.Viewer.getComponent("PageViewer");
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");
vc.libraryReadPage.attr({syllabus_pid: syllabusId});
vc.toView("LibraryReadPage", "rightIn")
}
......@@ -32,22 +41,18 @@ export default class NewClass extends cc.Component {
// onLoad () {}
start () {
this.initData();
this.initView();
}
initData() {
async start () {
this.loading.active = true;
await this.initView();
this.loading.active = false;
}
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) {}
}
......@@ -85,11 +85,14 @@ export default class NewClass extends middleLayerBase {
}
onHomeworkFinish(d1 = null, d2 = null) {
let data = d1;
let data = null;
let callback = null;
if (typeof(d1) == 'function') {
data = d2;
callback = d1;
} else {
data = d1;
callback = d2;
}
console.log('onHomeworkFinish: ' + JSON.stringify(data));
callback && callback();
......@@ -135,59 +138,6 @@ export default class NewClass extends middleLayerBase {
}
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; // 从绘本里返回的界面
......@@ -196,7 +146,7 @@ export default class NewClass extends middleLayerBase {
(<any>window).courseware.freeAllOcMethod();
this.hideTips();
// 切换到空场景
cc.director.loadScene('middleLayer_for_JJ', () => {
cc.director.loadScene('middleLayer_for_kyxq', () => {
this.initSize();
this.backPageNode.active = true;
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