Commit ac16d70f authored by 曲世俊's avatar 曲世俊

--feat 课前导读界面开发、个人作品、看动画界面优化、上报界面

parent be973413
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import {playAudioByUrl, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "./util";
const {ccclass, property} = cc._decorator;
@ccclass
export default class LessonBrief extends cc.Component {
@property(cc.Node)
content: cc.Node = null;
onClickClose(){
this.node.active=false
}
data
setData(data){
this.data=data
}
refreshUI(){
if(!this.data) return
this.content.removeAllChildren()
getSprNodeByUrl(this.data.image, (spr) => {
this.content.addChild(spr.node);
spr.srcBlendFactor = cc.macro.BlendFactor.ONE
});
}
}
{
"ver": "1.0.8",
"uuid": "311f6161-5121-4629-b683-0e33dd1c1b98",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -49,8 +49,13 @@ export default class NewClass extends cc.Component { ...@@ -49,8 +49,13 @@ export default class NewClass extends cc.Component {
@property(cc.Label) @property(cc.Label)
storyStory: cc.Label = null; storyStory: cc.Label = null;
@property(cc.ScrollView)
reportSV: cc.ScrollView = null;
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
m_sentenceNodeList=[]
onLoad () { onLoad () {
this.scentenceItem.active=false this.scentenceItem.active=false
this.storyItem.zIndex=111 this.storyItem.zIndex=111
...@@ -65,10 +70,8 @@ export default class NewClass extends cc.Component { ...@@ -65,10 +70,8 @@ export default class NewClass extends cc.Component {
playAudioId playAudioId
refreshUI(){ refreshUI(){
this.stopAudio() this.stopAudio()
for (let v of this.content.children){ for (let v of this.m_sentenceNodeList){
if (v.name != "itemCnt" && v.name != "storyItem"){ v.removeFromParent()
v.removeFromParent()
}
} }
if(!this.data) return if(!this.data) return
...@@ -83,7 +86,7 @@ export default class NewClass extends cc.Component { ...@@ -83,7 +86,7 @@ export default class NewClass extends cc.Component {
this.title.string=_data.name this.title.string=_data.name
this.unit.string=_data.unitName this.unit.string=_data.unitName
this.study_duration.string=_data.study_duration this.study_duration.string=_data.study_duration
this.last_play.string=_data.last_play && _data.last_play || "" this.last_play.string=_data.last_play && new Date(_data.last_play).toString() || ""
this.question_right_percent1.string=_data.question_right_percent this.question_right_percent1.string=_data.question_right_percent
this.question_right_percent2.string=_data.question_right_percent this.question_right_percent2.string=_data.question_right_percent
this.record_times.string=_data.record_times this.record_times.string=_data.record_times
...@@ -94,12 +97,13 @@ export default class NewClass extends cc.Component { ...@@ -94,12 +97,13 @@ export default class NewClass extends cc.Component {
_star.active=_data.question_right_percent >= 20*i _star.active=_data.question_right_percent >= 20*i
} }
this.m_sentenceNodeList=[]
for (let v of _data.excellents){ for (let v of _data.excellents){
this.createItem(v, "优秀发音") this.m_sentenceNodeList.push(this.createItem(v, "优秀发音"))
} }
for (let v of _data.tryagains){ for (let v of _data.tryagains){
this.createItem(v, "薄弱跟读") this.m_sentenceNodeList.push(this.createItem(v, "薄弱跟读"))
} }
// 句子 // 句子
...@@ -111,39 +115,72 @@ export default class NewClass extends cc.Component { ...@@ -111,39 +115,72 @@ export default class NewClass extends cc.Component {
} else { } else {
this.storyItem.active=false this.storyItem.active=false
} }
this.reportSV.scrollToTop()
} }
createItem(v, titleStr){ createItem(v, titleStr){
let _node = cc.instantiate(this.scentenceItem) let _node = cc.instantiate(this.scentenceItem)
_node.active=true _node.active=true
this.content.addChild(_node) this.content.addChild(_node)
// 星星的判定标准需要改
for (let i=1;i<=3;i++){ for (let i=1;i<=3;i++){
_node.getChildByName(`star${i}`).active=v.overall>=i*33 _node.getChildByName(`star${i}`).active=v.overall>=i*33
} }
_node.getChildByName("lbl").getComponent(cc.Label).string=v.test_text _node.getChildByName("lbl").getComponent(cc.Label).string=v.test_text
_node.getChildByName("title").getComponent(cc.Label).string=titleStr
_node.getChildByName("btn_listen").on("click", () => {
if (this.isAudioPlaying && v.record_url) { let btn_stop=_node.getChildByName("btn_stop")
return; let btn_play=_node.getChildByName("btn_play")
} let btn_listen=_node.getChildByName("btn_listen")
btn_stop.active=false
btn_play.active=true
btn_listen.active=true
btn_listen.on("click", () => {
if (!v.example_url) return
this.stopAudio()
this.isAudioPlaying = true; this.isAudioPlaying = true;
if (v.record_url) { cc.assetManager.loadRemote(v.example_url, (err, audioClip) => {
cc.assetManager.loadRemote(v.record_url, (err, audioClip) => { this.playAudioId = cc.audioEngine.play(audioClip, false, 0.8);
this.playAudioId = cc.audioEngine.play(audioClip, false, 0.8); cc.audioEngine.setFinishCallback(this.playAudioId, () => {
cc.audioEngine.setFinishCallback(this.playAudioId, () => { this.playAudioId=null
this.playAudioId=null this.isAudioPlaying = false;
this.isAudioPlaying = false; });
}); })
})
}
}) })
btn_play.on("click", () => {
_node.getChildByName("title").getComponent(cc.Label).string=v.titleStr if (!v.record_url) return
this.stopAudio()
btn_play.active=false
btn_stop.active=true
this.isAudioPlaying = true;
cc.assetManager.loadRemote(v.record_url, (err, audioClip) => {
this.playAudioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.playAudioId, () => {
this.playAudioId=null
this.isAudioPlaying = false;
});
})
})
btn_stop.on("click", () => {
this.stopAudio()
})
_node.on("stop_audio", ()=>{
btn_play.active=true
btn_stop.active=false
})
return _node
} }
stopAudio(){ stopAudio(){
if (this.playAudioId!=null) cc.audioEngine.stop(this.playAudioId) if (this.playAudioId!=null) cc.audioEngine.stop(this.playAudioId)
this.playAudioId=null
this.isAudioPlaying=false this.isAudioPlaying=false
for (let v of this.m_sentenceNodeList){
v.emit("stop_audio")
}
} }
onClickClose(){ onClickClose(){
......
...@@ -33,7 +33,7 @@ export default class NewClass extends cc.Component { ...@@ -33,7 +33,7 @@ export default class NewClass extends cc.Component {
return; return;
} }
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, showMyWork:false});
vc[`library${data}Page`].attr({pData: this.libraryRows[0]}); vc[`library${data}Page`].attr({pData: this.libraryRows[0]});
vc.toView(`Library${data}Page`, "rightIn"); vc.toView(`Library${data}Page`, "rightIn");
} }
......
...@@ -20,8 +20,13 @@ export default class NewClass extends cc.Component { ...@@ -20,8 +20,13 @@ export default class NewClass extends cc.Component {
data; data;
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); if (this.node['fromPage']){
vc.toView("LibraryPage", "leftIn") const vc = this.Viewer.getComponent("PageViewer");
vc.toView(this.node['fromPage'], "leftIn")
} else {
const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LibraryPage", "leftIn")
}
} }
// onLoad () {} // onLoad () {}
...@@ -34,13 +39,27 @@ export default class NewClass extends cc.Component { ...@@ -34,13 +39,27 @@ export default class NewClass extends cc.Component {
this.loading.active = false; this.loading.active = false;
} }
async onEnable() {
this.initUI()
this.loading.active = true;
await this.initData();
await this.initView();
this.loading.active = false;
}
initUI(){ initUI(){
this.svItem.active=false this.svItem.active=false
} }
async initData() { async initData() {
const {rows} = await asyncCallNetworkApiGet(`/api/syllabus/v1/list`, {pid: this.node['syllabus_pid']}); if (this.node['showMyWork']){
this.data = rows; let _id=this.node['syllabus_pid']
const {rows} = await asyncCallNetworkApiGet("/api/kyxq/v1/user/myshow", {jc_id: _id});
this.data = rows;
} else {
const {rows} = await asyncCallNetworkApiGet(`/api/syllabus/v1/list`, {pid: this.node['syllabus_pid']});
this.data = rows;
}
} }
initView() { initView() {
...@@ -48,7 +67,10 @@ export default class NewClass extends cc.Component { ...@@ -48,7 +67,10 @@ export default class NewClass extends cc.Component {
} }
initListView() { initListView() {
if (!this.data) {
global.middleLayer.showTips("动画未制作");
return
}
const svNode = this.scrollView; const svNode = this.scrollView;
...@@ -60,7 +82,7 @@ export default class NewClass extends cc.Component { ...@@ -60,7 +82,7 @@ export default class NewClass extends cc.Component {
const sv = svNode.getComponent(cc.ScrollView); const sv = svNode.getComponent(cc.ScrollView);
sv.content.removeAllChildren() sv.content.removeAllChildren()
sv.content.height=0 // sv.content.height=0
let _rowCnt = 3 let _rowCnt = 3
for (let i = 0;i<Math.ceil(itemArr.length/_rowCnt);i++){ for (let i = 0;i<Math.ceil(itemArr.length/_rowCnt);i++){
let _node = new cc.Node() let _node = new cc.Node()
...@@ -80,8 +102,11 @@ export default class NewClass extends cc.Component { ...@@ -80,8 +102,11 @@ export default class NewClass extends cc.Component {
itemArr[_index].y=0 itemArr[_index].y=0
} }
} }
sv.content.height+=440 // sv.content.height+=440
} }
console.log("qsj!!",sv.content.height)
sv.scrollToTop() sv.scrollToTop()
// this.initScrollViewItemRow(sv, itemArr, 4); // this.initScrollViewItemRow(sv, itemArr, 4);
...@@ -110,22 +135,27 @@ export default class NewClass extends cc.Component { ...@@ -110,22 +135,27 @@ 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;
itemNode.addComponent(cc.Button); if (data.id){
itemNode.on("click", async () => { itemNode.addComponent(cc.Button);
global.middleLayer.backPageNode = this.node; itemNode.on("click", async () => {
global.middleLayer.loadOnlineCourseWare(data.id, null, (flag)=>{ global.middleLayer.backPageNode = this.node;
this.node.active=!flag global.middleLayer.loadOnlineCourseWare(data.id, null, (flag)=>{
this.node.active=!flag
});
})
global.middleLayer.callNetworkApiGet(`/api/courseware/v2/${data.id}/list`, {}, (data) => {
if (itemNode && data.rows && data.rows[0] && data.rows[0].data){
let _data = JSON.parse(data.rows[0].data)
if (_data && _data.dataArr){
itemNode.getChildByName("cntLbl").getComponent(cc.Label).string=String(_data.dataArr.length)
}
}
}); });
}) } else {
itemNode.getChildByName("cntLbl").active=false
global.middleLayer.callNetworkApiGet(`/api/courseware/v2/${data.id}/list`, {}, (data) => { itemNode.getChildByName("icon_video").active=false
if (itemNode && data.rows && data.rows[0] && data.rows[0].data){ }
let _data = JSON.parse(data.rows[0].data)
if (_data && _data.dataArr){
itemNode.getChildByName("cntLbl").getComponent(cc.Label).string=String(_data.dataArr.length)
}
}
});
itemArr.push(itemNode); itemArr.push(itemNode);
} }
......
...@@ -339,6 +339,30 @@ export default class NewClass extends cc.Component { ...@@ -339,6 +339,30 @@ export default class NewClass extends cc.Component {
async onClickDebug(){ async onClickDebug(){
const {code, msg, results} = await asyncCallNetworkApiGet(`/api/kyxq/v1/user/course/report`, {syllabusid:34396}) const {code, msg, results} = await asyncCallNetworkApiGet(`/api/kyxq/v1/user/course/report`, {syllabusid:34396})
this.LessonReport.active=true this.LessonReport.active=true
results.excellents.push({
overall:94,
record_url:"https://teach.cdn.ireadabc.com/157bd8b61f0fc7e9fb04f8a143be80b4.mp3",
example_url:"https://teach.cdn.ireadabc.com/157bd8b61f0fc7e9fb04f8a143be80b4.mp3",
test_text:"one two three",
})
results.excellents.push({
overall:80,
record_url:"https://teach.cdn.ireadabc.com/157bd8b61f0fc7e9fb04f8a143be80b4.mp3",
example_url:"https://teach.cdn.ireadabc.com/157bd8b61f0fc7e9fb04f8a143be80b4.mp3",
test_text:"what's is your name",
})
results.tryagains.push({
overall:55,
record_url:"https://teach.cdn.ireadabc.com/157bd8b61f0fc7e9fb04f8a143be80b4.mp3",
example_url:"https://teach.cdn.ireadabc.com/157bd8b61f0fc7e9fb04f8a143be80b4.mp3",
test_text:"what's is your name",
})
results.tryagains.push({
overall:23,
record_url:"https://teach.cdn.ireadabc.com/157bd8b61f0fc7e9fb04f8a143be80b4.mp3",
example_url:"https://teach.cdn.ireadabc.com/157bd8b61f0fc7e9fb04f8a143be80b4.mp3",
test_text:"what's is your name",
})
this.LessonReport.getComponent("LessonReport").setData(results) this.LessonReport.getComponent("LessonReport").setData(results)
this.LessonReport.getComponent("LessonReport").refreshUI() this.LessonReport.getComponent("LessonReport").refreshUI()
} }
......
...@@ -28,7 +28,7 @@ export default class NewClass extends cc.Component { ...@@ -28,7 +28,7 @@ export default class NewClass extends cc.Component {
btn_works: cc.Node = null; btn_works: cc.Node = null;
@property(cc.Node) @property(cc.Node)
LessonPreview: cc.Node = null; LessonBrief: cc.Node = null;
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
...@@ -129,12 +129,11 @@ export default class NewClass extends cc.Component { ...@@ -129,12 +129,11 @@ export default class NewClass extends cc.Component {
this.configData=[] this.configData=[]
for (let v of resData.rows){ for (let v of resData.rows){
if (v.name=="config"){ if (v.name=="config"){
console.log("qsj??",v)
const {rows} = await asyncCallNetworkApiGet(`/api/courseware/v2/${v.id}/list`, {}); const {rows} = await asyncCallNetworkApiGet(`/api/courseware/v2/${v.id}/list`, {});
console.log("qsj!!",rows)
if (rows && rows[0] && rows[0].data){ if (rows && rows[0] && rows[0].data){
let _data = JSON.parse(rows[0].data) let _data = JSON.parse(rows[0].data)
this.configData=_data.pages this.configData=_data.pages
console.log("config data", this.configData)
} }
} else { } else {
rows.push(v) rows.push(v)
...@@ -343,10 +342,26 @@ export default class NewClass extends cc.Component { ...@@ -343,10 +342,26 @@ export default class NewClass extends cc.Component {
} }
onClickPreview(){ onClickPreview(){
this.LessonPreview.active=true this.LessonBrief.active=true
this.LessonPreview.getComponent("LessonPreview").setData(this.configData) let _data=this.configData
this.LessonPreview.getComponent("LessonPreview").refreshUI() if (_data && _data[0]){
this.LessonBrief.getComponent("LessonBrief").setData(_data[0])
}
this.LessonBrief.getComponent("LessonBrief").refreshUI()
}
onClickMyWork(evt: cc.Event) {
const syllabusId = this.node['syllabus_pid']
if (!syllabusId) {
global.middleLayer.showTips(`未制作`);
return;
}
const vc = this.Viewer.getComponent("PageViewer");
vc[`libraryVideoPage`].attr({syllabus_pid: this.node['syllabus_pid'], showMyWork:true});
vc[`libraryVideoPage`].attr({fromPage: "UnitPage"});
vc.toView(`LibraryVideoPage`, "rightIn");
} }
// update (dt) {} // update (dt) {}
} }
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