| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- import {_decorator, Color, Component, Label, Node, Sprite, tween, Vec3} from 'cc';
- import {UserInfo} from '../../script/UserInfo';
- import {HttpUtils} from '../../script/utils/HttpUtils';
- const {ccclass, property} = _decorator;
- @ccclass('ResultMgr')
- export class ResultMgr extends Component {
- protected onLoad(): void {
- this.node.getChildByName("halo").getChildByName("halo").getComponent(Sprite).fillRange = 0
- this.node.getChildByName("Label3").getComponent(Label).string = ""
- this.node.getChildByName("Label5").getComponent(Label).string = ""
- this.node.getChildByName("Label6").getComponent(Label).string = ""
- }
- start() {
- this.sendData()
- if (UserInfo.score <= 0) {
- this.node.getChildByName("Label3").getComponent(Label).string = "0"
- this.setLabels2()
- } else {
- this.node.getChildByName("halo").getChildByName("halo").getComponent(Sprite).color = Color.RED
- const tw = tween(this.node.getChildByName("halo").getChildByName("halo").getComponent(Sprite)).to(2, {fillRange: 1}, {
- onUpdate: (target: Vec3, ratio: number) => {
- // console.log("000000= "+ratio);
- this.node.getChildByName("Label3").getComponent(Label).string = Math.floor(ratio * 100) + "%"
- if (ratio < 0.3) {
- this.node.getChildByName("halo").getChildByName("halo").getComponent(Sprite).color = new Color(206, 37, 37, 255)
- } else if (ratio > 0.7) {
- this.node.getChildByName("halo").getChildByName("halo").getComponent(Sprite).color = new Color(151, 206, 37, 255)
- } else {
- this.node.getChildByName("halo").getChildByName("halo").getComponent(Sprite).color = new Color(206, 129, 37, 255)
- }
- if (ratio > UserInfo.totalRight / UserInfo.totalQuestion) {
- tw.stop()
- this.setLabels2()
- }
- }
- })
- .call(() => {
- this.setLabels2()
- })
- .start()
- }
- }
- /**
- * 上一个版本的结算数据,现在已经不用了
- */
- private setLabels() {
- this.node.getChildByName("Label5").getComponent(Label).string = UserInfo.aveTime.toFixed(3) + "秒"
- // if (UserInfo.score < 20) {
- // if (UserInfo.aveTime < 2.5) {
- // // this.node.getChildByName("Label6").getComponent(Label).string = "您回答的速度太快了,请在保持速度的同时提高准确率!"
- // this.node.getChildByName("Label6").getComponent(Label).string = "您回答的速度太快了,并且准确率太低。建议您找专业医护人员进行检查!"
- // } else if (UserInfo.aveTime > 10) {
- // this.node.getChildByName("Label6").getComponent(Label).string = "您回答的速度太慢了,您的准确率和速度都不太理想,建议您找专业医护人员进行检查!"
- // // this.node.getChildByName("Label6").getComponent(Label).string = "您答题的速度都有待提高哦!加油!"
- // } else {
- // this.node.getChildByName("Label6").getComponent(Label).string = "您的答题速度还不错,但准确率太低了,建议您找专业医护人员进行检查!"
- // // this.node.getChildByName("Label6").getComponent(Label).string = "您答题的速度和正确率都有待提高哦!加油!"
- // }
- // } else if (UserInfo.score > 50) {
- // if (UserInfo.aveTime < 2.5) {
- // // this.node.getChildByName("Label6").getComponent(Label).string = "您的准确率表现很好,但您回答的速度太快了,请仔细思考后作答!"
- // this.node.getChildByName("Label6").getComponent(Label).string = "太棒了!您的准确率和答题速度都非常棒!请继续保持!"
- // } else if (UserInfo.aveTime > 10) {
- // // this.node.getChildByName("Label6").getComponent(Label).string = "您的准确率表现很好,但您回答的速度太慢了,请在保持准确的同时提高速度!"
- // this.node.getChildByName("Label6").getComponent(Label).string = "您的准确率很棒哦,但是您答题的速度太慢。请多加练习,提高速度。加油!"
- // } else {
- // // this.node.getChildByName("Label6").getComponent(Label).string = "您的准确率和反应速度表现得很稳定,不错!"
- // this.node.getChildByName("Label6").getComponent(Label).string = "您的准确率很棒哦,答题速度也不错。请继续加油哦!"
- // }
- // } else {
- // if (UserInfo.aveTime < 2.5) {
- // // this.node.getChildByName("Label6").getComponent(Label).string = "虽然您的准确率表现一般,但您的回答速度太快了,请仔细思考后作答!"
- // this.node.getChildByName("Label6").getComponent(Label).string = "您的答题准确率一般哦,但是您的回答速度很快。请您多加练习,提高准确率!"
- // } else if (UserInfo.aveTime > 10) {
- // // this.node.getChildByName("Label6").getComponent(Label).string = "您的准确性表现一般,但您的回答速度有待提高,继续加油哦!"
- // this.node.getChildByName("Label6").getComponent(Label).string = "您的答题准确率一般哦,而且您的回答速度太慢。请您多加练习,加油哦!"
- // } else {
- // // this.node.getChildByName("Label6").getComponent(Label).string = "您的准确性和反应速度表现一般,继续加油哦!"
- // this.node.getChildByName("Label6").getComponent(Label).string = "您的准确率和反应速度都一般哦,请您多加练习,加油哦!"
- // }
- // }
- // 20分-50分,2.5s以下:虽然您的准确率表现一般,但您的回答速度太快了,请仔细思考后作答!
- // 20分-50分,2.5-15s:您的准确性和反应速度表现一般,继续加油哦!
- // 20分-50分,15s以上:您的准确性表现一般,但您的回答速度有待提高,继续加油哦!
- // 20分以下,2.5s以下:您回答的速度太快了,请在保持速度的同时提高准确率!
- // 20分以下,2.5-15s:您的准确性和反应速度都有待提高哦!
- // 20分以下,15s以上:您回答的速度太慢了,您的准确率和速度都有待提高哦!
- // 50分以上,2.5s以下:您的准确率表现很好,但您回答的速度太快了,请仔细思考后作答!
- // 50分以上,2.5-15s:您的准确率和反应速度表现得很稳定,不错!
- // 50分以上,15s以上:您的准确率表现很好,但您回答的速度太慢了,请在保持准确的同时提高速度!
- }
- private setLabels2() {
- this.node.getChildByName("Label4").getComponent(Label).string = "您答对了" + UserInfo.totalRight + "道题"
- this.node.getChildByName("Label5").getComponent(Label).string = "您答错了" + UserInfo.totalWrong + "道题"
- this.node.getChildByName("Label6").getComponent(Label).string = "您超时了" + UserInfo.totalTimeout + "道题"
- const t = UserInfo.totalRight / UserInfo.totalQuestion
- if (t < 0.3) {
- this.node.getChildByName("Label7").getComponent(Label).string = "您属于高风险人群"
- this.node.getChildByName("Label7").getComponent(Label).color = new Color(206, 37, 37, 255)
- } else if (t > 0.7) {
- this.node.getChildByName("Label7").getComponent(Label).string = "您属于低风险人群"
- this.node.getChildByName("Label7").getComponent(Label).color = new Color(151, 206, 37, 255)
- } else {
- this.node.getChildByName("Label7").getComponent(Label).string = "您属于中风险人群"
- this.node.getChildByName("Label7").getComponent(Label).color = new Color(206, 129, 37, 255)
- }
- }
- private async sendData() {
- // console.log("00000000000000= " + Math.floor(UserInfo.totalRight / UserInfo.totalQuestion*100) + " " + UserInfo.score);
- const data: any = {
- "phone": UserInfo.phone,
- "sourceCode": UserInfo.sourceCode,
- "score": Math.floor(UserInfo.totalRight / UserInfo.totalQuestion * 100),
- "aveTime": UserInfo.aveTime,
- "hospitalId": UserInfo.hospitalId,
- "hospitalName": UserInfo.hospitalName,
- "totalRight": UserInfo.totalRight,
- "totalWrong": UserInfo.totalWrong,
- "totalTimeout": UserInfo.totalTimeout,
- "totalQuestion": UserInfo.totalQuestion,
- "details": UserInfo.details
- }
- // console.log("111111111111= "+JSON.stringify(data));
- const ret = await HttpUtils.sendPost(HttpUtils.ip + "/detect/add", data)
- console.log("...receive data: " + JSON.stringify(ret));
- }
- update(deltaTime: number) {
- }
- }
|