Commit 2db0f7f6 authored by 李维's avatar 李维

完成课程简介、课前导读

parent 6c758790
......@@ -16237,12 +16237,12 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 309.1,
"width": 300,
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"x": 1,
"y": 0.5
},
"_trs": {
......@@ -16276,7 +16276,7 @@
},
{
"__type__": "cc.Node",
"_name": "btn_preview",
"_name": "btn_works",
"_objFlags": 0,
"_parent": {
"__id__": 355
......@@ -16302,8 +16302,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 132,
"height": 146
"width": 134,
"height": 145
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -16314,7 +16314,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-88.55000000000001,
87.54999999999998,
0,
0,
0,
......@@ -16337,7 +16337,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "acy2oxTeJHdrW4+lZ0/Qwt"
"_id": "3eacMuXltPr7Dw6KEcip9i"
},
{
"__type__": "cc.Sprite",
......@@ -16355,7 +16355,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "33f68cc0-1138-4bef-8a65-0ec0dd6affc7"
"__uuid__": "a3061d2b-c5dd-49ee-8f2a-4f1286bbd1e3"
},
"_type": 0,
"_sizeMode": 1,
......@@ -16369,7 +16369,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "f1C1GGKNpN8q+9BC/CcO6K"
"_id": "75CPT2R49BkaCxHpjhhKA2"
},
{
"__type__": "cc.Button",
......@@ -16441,7 +16441,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "72amS9jGdEq4Zqz2Gl2Glv"
"_id": "e7uYE8HhdMg7XnDwecbJcL"
},
{
"__type__": "cc.ClickEvent",
......@@ -16450,18 +16450,18 @@
},
"component": "",
"_componentId": "0648bu4mu5LTadZtHOrsA2O",
"handler": "onClickPreview",
"handler": "onClickMyWork",
"customEventData": ""
},
{
"__type__": "cc.Node",
"_name": "btn_works",
"_name": "btn_preview",
"_objFlags": 0,
"_parent": {
"__id__": 355
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 361
......@@ -16481,8 +16481,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 134,
"height": 145
"width": 132,
"height": 146
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -16493,7 +16493,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
87.54999999999998,
-88.55000000000001,
0,
0,
0,
......@@ -16516,7 +16516,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "3eacMuXltPr7Dw6KEcip9i"
"_id": "acy2oxTeJHdrW4+lZ0/Qwt"
},
{
"__type__": "cc.Sprite",
......@@ -16534,7 +16534,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a3061d2b-c5dd-49ee-8f2a-4f1286bbd1e3"
"__uuid__": "33f68cc0-1138-4bef-8a65-0ec0dd6affc7"
},
"_type": 0,
"_sizeMode": 1,
......@@ -16548,7 +16548,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "75CPT2R49BkaCxHpjhhKA2"
"_id": "f1C1GGKNpN8q+9BC/CcO6K"
},
{
"__type__": "cc.Button",
......@@ -16620,7 +16620,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "e7uYE8HhdMg7XnDwecbJcL"
"_id": "72amS9jGdEq4Zqz2Gl2Glv"
},
{
"__type__": "cc.ClickEvent",
......@@ -16629,7 +16629,7 @@
},
"component": "",
"_componentId": "0648bu4mu5LTadZtHOrsA2O",
"handler": "onClickMyWork",
"handler": "onClickPreview",
"customEventData": ""
},
{
......@@ -16657,10 +16657,10 @@
"_N$paddingRight": 0,
"_N$paddingTop": 0,
"_N$paddingBottom": 0,
"_N$spacingX": 43.1,
"_N$spacingX": 30,
"_N$spacingY": 0,
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$horizontalDirection": 1,
"_N$affectedByScale": false,
"_id": "82t6uGX5ZCQa3ul0X0rEY2"
},
......@@ -16676,8 +16676,8 @@
"_target": null,
"_alignFlags": 33,
"_left": 0,
"_right": 128.50399999999996,
"_top": 10.853000000000065,
"_right": 50,
"_top": 10,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
......@@ -16709,10 +16709,10 @@
"__id__": 288
},
"btn_preview": {
"__id__": 356
"__id__": 360
},
"btn_works": {
"__id__": 360
"__id__": 356
},
"LessonBrief": {
"__id__": 367
......@@ -17714,7 +17714,7 @@
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
"y": 1
},
"_trs": {
"__type__": "TypedArray",
......@@ -17860,7 +17860,7 @@
"_N$spacingY": 0,
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$affectedByScale": false,
"_N$affectedByScale": true,
"_id": "ef7aaH09FMxo1kWgHv8HXv"
},
{
......@@ -20271,12 +20271,12 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 307.1,
"width": 300,
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"x": 1,
"y": 0.5
},
"_trs": {
......@@ -20310,7 +20310,7 @@
},
{
"__type__": "cc.Node",
"_name": "btn_preview",
"_name": "btn_report",
"_objFlags": 0,
"_parent": {
"__id__": 447
......@@ -20337,7 +20337,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 132,
"height": 146
"height": 156
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -20348,7 +20348,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-87.55000000000001,
87.54999999999998,
0,
0,
0,
......@@ -20371,7 +20371,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "daZbKDXeRL6p61ia9th4DH"
"_id": "bbYm4ulkdLWayJ6XXfJlN7"
},
{
"__type__": "cc.Sprite",
......@@ -20389,7 +20389,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "d7732bc5-b894-4e65-8941-163c7e811c27"
"__uuid__": "08b55b20-8445-4a76-a7ed-7533aa2d1e29"
},
"_type": 0,
"_sizeMode": 1,
......@@ -20403,7 +20403,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "1djEPfj/lAMqKZNjET09y3"
"_id": "0588Nk8WtKwLTMcAfjArFE"
},
{
"__type__": "cc.Button",
......@@ -20475,7 +20475,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "12YBaiZg5LerlPq+z3+5cQ"
"_id": "1cyxW8pn9Id631u1KoSVdD"
},
{
"__type__": "cc.ClickEvent",
......@@ -20484,18 +20484,18 @@
},
"component": "",
"_componentId": "9b9bchIHGtCaZ5ox/9QJGCT",
"handler": "onClickOpenLessonPreview",
"handler": "onClickOpenLessonReport",
"customEventData": ""
},
{
"__type__": "cc.Node",
"_name": "btn_report",
"_name": "btn_preview",
"_objFlags": 0,
"_parent": {
"__id__": 447
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 453
......@@ -20516,7 +20516,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 132,
"height": 156
"height": 146
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -20527,7 +20527,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
87.54999999999998,
-87.55000000000001,
0,
0,
0,
......@@ -20550,7 +20550,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "bbYm4ulkdLWayJ6XXfJlN7"
"_id": "daZbKDXeRL6p61ia9th4DH"
},
{
"__type__": "cc.Sprite",
......@@ -20568,7 +20568,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "08b55b20-8445-4a76-a7ed-7533aa2d1e29"
"__uuid__": "d7732bc5-b894-4e65-8941-163c7e811c27"
},
"_type": 0,
"_sizeMode": 1,
......@@ -20582,7 +20582,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "0588Nk8WtKwLTMcAfjArFE"
"_id": "1djEPfj/lAMqKZNjET09y3"
},
{
"__type__": "cc.Button",
......@@ -20654,7 +20654,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "1cyxW8pn9Id631u1KoSVdD"
"_id": "12YBaiZg5LerlPq+z3+5cQ"
},
{
"__type__": "cc.ClickEvent",
......@@ -20663,7 +20663,7 @@
},
"component": "",
"_componentId": "9b9bchIHGtCaZ5ox/9QJGCT",
"handler": "onClickOpenLessonReport",
"handler": "onClickOpenLessonPreview",
"customEventData": ""
},
{
......@@ -20691,10 +20691,10 @@
"_N$paddingRight": 0,
"_N$paddingTop": 0,
"_N$paddingBottom": 0,
"_N$spacingX": 43.1,
"_N$spacingX": 30,
"_N$spacingY": 0,
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$horizontalDirection": 1,
"_N$affectedByScale": false,
"_id": "92yqrv+SlC4pdSNZb8yreX"
},
......@@ -20710,8 +20710,8 @@
"_target": null,
"_alignFlags": 33,
"_left": 0,
"_right": 129.50399999999996,
"_top": 10.853000000000065,
"_right": 50,
"_top": 10,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
......@@ -21028,10 +21028,10 @@
"__uuid__": "3a7bb79f-32fd-422e-ada2-96f518fed422"
},
"btn_preview": {
"__id__": 448
"__id__": 452
},
"btn_report": {
"__id__": 452
"__id__": 448
},
"headNode": {
"__id__": 459
......
......@@ -20,19 +20,27 @@ export default class LessonBrief extends cc.Component {
}
data
setData(data){
this.data=data
setData(data) {
this.data = data
}
refreshUI(){
if(!this.data) return
async refreshUI() {
if (!this.data) return
const sv = cc.find("/contentSV", this.node).getComponent(cc.ScrollView)
sv.scrollToTop()
this.content.removeAllChildren()
getSprNodeByUrl(this.data.image, (spr) => {
this.content.addChild(spr.node);
spr.srcBlendFactor = cc.macro.BlendFactor.ONE
});
for(let index = 0; index <this.data.length; index ++) {
const imgNode = await this.getImage(this.data[index].image);
this.content.addChild(imgNode);
}
}
getImage(url) {
return new Promise(resovle=>{
getSprNodeByUrl(url, (spr) => {
spr.node.scale = (this.content.width - 50) / spr.node.width;
resovle(spr.node)
});
})
}
}
......@@ -97,7 +97,6 @@ export default class NewClass extends cc.Component {
}
const saveKey = `SyllabusTree_${syllabus_pid}`;
const treeData = this.getStatus(saveKey);
console.log(treeData)
const nowDate = new Date().getTime();
const expTime = 10 * 60 * 1000; // 10分钟超期
if(treeData && (nowDate - treeData.updateTime) < expTime) {
......
......@@ -46,7 +46,6 @@ export default class NewClass extends cc.Component {
}
async onEnable() {
console.log("Unit page on Enabel")
await this.initView();
}
......@@ -118,27 +117,25 @@ export default class NewClass extends cc.Component {
}
configData=[]
configData = []
async initUnitListView() {
console.log("initUnitListView")
const svNode = this.unitScrollView;
svNode.opacity = 0;
const resData = await this.Viewer.getComponent("PageViewer").getSyllabusTreeByPid(this.node['syllabus_pid'])
let rows=[]
this.configData=[]
for (let v of resData.rows){
if (v.name=="config"){
const {rows} = await asyncCallNetworkApiGet(`/api/courseware/v2/${v.id}/list`, {});
if (rows && rows[0] && rows[0].data){
let _data = JSON.parse(rows[0].data)
this.configData=_data.pages
console.log("config data", this.configData)
}
let rows = []
this.configData = null
for (let v of resData.rows) {
if (v.name == "config") {
// 课程配置文件
const _strData = (v.children && v.children[0] && v.children[0].template_name == "sn_config" && v.children[0].data) ? v.children && v.children[0] && v.children[0].data : "{}"
this.configData = JSON.parse(_strData)
} else {
// 课程数据
rows.push(v)
}
}
if (rows.length == 0) {
const svNode = this.unitScrollView;
const sv = svNode.getComponent(cc.ScrollView);
......@@ -147,68 +144,55 @@ export default class NewClass extends cc.Component {
return;
}
await this.getAndStoreSyllabusStatus(rows);
// const svNode = this.unitScrollView;
const view = cc.find("view", svNode);
view.width = svNode.width;
view.height = svNode.height;
const itemArr = this.getUnitItemDataArr(rows);
const sv = svNode.getComponent(cc.ScrollView);
this.initScrollViewItem(sv, itemArr, 1);
const content = sv.content;
const content = sv.content;
const canvas = cc.find("Canvas");
if (content.width > canvas.width) {
content.x = -canvas.width / 2;
} else {
content.x = -content.width / 2;
}
// console.log('content.width: ' + content.width);
svNode.opacity = 255;
this.refreshConfig()
}
refreshConfig(){
if (this.configData.length>0){
this.btn_preview.active=true
// 刷新右上角“课程简介”按钮显示隐藏
refreshConfig() {
if (this.configData.introduces.length > 0) {
this.btn_preview.active = true
} else {
this.btn_preview.active=false
this.btn_preview.active = false
}
}
listItem;
getUnitItemDataArr(dataArr) {
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++) {
const data = dataArr[i];
const itemNode = cc.instantiate(listItem);
itemNode['data'] = data;
itemNode.removeAllChildren();
const subArr = data.children;
const baseX = subItem.x;
const baseY = subItem.y;
const disX = 530;
let lastX = 0;
for (let j=0; j<subArr.length; j++) {
const subNode = cc.instantiate(subItem)
subNode.x = baseX + j * disX;
subNode.y = baseY;
......@@ -217,7 +201,6 @@ export default class NewClass extends cc.Component {
lastX = subNode.x;
const subData = subArr[j];
// console.log("subData: ", subData);
getSprNodeByUrl(subData.cover, (spr) => {
const sprNode = spr.node;
......@@ -226,7 +209,6 @@ export default class NewClass extends cc.Component {
setSprNodeMaxLen(sprNode, picLayer.width, picLayer.height, true);
})
const pointBase = cc.find("point", subNode);
const pointLayer = cc.find("pint_layer", subNode);
......@@ -237,7 +219,6 @@ export default class NewClass extends cc.Component {
const clsData = subData.children[k];
const pointNode = cc.instantiate(pointBase);
pointNode.opacity = 255;
if (clsData) {
const finished = this.syllabusLockStatusStore[clsData.id]==='finished';
if (!finished) {
......@@ -265,16 +246,12 @@ export default class NewClass extends cc.Component {
const labelNode = cc.find("label", subNode);
const label = labelNode.getComponent(cc.Label);
label.string = subData.name;
subNode.addComponent(cc.Button);
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")
})
}
......@@ -283,56 +260,39 @@ export default class NewClass extends cc.Component {
const label = labelNode.getComponent(cc.Label);
label.string = data.name//"Unit " + (i + 1);
itemNode.addChild(labelNode);
// if (subArr.length > 2) {
itemNode.width = lastX + 360;
setTimeout(() => {
itemNode.width = lastX + 360;
}, 1);
// }
itemArr.push(itemNode);
}
return itemArr;
}
initScrollViewItem(sv, itemArr, row=1) {
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].scaleX + disX;
let colCount = 0;
let lastX = 0;
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 + disX;
rowCount++;
if (rowCount >= row) {
rowCount = 0;
......@@ -341,12 +301,9 @@ export default class NewClass extends cc.Component {
}
}
onClickPreview(){
this.LessonBrief.active=true
let _data=this.configData
if (_data && _data[0]){
this.LessonBrief.getComponent("LessonBrief").setData(_data[0])
}
onClickPreview() {
this.LessonBrief.active = true
this.LessonBrief.getComponent("LessonBrief").setData(this.configData.introduces)
this.LessonBrief.getComponent("LessonBrief").refreshUI()
}
......@@ -361,7 +318,6 @@ export default class NewClass extends cc.Component {
vc[`libraryVideoPage`].attr({fromPage: "UnitPage"});
vc.toView(`LibraryVideoPage`, "rightIn");
}
// update (dt) {}
}
......@@ -26,8 +26,8 @@
"height": 460,
"rawWidth": 29,
"rawHeight": 460,
"borderTop": 0,
"borderBottom": 0,
"borderTop": 30,
"borderBottom": 30,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
......
......@@ -26,8 +26,8 @@
"height": 460,
"rawWidth": 29,
"rawHeight": 460,
"borderTop": 0,
"borderBottom": 0,
"borderTop": 30,
"borderBottom": 30,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
......
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