results.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { http } from '../http';
  3. import { config } from '../config';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('results')
  6. export class results extends Component {
  7. @property(Node) btn_restart:Node = null
  8. @property(Node) lab_scores:Node = null
  9. private call_back = null
  10. start() {
  11. this.btn_restart.on(Node.EventType.TOUCH_END,()=>{
  12. if(this.call_back!=null){
  13. this.call_back()
  14. this.close()
  15. }
  16. })
  17. }
  18. private close(){
  19. this.node.active = false;
  20. }
  21. public show(scores:number,call){
  22. http.post(config.API.sync_integral,{"integral":scores},(err,data)=>{
  23. if(!err){
  24. console.log("data",data)
  25. // http.get(config.STATIC_API.regions,(e,d)=>{
  26. // console.log("regions",d)
  27. // })
  28. http.get(config.STATIC_API.rankings(0),(err,data)=>{
  29. console.log("rankings",data)
  30. })
  31. }
  32. })
  33. this.node.active = true
  34. this.lab_scores.getComponent(Label).string = "积分:"+ scores+""
  35. this.call_back = call
  36. }
  37. }