Commit 4e35c977 authored by liujiangnan's avatar liujiangnan

feat: 打开课件

parent 252528f3
No preview for this file type
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b", "uuid": "77fede7e-1b07-44f7-b87d-4b576c476e14",
"downloadMode": 0, "downloadMode": 0,
"duration": 0.130612, "duration": 0.235102,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
This diff is collapsed.
import { asyncDelay, asyncCallNetworkApiGet, getSpriteFrimeByUrl, buttonOnClick, import { asyncDelay, asyncCallNetworkApiGet, asyncGetSpriteFrimeByUrl, buttonOnClick,
showLoading, hideLoading } from "../script/util"; showLoading, hideLoading, loadOnlineCourseWare } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -25,7 +25,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -25,7 +25,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
async onLoadEnd() { async onLoadEnd() {
await this.initData(); await this.initData();
this.initView(); await this.initView();
this.initListener(); this.initListener();
} }
...@@ -43,10 +43,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -43,10 +43,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.rows = this.loadData(); this.rows = this.loadData();
} }
drawPage() { async drawPage() {
const contentNode = cc.find("Canvas/pages/view/content"); const contentNode = cc.find("Canvas/pages/view/content");
const item = cc.find("item", contentNode); const item = cc.find("item", contentNode);
// 清理原来的数据 // 清理原来的数据
item.parent = this.node; item.parent = this.node;
contentNode.removeAllChildren(); contentNode.removeAllChildren();
...@@ -58,36 +58,40 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -58,36 +58,40 @@ export default class SceneComponent extends MyCocosSceneComponent {
const itemClone = cc.instantiate(item); const itemClone = cc.instantiate(item);
itemClone.parent = contentNode; itemClone.parent = contentNode;
itemClone.active = true; itemClone.active = true;
itemClone.attr({item_id: row.id}); itemClone.attr({item_id: row.id, item_name: row.name});
cc.find(`text`, itemClone).getComponent(cc.Label).string = row.name; cc.find(`text`, itemClone).getComponent(cc.Label).string = row.name;
if (row.cover) { if (row.cover) {
getSpriteFrimeByUrl(row.cover, (spriteFrame) => { const spriteFrame:any = await asyncGetSpriteFrimeByUrl(row.cover);
const coverNode = cc.find(`cover`, itemClone); const coverNode = cc.find(`cover`, itemClone);
coverNode.getComponent(cc.Sprite).spriteFrame = spriteFrame; coverNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
const sx = 70 / coverNode.width; const sx = 70 / coverNode.width;
const sy = 80 / coverNode.height; const sy = 80 / coverNode.height;
coverNode.scale = Math.min(sx, sy); coverNode.scale = Math.min(sx, sy);
});
} }
buttonOnClick(itemClone, async () => { buttonOnClick(itemClone, async () => {
this.routers.push(itemClone); if (row.has_courseware) {
showLoading(); // 打开课件
await this.loadData(row.id); showLoading();
this.drawPage(); loadOnlineCourseWare(row.id);
hideLoading(); } else {
// 打开文件夹
if (this.routers.length > 0) { this.routers.push(row);
cc.find(`Canvas/back`).active = false; showLoading();
await this.loadData(row.id);
await this.drawPage();
cc.find(`Canvas/lefttop/bg_title/title`).getComponent(cc.Label).string = row.name;
cc.find(`Canvas/lefttop`).active = true;
hideLoading();
} }
}); });
} }
} }
initView() { async initView() {
this.initBg(); this.initBg();
this.drawPage(); await this.drawPage();
} }
initBg() { initBg() {
...@@ -100,12 +104,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -100,12 +104,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
buttonOnClick(back, async () => { buttonOnClick(back, async () => {
showLoading(); showLoading();
const item = this.routers.pop(); const item = this.routers.pop();
await this.loadData(item.id); await this.loadData(item.pid);
this.drawPage(); await this.drawPage();
hideLoading(); hideLoading();
if (this.routers.length === 0) { if (this.routers.length === 0) {
back.active = false; cc.find(`Canvas/lefttop`).active = false;
} }
}); });
} }
......
...@@ -143,6 +143,18 @@ export function getSpriteFrimeByUrl(url, cb) { ...@@ -143,6 +143,18 @@ export function getSpriteFrimeByUrl(url, cb) {
}) })
} }
export function asyncGetSpriteFrimeByUrl(url) {
return new Promise((resolve, reject) => {
cc.loader.load({ url }, (err, img) => {
if (err) {
return reject(err);
}
const spriteFrame = new cc.SpriteFrame(img)
resolve(spriteFrame);
})
});
}
export function getSprNode(resName) { export function getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame; const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node(); const node = new cc.Node();
...@@ -454,6 +466,16 @@ export function hideLoading(){ ...@@ -454,6 +466,16 @@ export function hideLoading(){
} }
} }
export function loadOnlineCourseWare(courseId) {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.loadOnlineCourseWare(courseId);
} else {
console.log('===loadOnlineCourseWare===', courseId);
}
}
export function asyncCallNetworkApiGet(apiName, data) { export function asyncCallNetworkApiGet(apiName, data) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
callNetworkApiGet(apiName, data, (res => { callNetworkApiGet(apiName, data, (res => {
......
This diff is collapsed.
{
"ver": "2.3.5",
"uuid": "fee1b3c9-5fe4-4c8c-a000-59fcb9f61bf6",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2560,
"height": 1440,
"platformSettings": {},
"subMetas": {
"bg_1": {
"ver": "1.0.4",
"uuid": "91b1e86e-524a-4f72-a178-e269cbf7f4d4",
"rawTextureUuid": "fee1b3c9-5fe4-4c8c-a000-59fcb9f61bf6",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 2560,
"height": 1440,
"rawWidth": 2560,
"rawHeight": 1440,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "04576f41-dce4-4f92-bdce-ef0b6e37103e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 677,
"height": 842,
"platformSettings": {},
"subMetas": {
"bg_di1": {
"ver": "1.0.4",
"uuid": "52491330-d32c-4de0-bc39-93aa80b2adc1",
"rawTextureUuid": "04576f41-dce4-4f92-bdce-ef0b6e37103e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 677,
"height": 842,
"rawWidth": 677,
"rawHeight": 842,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "77b8c434-7b69-429c-9da9-d2d7677e0cde",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 826,
"height": 631,
"platformSettings": {},
"subMetas": {
"bg_di2": {
"ver": "1.0.4",
"uuid": "dc28ca15-9dea-4716-a706-b75cf880f291",
"rawTextureUuid": "77b8c434-7b69-429c-9da9-d2d7677e0cde",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 826,
"height": 631,
"rawWidth": 826,
"rawHeight": 631,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "6cbcf287-5e39-49a2-8d2c-ad2c07113dbb",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 588,
"height": 140,
"platformSettings": {},
"subMetas": {
"bg_title": {
"ver": "1.0.4",
"uuid": "325c2613-f4eb-4a4f-a663-11216e0a8820",
"rawTextureUuid": "6cbcf287-5e39-49a2-8d2c-ad2c07113dbb",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 588,
"height": 140,
"rawWidth": 588,
"rawHeight": 140,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2efb6b1a-263e-41b6-a880-f4451bec22fe",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 720,
"height": 822,
"platformSettings": {},
"subMetas": {
"btn_dub": {
"ver": "1.0.4",
"uuid": "0d54a959-f4f7-4236-ac33-10ae4926853e",
"rawTextureUuid": "2efb6b1a-263e-41b6-a880-f4451bec22fe",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 720,
"height": 822,
"rawWidth": 720,
"rawHeight": 822,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "794b2a13-a7e1-459f-9e6c-4cdd3a9a01b9",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 720,
"height": 822,
"platformSettings": {},
"subMetas": {
"btn_practise": {
"ver": "1.0.4",
"uuid": "fff70ccb-057e-4470-a945-1029142f8ea7",
"rawTextureUuid": "794b2a13-a7e1-459f-9e6c-4cdd3a9a01b9",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 720,
"height": 822,
"rawWidth": 720,
"rawHeight": 822,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "7cf55b14-2bbb-4cdb-bcd9-d349c0931203",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 207,
"height": 215,
"platformSettings": {},
"subMetas": {
"btn_return": {
"ver": "1.0.4",
"uuid": "90d9553f-40f6-4a5b-895b-8a4b4b0b822f",
"rawTextureUuid": "7cf55b14-2bbb-4cdb-bcd9-d349c0931203",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 207,
"height": 215,
"rawWidth": 207,
"rawHeight": 215,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e821bca7-d738-45fb-a269-2e18e1f30c5e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 720,
"height": 822,
"platformSettings": {},
"subMetas": {
"btn_story": {
"ver": "1.0.4",
"uuid": "bc3195a0-3afe-46cd-a7dc-37a34f5db5c1",
"rawTextureUuid": "e821bca7-d738-45fb-a269-2e18e1f30c5e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 720,
"height": 822,
"rawWidth": 720,
"rawHeight": 822,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"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