Commit 94028df4 authored by liujiangnan's avatar liujiangnan

feat: 封面好了

parent ff156406
......@@ -53,12 +53,29 @@ export default class NewClass extends cc.Component {
});
for(let i=0; i<rows.length; i++) {
const row = rows[i];
const ci = cc.instantiate(this.CourseItem)
const ci = cc.instantiate(this.CourseItem);
cc.find(`progressText`, ci).getComponent(cc.Label).string = `学习进度:${row.process}`;
const arr = row.process.split(`/`);
const a = parseInt(arr[0]);
const b = parseInt(arr[1]);
if (b == 0) {
cc.find(`progress`, ci).getComponent(cc.ProgressBar).progress = 0;
} 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 sx = 476 / coverNode.width;
const sy = 630 / coverNode.height;
coverNode.scale = Math.max(sx, sy);
ci.active = true;
ci.attr({syllabus_id: row.id});
ci.on("click", ()=>{
this.handleClickCourseItem();
})
});
this.SvContent.addChild(ci);
}
this.loading.active = false;
......
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