Commit ac625c57 authored by liujiangnan's avatar liujiangnan

feat:

parent 299b7f9b
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util";
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
scrollView: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
data;
handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LibraryPage", "leftIn")
}
// onLoad () {}
async start() {
this.loading.active = true;
await this.initData();
await this.initView();
this.loading.active = false;
}
async initData() {
const {rows} = await asyncCallNetworkApiGet(`/api/syllabus/v1/list`, {pid: this.node['syllabus_pid']});
this.data = rows;
}
initView() {
this.initListView();
}
initListView() {
const svNode = this.scrollView;
const view = cc.find("view", svNode);
view.width = svNode.width;
view.height = svNode.height;
const itemArr = this.getItemArr(this.data);
const sv = svNode.getComponent(cc.ScrollView);
this.initScrollViewItem(sv, itemArr, 1);
}
getItemArr(dataArr) {
const listItem = cc.find("view/content/item", this.scrollView);
const itemArr = [];
for (let i = 0; i < dataArr.length; i++) {
const data = dataArr[i];
const itemNode = cc.instantiate(listItem);
itemNode['data'] = data;
getSprNodeByUrl(data.cover, (spr) => {
const sprNode = spr.node;
const picLayer = cc.find("mask/pic_layer", itemNode);
picLayer.addChild(sprNode);
setSprNodeMaxLen(sprNode, picLayer.width, picLayer.height, true);
})
cc.find("title_label", itemNode).getComponent(cc.Label).string = data.name;
itemNode.addComponent(cc.Button);
itemNode.on("click", () => {
global.middleLayer.backPageNode = this.node;
global.middleLayer.loadOnlineCourseWare(data.id);
})
itemArr.push(itemNode);
}
return itemArr;
}
initScrollViewItem(sv, itemArr, row = 1) {
if (!itemArr || itemArr.length == 0) {
return;
}
sv.scrollToTop();
const content = sv.content;
content.width = sv.node.width;
content.height = sv.node.height;
content.removeAllChildren();
const tempH = content.height / row;
const disY = tempH * 0.95;
const baseY = (row - 1) * 0.5 * disY;
let rowCount = 0;
const disX = 40;
const baseX = itemArr[0].width / 2 * itemArr[0].scaleX + disX;
let colCount = 0;
let lastX = baseX;
for (let i = 0; i < itemArr.length; i++) {
const item = itemArr[i];
item.x = lastX + disX;
item.y = baseY - rowCount * disY;
lastX = item.x + item.width * item.scale;
content.addChild(itemArr[i]);
const tempW = Math.abs(item.x + disX + item.width / 2 * item.scale);
content.width = lastX - item.width / 2 * item.scaleX + disX * 2;
rowCount++;
if (rowCount >= row) {
rowCount = 0;
colCount++;
}
}
}
// update (dt) {}
}
{
"ver": "1.0.8",
"uuid": "19d74af8-e981-4f91-831f-a15412164bc2",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -23,18 +23,18 @@ export default class NewClass extends cc.Component {
handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer");
vc.toView("HomePage", "topIn")
vc.toView("HomePage", "topIn");
}
handleClickReadBook(evt: cc.Event) {
handleClickReadBook(evt: cc.Event, data) {
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")
vc[`library${data}Page`].attr({syllabus_pid: syllabusId});
vc.toView(`Library${data}Page`, "rightIn");
}
// LIFE-CYCLE CALLBACKS:
......
......@@ -100,11 +100,11 @@ export default class NewClass extends cc.Component {
return itemArr;
}
initScrollViewItem(sv, itemArr, row = 1) {
if (!itemArr || itemArr.length == 0) {
return;
}
sv.scrollToTop();
const content = sv.content;
content.width = sv.node.width;
......
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util";
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Node)
Viewer: cc.Node = null;
@property(cc.Node)
scrollView: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
data;
handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LibraryPage", "leftIn")
}
// onLoad () {}
async start() {
this.loading.active = true;
await this.initData();
await this.initView();
this.loading.active = false;
}
async initData() {
const {rows} = await asyncCallNetworkApiGet(`/api/syllabus/v1/list`, {pid: this.node['syllabus_pid']});
this.data = rows;
}
initView() {
this.initListView();
}
initListView() {
const svNode = this.scrollView;
const view = cc.find("view", svNode);
view.width = svNode.width;
view.height = svNode.height;
const itemArr = this.getItemArr(this.data);
const sv = svNode.getComponent(cc.ScrollView);
this.initScrollViewItem(sv, itemArr, 1);
}
getItemArr(dataArr) {
const listItem = cc.find("view/content/item", this.scrollView);
const itemArr = [];
for (let i = 0; i < dataArr.length; i++) {
const data = dataArr[i];
const itemNode = cc.instantiate(listItem);
itemNode['data'] = data;
getSprNodeByUrl(data.cover, (spr) => {
const sprNode = spr.node;
const picLayer = cc.find("mask/pic_layer", itemNode);
picLayer.addChild(sprNode);
setSprNodeMaxLen(sprNode, picLayer.width, picLayer.height, true);
})
cc.find("title_label", itemNode).getComponent(cc.Label).string = data.name;
itemNode.addComponent(cc.Button);
itemNode.on("click", () => {
global.middleLayer.backPageNode = this.node;
global.middleLayer.loadOnlineCourseWare(data.id);
})
itemArr.push(itemNode);
}
return itemArr;
}
initScrollViewItem(sv, itemArr, row = 1) {
if (!itemArr || itemArr.length == 0) {
return;
}
sv.scrollToTop();
const content = sv.content;
content.width = sv.node.width;
content.height = sv.node.height;
content.removeAllChildren();
const tempH = content.height / row;
const disY = tempH * 0.95;
const baseY = (row - 1) * 0.5 * disY;
let rowCount = 0;
const disX = 40;
const baseX = itemArr[0].width / 2 * itemArr[0].scaleX + disX;
let colCount = 0;
let lastX = baseX;
for (let i = 0; i < itemArr.length; i++) {
const item = itemArr[i];
item.x = lastX + disX;
item.y = baseY - rowCount * disY;
lastX = item.x + item.width * item.scale;
content.addChild(itemArr[i]);
const tempW = Math.abs(item.x + disX + item.width / 2 * item.scale);
content.width = lastX - item.width / 2 * item.scaleX + disX * 2;
rowCount++;
if (rowCount >= row) {
rowCount = 0;
colCount++;
}
}
}
// update (dt) {}
}
{
"ver": "1.0.8",
"uuid": "be21372b-e856-477a-a44a-0bee18129d16",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -79,7 +79,6 @@ export default class NewClass extends cc.Component {
const res = await asyncCallNetworkApiPost('/api/kyxq/v1/login', {
phone: phone,
});
console.log(res);
if (res.code != '200') {
global.middleLayer.showTips(res.msg);
this.showEnterFail();
......
......@@ -26,6 +26,12 @@ export default class NewClass extends cc.Component {
@property(cc.Node)
libraryReadDetailPage: cc.Node = null;
@property(cc.Node)
libraryAudioPage: cc.Node = null;
@property(cc.Node)
libraryVideoPage: cc.Node = null;
@property(cc.Node)
unitPage: cc.Node = null;
......@@ -80,6 +86,16 @@ export default class NewClass extends cc.Component {
this._currentViewName = 'LibraryReadPage';
this._currentViewNode = this.libraryReadPage;
break;
case 'LibraryAudioPage':
await this.switchView(this.libraryAudioPage, this._currentViewNode, aniType);
this._currentViewName = 'LibraryAudioPage';
this._currentViewNode = this.libraryAudioPage;
break;
case 'LibraryVideoPage':
await this.switchView(this.libraryVideoPage, this._currentViewNode, aniType);
this._currentViewName = 'LibraryVideoPage';
this._currentViewNode = this.libraryVideoPage;
break;
case 'LibraryReadDetailPage':
await this.switchView(this.libraryReadDetailPage, this._currentViewNode, aniType);
this._currentViewName = 'LibraryReadDetailPage';
......
{
"ver": "1.1.2",
"uuid": "166d3d9d-a393-45ad-b904-44288faecb55",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "7a071770-0b56-4d5a-9f25-1c3bb16aa603",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
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