Commit 15e93c48 authored by limingzhe's avatar limingzhe

fix: 反馈调整

parent 2b18eacc
import { asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, playLocalAudio, playAudioByUrl } from "./util";
import { asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, playLocalAudio, playAudioByUrl, getSprNodeByUrl } from "./util";
const {ccclass, property} = cc._decorator;
@ccclass
......@@ -22,6 +23,7 @@ export default class NewClass extends cc.Component {
_inited = false;
// 点击用户中心
handleClickUserCenter() {
......@@ -38,9 +40,11 @@ export default class NewClass extends cc.Component {
// 点击课程
handleClickCourseItem(pid) {
handleClickCourseItem(pid, pData) {
const vc = this.Viewer.getComponent("PageViewer");
vc.unitPage.attr({syllabus_pid: pid});
vc.unitPage.attr({pData: pData});
vc.toView("UnitPage", "rightIn");
}
......@@ -64,9 +68,15 @@ export default class NewClass extends cc.Component {
} else {
cc.find(`progress`, ci).getComponent(cc.ProgressBar).progress = Math.floor(a/b*10)/10;
}
getSpriteFrimeByUrl(row.cover, (spriteFrame) => {
const coverNode = cc.find(`bg`, ci);
coverNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
const spr = coverNode.getComponent(cc.Sprite);
spr.spriteFrame = spriteFrame;
const sx = 476 / coverNode.width;
const sy = 630 / coverNode.height;
coverNode.scale = Math.max(sx, sy);
......@@ -74,7 +84,8 @@ export default class NewClass extends cc.Component {
ci.active = true;
ci.attr({syllabus_id: row.id});
ci.on("click", ()=>{
this.handleClickCourseItem(ci[`syllabus_id`]);
console.log('row: ', row);
this.handleClickCourseItem(ci[`syllabus_id`], row);
})
});
this.SvContent.addChild(ci);
......@@ -88,6 +99,17 @@ export default class NewClass extends cc.Component {
await this.getCourseList();
this._canTouch = true;
this._inited = true;
this.initBg();
}
initBg() {
const canvas = cc.find("Canvas");
const bg = cc.find("bg/bg", this.node);
const sx = canvas.width / bg.width;
const sy = canvas.height / bg.height;
bg.scale = Math.max(sx, sy);
}
async onEnable() {
......
......@@ -34,6 +34,7 @@ export default class NewClass extends cc.Component {
}
const vc = this.Viewer.getComponent("PageViewer");
vc[`library${data}Page`].attr({syllabus_pid: syllabusId});
vc[`library${data}Page`].attr({pData: this.libraryRows[0]});
vc.toView(`Library${data}Page`, "rightIn");
}
......@@ -47,8 +48,10 @@ export default class NewClass extends cc.Component {
this.loading.active = false;
}
libraryRows;
async initView() {
const {code, rows} = await asyncCallNetworkApiGet(`/api/kyxq/v1/library`, {});
this.libraryRows = rows;
this.btnReading[`syllabus_id`] = rows[0].id;
this.btnListening[`syllabus_id`] = rows[1].id;
this.btnWatching[`syllabus_id`] = rows[2].id;
......
......@@ -72,7 +72,21 @@ export default class NewClass extends cc.Component {
initView() {
this.initUI()
this.initListView();
this.initLevelListView()
this.initLevelListView();
this.initTitle();
}
initTitle() {
const titleLabelNode = cc.find("bg/bg_title/label", this.node);
const titleLabel = titleLabelNode.getComponent(cc.Label);
titleLabel.string = this.node['pData'].name;
if (titleLabelNode.width > titleLabelNode.parent.width * 0.9) {
titleLabelNode.scale = titleLabelNode.parent.width * 0.9 / titleLabelNode.width;
} else {
titleLabelNode.scale = 1;
}
}
initUI(){
......@@ -98,6 +112,13 @@ export default class NewClass extends cc.Component {
view.width = svNode.width;
view.height = svNode.height;
if (this.data.length == 0) {
const sv = svNode.getComponent(cc.ScrollView);
const content = sv.content;
content.removeAllChildren();
return;
}
const itemArr = this.getItemArr(this.data);
const sv = svNode.getComponent(cc.ScrollView);
......
......@@ -37,9 +37,24 @@ export default class NewClass extends cc.Component {
}
initView() {
this.initTitle();
this.initListView();
}
initTitle() {
const titleLabelNode = cc.find("bg/bg_title/label", this.node);
const titleLabel = titleLabelNode.getComponent(cc.Label);
titleLabel.string = this.node['pData'].name;
if (titleLabelNode.width > titleLabelNode.parent.width * 0.9) {
titleLabelNode.scale = titleLabelNode.parent.width * 0.9 / titleLabelNode.width;
} else {
titleLabelNode.scale = 1;
}
}
initListView() {
......@@ -92,6 +107,7 @@ export default class NewClass extends cc.Component {
itemNode.on("click", () => {
const vc = this.Viewer.getComponent("PageViewer");
vc.libraryReadDetailPage.attr({syllabus_pid: data.id});
vc.libraryReadDetailPage.attr({pData: data});
vc.toView("LibraryReadDetailPage", "rightIn")
})
......
import { BlendFactor } from './../../../creator.d';
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
......@@ -6,7 +7,7 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost } from "./util";
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl } from "./util";
const { ccclass, property } = cc._decorator;
......@@ -40,11 +41,19 @@ export default class NewClass extends cc.Component {
// onLoad () {}
async start() {
this.initBg();
}
async onEnable() {
this.loading.active = true;
await this.initData();
await this.getAndStoreSyllabusStatus();
await this.initView();
this.loading.active = false;
}
async initData() {
......@@ -54,6 +63,10 @@ export default class NewClass extends cc.Component {
syllabusLockStatusStore = {}; // 课件是否解锁的存储对象 { 99343: 'locked', 19834: 'unlock' }
async getAndStoreSyllabusStatus() {
if (this.data.length == 0) {
return;
}
const syllabuses = this.data.map(item => item.id);
const {rows} = await asyncCallNetworkApiGet(`/api/kyxq/v1/user/syllabus/status`, {syllabuses: syllabuses.join(",")});
for (let i = 0; i < rows.length; i++) {
......@@ -65,17 +78,50 @@ export default class NewClass extends cc.Component {
}
async initView() {
this.initTitle();
this.initListView();
}
initTitle() {
const titleLabelNode = cc.find("bg/bg_title/label", this.node);
const titleLabel = titleLabelNode.getComponent(cc.Label);
titleLabel.string = this.node['pData'].name;
if (titleLabelNode.width > titleLabelNode.parent.width * 0.9) {
titleLabelNode.scale = titleLabelNode.parent.width * 0.9 / titleLabelNode.width;
} else {
titleLabelNode.scale = 1;
}
}
initBg() {
const canvas = cc.find("Canvas");
const bg = cc.find("bg/bg", this.node);
const sx = canvas.width / bg.width;
const sy = canvas.height / bg.height;
bg.scale = Math.max(sx, sy);
}
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);
if (itemArr.length == 0) {
const sv = svNode.getComponent(cc.ScrollView);
const content = sv.content;
content.removeAllChildren();
return;
}
const sv = svNode.getComponent(cc.ScrollView);
this.initScrollViewItem(sv, itemArr, 1);
......@@ -109,13 +155,18 @@ export default class NewClass extends cc.Component {
cc.find("title_label", itemNode).getComponent(cc.Label).string = data.name;
cc.find("English_label", itemNode).getComponent(cc.Label).string = data.tag;
getSprNodeByUrl(data.cover, (spr) => {
const sprNode = spr.node;
const picLayer = cc.find("pic_layer", itemNode);
picLayer.addChild(sprNode);
const coverNode = cc.find("pic_layer", itemNode);
const maxW = coverNode.width;
const maxH = coverNode.height;
getSpriteFrimeByUrl(data.cover, (spriteFrame) => {
setSprNodeMaxLen(sprNode, picLayer.width, picLayer.height, true);
// spriteFrame.BlendFactor = cc.macro.BlendFactor.ONE
const spr = coverNode.getComponent(cc.Sprite);
spr.spriteFrame = spriteFrame;
setSprNodeMaxLen(coverNode, maxW, maxH);
if (unLock) {
cc.find(`icon_lock`, itemNode).active = false;
} else {
......@@ -123,6 +174,21 @@ export default class NewClass extends cc.Component {
}
itemNode.active = true;
});
// getSprNodeByUrl(data.cover, (spr) => {
// const sprNode = spr.node;
// const picLayer = cc.find("pic_layer", itemNode);
// picLayer.addChild(sprNode);
// setSprNodeMaxLen(sprNode, picLayer.width, picLayer.height, true);
// if (unLock) {
// cc.find(`icon_lock`, itemNode).active = false;
// } else {
// spr.setMaterial(0, this.gray);
// }
// itemNode.active = true;
// });
itemArr.push(itemNode);
}
return itemArr;
......
......@@ -32,15 +32,47 @@ export default class NewClass extends cc.Component {
// onLoad () {}
async start () {
this.loading.active = true;
this.initBg();
this.listItem = cc.find("view/content/item", this.unitScrollView);
}
async onEnable() {
await this.initView();
this.loading.active = false;
}
async initView() {
this.loading.active = true;
this.initTitle();
await this.initUnitListView();
this.loading.active = false;
}
initBg() {
const canvas = cc.find("Canvas");
const bg = cc.find("bg/bg", this.node);
const sx = canvas.width / bg.width;
const sy = canvas.height / bg.height;
bg.scale = Math.max(sx, sy);
}
initTitle() {
const titleLabelNode = cc.find("bg/bg_title/label", this.node);
const titleLabel = titleLabelNode.getComponent(cc.Label);
titleLabel.string = this.node['pData'].name;
if (titleLabelNode.width > titleLabelNode.parent.width * 0.9) {
titleLabelNode.scale = titleLabelNode.parent.width * 0.9 / titleLabelNode.width;
} else {
titleLabelNode.scale = 1;
}
}
syllabusLockStatusStore = {}; // 课件是否解锁的存储对象 { 99343: 'locked', 19834: 'unlock' }
syllabusFinishedStore = {}; // 课件是否完成的存储对象 { 99343: 'finished', 19834: 'unfinish' }
......@@ -71,7 +103,18 @@ export default class NewClass extends cc.Component {
async initUnitListView() {
const {rows} = await asyncCallNetworkApiGet(`/api/syllabus/v2/tree`, {pid: this.node['syllabus_pid'], deep: 2});
const resData = await asyncCallNetworkApiGet(`/api/syllabus/v2/tree`, {pid: this.node['syllabus_pid'], deep: 2});
const rows = resData.rows;
if (rows.length == 0) {
const svNode = this.unitScrollView;
const sv = svNode.getComponent(cc.ScrollView);
const content = sv.content;
content.removeAllChildren();
return;
}
await this.getAndStoreSyllabusStatus(rows);
const svNode = this.unitScrollView;
......@@ -89,11 +132,13 @@ export default class NewClass extends cc.Component {
}
listItem;
getUnitItemDataArr(dataArr) {
const listItem = cc.find("view/content/item", this.unitScrollView);
const subItem = cc.find("sub_item", listItem);
const listLabel = cc.find("label", listItem);
let listItem = this.listItem;
let subItem = cc.find("sub_item", listItem);
let listLabel = cc.find("label", listItem);
const itemArr = [];
for (let i=0; i<dataArr.length; i++) {
......@@ -171,13 +216,15 @@ export default class NewClass extends cc.Component {
subNode.on("click", () => {
const vc = this.Viewer.getComponent("PageViewer");
vc.missionPage.attr({syllabus_pid: subData.id});
vc.missionPage.attr({pData: subData});
vc.toView("MissionPage", "rightIn")
})
}
const labelNode = cc.instantiate(listLabel);
const label = labelNode.getComponent(cc.Label);
label.string = "Unit " + (i + 1);
label.string = data.name//"Unit " + (i + 1);
itemNode.addChild(labelNode);
// if (subArr.length > 2) {
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 357,
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 153,
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 350,
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 166,
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 513,
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 357,
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 357,
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 309,
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 350,
......
......@@ -4,7 +4,7 @@
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 283,
......
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