Commit 15e93c48 authored by limingzhe's avatar limingzhe

fix: 反馈调整

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