Commit ce1a1fd0 authored by 李维's avatar 李维

优化学习报告数字显示

parent 77236077
......@@ -14801,7 +14801,7 @@
"horizontal": true,
"vertical": false,
"inertia": true,
"brake": 0.75,
"brake": 0.3,
"elastic": true,
"bounceDuration": 0.23,
"scrollEvents": [],
......@@ -19608,7 +19608,7 @@
"horizontal": true,
"vertical": false,
"inertia": true,
"brake": 0.75,
"brake": 0.3,
"elastic": true,
"bounceDuration": 0.23,
"scrollEvents": [],
......@@ -25396,7 +25396,7 @@
"ctor": "Float64Array",
"array": [
-570,
205,
200,
0,
0,
0,
......@@ -25759,19 +25759,19 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 84.2,
"width": 263.16,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"x": 1,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-400,
-285.003,
-302,
0,
0,
......@@ -25811,8 +25811,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "Lable",
"_N$string": "Lable",
"_string": "2023.11.11 未学过",
"_N$string": "2023.11.11 未学过",
"_fontSize": 36,
"_lineHeight": 40,
"_enableWrapText": true,
......@@ -27883,8 +27883,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 129.13,
"height": 75.6
"width": 136.11,
"height": 98.28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -27937,8 +27937,8 @@
"_dstBlendFactor": 771,
"_string": "93%",
"_N$string": "93%",
"_fontSize": 74,
"_lineHeight": 60,
"_fontSize": 78,
"_lineHeight": 78,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "86a73b35-ea84-4acf-83dc-d18b68083b2e"
......@@ -27948,8 +27948,8 @@
"_batchAsBitmap": false,
"_styleFlags": 1,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
......@@ -27981,7 +27981,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 129.13,
"height": 75.6
"height": 93.24
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -28035,7 +28035,7 @@
"_string": "93%",
"_N$string": "93%",
"_fontSize": 74,
"_lineHeight": 60,
"_lineHeight": 74,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "86a73b35-ea84-4acf-83dc-d18b68083b2e"
......@@ -28045,8 +28045,8 @@
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
......@@ -28225,8 +28225,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-301,
-79.662,
-300,
-80,
0,
0,
0,
......@@ -28276,7 +28276,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 120,
"height": 75.6
"height": 93.24
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -28287,8 +28287,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
4.882,
-8.622,
5,
0,
0,
0,
0,
......@@ -28330,7 +28330,7 @@
"_string": "42",
"_N$string": "42",
"_fontSize": 74,
"_lineHeight": 80,
"_lineHeight": 74,
"_enableWrapText": false,
"_N$file": {
"__uuid__": "86a73b35-ea84-4acf-83dc-d18b68083b2e"
......@@ -28341,7 +28341,7 @@
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 2,
"_N$verticalAlign": 2,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 2,
"_N$cacheMode": 0,
......@@ -28377,15 +28377,15 @@
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
40.8,
-18.8,
15,
-12,
0,
0,
0,
......@@ -28438,7 +28438,7 @@
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
......@@ -28617,8 +28617,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-2,
-79.662,
0,
-80,
0,
0,
0,
......@@ -28679,7 +28679,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
18.925,
5,
0,
0,
0,
......@@ -28722,7 +28722,7 @@
"_string": "52",
"_N$string": "52",
"_fontSize": 74,
"_lineHeight": 60,
"_lineHeight": 74,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "86a73b35-ea84-4acf-83dc-d18b68083b2e"
......@@ -28769,15 +28769,15 @@
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
43,
-20,
15,
-12,
0,
0,
0,
......@@ -28830,7 +28830,7 @@
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
......@@ -29010,7 +29010,7 @@
"ctor": "Float64Array",
"array": [
300,
-79.662,
-80,
0,
0,
0,
......@@ -29071,7 +29071,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
16.27,
5,
0,
0,
0,
......@@ -29114,7 +29114,7 @@
"_string": "20",
"_N$string": "20",
"_fontSize": 74,
"_lineHeight": 60,
"_lineHeight": 74,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "86a73b35-ea84-4acf-83dc-d18b68083b2e"
......@@ -29125,7 +29125,7 @@
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 2,
"_N$verticalAlign": 0,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 2,
"_N$cacheMode": 0,
......@@ -29161,15 +29161,15 @@
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
42,
-20,
15,
-12,
0,
0,
0,
......@@ -29222,7 +29222,7 @@
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 0,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
......@@ -32259,9 +32259,6 @@
"mask": {
"__id__": 580
},
"study_duration": {
"__id__": 633
},
"last_play": {
"__id__": 584
},
......@@ -32271,6 +32268,12 @@
"question_right_percent2": {
"__id__": 627
},
"study_duration": {
"__id__": 633
},
"study_duration_unit": {
"__id__": 635
},
"record_times": {
"__id__": 649
},
......
......@@ -4,8 +4,8 @@
// - 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;
import { playAudioByUrl, getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay, dateFormate } from "./util";
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
......@@ -17,14 +17,16 @@ export default class NewClass extends cc.Component {
@property(cc.Node)
mask: cc.Node = null;
@property(cc.Label)
study_duration: cc.Label = null;
@property(cc.Label)
last_play: cc.Label = null;
@property(cc.Label)
question_right_percent1: cc.Label = null;
@property(cc.Label)
question_right_percent2: cc.Label = null;
@property(cc.Label)
study_duration: cc.Label = null;
@property(cc.Label)
study_duration_unit: cc.Label = null;
@property(cc.Label)
record_times: cc.Label = null;
@property(cc.Label)
question_times: cc.Label = null;
......@@ -60,111 +62,116 @@ export default class NewClass extends cc.Component {
nd_storyStory: cc.Node = null;
// LIFE-CYCLE CALLBACKS:
m_sentenceNodeList=[]
m_sentenceNodeList = []
onLoad () {
this.scentenceItem.active=false
this.storyItem.zIndex=111
this.itemCnt.zIndex=-1
onLoad() {
this.scentenceItem.active = false
this.storyItem.zIndex = 111
this.itemCnt.zIndex = -1
}
data
setData(data){
this.data=data
setData(data) {
this.data = data
}
isAudioPlaying=false
isAudioPlaying = false
playAudioId
refreshUI(){
refreshUI() {
this.stopAudio()
for (let v of this.m_sentenceNodeList){
for (let v of this.m_sentenceNodeList) {
v.removeFromParent()
}
if(!this.data) return
let _data=this.data
if (!this.data) return
let _data = this.data
getSprNodeByUrl(_data.cover, (spr) => {
this.mask.addChild(spr.node);
spr.srcBlendFactor = cc.macro.BlendFactor.ONE
setSprNodeMaxLen(spr.node, this.mask.width, this.mask.height);
setSprNodeMaxLen(spr.node, this.mask.width, this.mask.height, true);
});
const lastDate = _data.last_play ? new Date(_data.last_play) : null;
const studyDuration = _data.study_duration
this.title.string = _data.name
this.unit.string = _data.unitName
this.last_play.string = lastDate ? `${dateFormate("yyyy.MM.dd", lastDate)} 学习过` : "未学过"
this.question_right_percent1.string = _data.question_right_percent // 正确率 - 白色描边
this.question_right_percent2.string = _data.question_right_percent // 正确率 - 主体红字
this.study_duration.string = _data.study_duration > 999 ? Math.floor(_data.study_duration / 60 * 10) / 10 : _data.study_duration // 学习时长
this.study_duration_unit.string = _data.study_duration > 999 ? "小时" : "分钟";
this.title.string=_data.name
this.unit.string=_data.unitName
this.study_duration.string=_data.study_duration
this.last_play.string=_data.last_play && new Date(_data.last_play).toLocaleString() || ""
this.question_right_percent1.string=_data.question_right_percent
this.question_right_percent2.string=_data.question_right_percent
this.record_times.string=_data.record_times
this.question_times.string=_data.question_times
this.question_times.string = _data.question_times // 练习次数
this.record_times.string = _data.record_times // 开口次数
for (let i=1;i<=5;i++){
let _star=this.stars.getChildByName(`icon_star${i}`)
_star.active=_data.question_right_percent >= 20*i
for (let i = 1; i <= 5; i++) {
let _star = this.stars.getChildByName(`icon_star${i}`)
_star.active = _data.question_right_percent >= 20 * i
}
this.m_sentenceNodeList=[]
for (let v of _data.excellents){
this.m_sentenceNodeList = []
for (let v of _data.excellents) {
this.m_sentenceNodeList.push(this.createItem(v, "优秀发音"))
}
for (let v of _data.tryagains){
for (let v of _data.tryagains) {
this.m_sentenceNodeList.push(this.createItem(v, "薄弱跟读"))
}
// 句子
if (_data.knowledge){
if (_data.knowledge.word){
this.storyWord.string=_data.knowledge.word
this.nd_storyWord.active=true
if (_data.knowledge) {
if (_data.knowledge.word) {
this.storyWord.string = _data.knowledge.word
this.nd_storyWord.active = true
} else {
this.nd_storyWord.active=false
this.nd_storyWord.active = false
}
if (_data.knowledge.sentence){
this.storyScentence.string=_data.knowledge.sentence
this.nd_storySentence.active=true
if (_data.knowledge.sentence) {
this.storyScentence.string = _data.knowledge.sentence
this.nd_storySentence.active = true
} else {
this.nd_storySentence.active=false
this.nd_storySentence.active = false
}
if (_data.knowledge.story){
this.storyStory.string=_data.knowledge.story
this.nd_storyStory.active=true
if (_data.knowledge.story) {
this.storyStory.string = _data.knowledge.story
this.nd_storyStory.active = true
} else {
this.nd_storyStory.active=false
this.nd_storyStory.active = false
}
if (!_data.knowledge.word&&
!_data.knowledge.sentence&&
!_data.knowledge.story)
{
this.storyItem.active=false
if (!_data.knowledge.word &&
!_data.knowledge.sentence &&
!_data.knowledge.story) {
this.storyItem.active = false
} else {
this.storyItem.active=true
this.storyItem.active = true
}
} else {
this.storyItem.active=false
this.storyItem.active = false
}
this.reportSV.scrollToTop()
}
createItem(v, titleStr){
createItem(v, titleStr) {
let _node = cc.instantiate(this.scentenceItem)
_node.active=true
_node.active = true
this.content.addChild(_node)
// 星星的判定标准需要改
for (let i=1;i<=3;i++){
_node.getChildByName(`star${i}`).active=v.overall>=i*33
for (let i = 1; i <= 3; i++) {
_node.getChildByName(`star${i}`).active = v.overall >= i * 33
}
_node.getChildByName("lbl").getComponent(cc.Label).string=v.test_text
_node.getChildByName("title").getComponent(cc.Label).string=titleStr
_node.getChildByName("lbl").getComponent(cc.Label).string = v.test_text
_node.getChildByName("title").getComponent(cc.Label).string = titleStr
let btn_stop=_node.getChildByName("btn_stop")
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
let btn_stop = _node.getChildByName("btn_stop")
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
......@@ -173,7 +180,7 @@ export default class NewClass extends cc.Component {
cc.assetManager.loadRemote(v.example_url, (err, audioClip) => {
this.playAudioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.playAudioId, () => {
this.playAudioId=null
this.playAudioId = null
this.isAudioPlaying = false;
});
})
......@@ -181,13 +188,13 @@ export default class NewClass extends cc.Component {
btn_play.on("click", () => {
if (!v.record_url) return
this.stopAudio()
btn_play.active=false
btn_stop.active=true
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.playAudioId = null
this.isAudioPlaying = false;
});
})
......@@ -195,26 +202,26 @@ export default class NewClass extends cc.Component {
btn_stop.on("click", () => {
this.stopAudio()
})
_node.on("stop_audio", ()=>{
btn_play.active=true
btn_stop.active=false
_node.on("stop_audio", () => {
btn_play.active = true
btn_stop.active = false
})
return _node
}
stopAudio(){
if (this.playAudioId!=null) cc.audioEngine.stop(this.playAudioId)
this.playAudioId=null
this.isAudioPlaying=false
for (let v of this.m_sentenceNodeList){
stopAudio() {
if (this.playAudioId != null) cc.audioEngine.stop(this.playAudioId)
this.playAudioId = null
this.isAudioPlaying = false
for (let v of this.m_sentenceNodeList) {
v.emit("stop_audio")
}
}
onClickClose(){
onClickClose() {
this.stopAudio()
this.node.active=false
this.node.active = false
}
// update (dt) {}
......
......@@ -502,3 +502,22 @@ export function formatTime(time) {
return `${hh}${mm}:${ss}`;
}
// "yyyy-MM-dd hh:mm:ss
export function dateFormate(fmt, date) {
var o = {
"M+": date.getMonth() + 1, //月份
"d+": date.getDate(), //日
"h+": date.getHours(), //小时
"m+": date.getMinutes(), //分
"s+": date.getSeconds(), //秒
"q+": Math.floor((date.getMonth() + 3) / 3), //季度
"S": date.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
\ No newline at end of file
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