results.ts 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { http } from '../http';
  3. import { config } from '../config';
  4. import { audioManager } from '../manager/audioManager';
  5. import { uiManager } from '../manager/uiManager';
  6. import { user_results } from '../data';
  7. import { userDataManager } from '../manager/userDataManager';
  8. import { ClientEvent } from '../lib/clientEvent';
  9. import { SdkUtil } from '../sdkUtil';
  10. import { results_unlock_car } from './results_unlock_car';
  11. import { base_ui } from '../fw/base_ui';
  12. import { GameManager } from '../GameManager';
  13. import { restart_view } from '../ui/restart_view';
  14. const { ccclass, property } = _decorator;
  15. @ccclass('results')
  16. export class results extends base_ui {
  17. @property(Node) btn_restart:Node = null
  18. @property(Node) lab_scores:Node = null
  19. @property(Node) btn_back_home:Node = null
  20. @property(Node) btn_video_reLife:Node = null
  21. @property(Node) unlock_car:Node = null
  22. @property(Node) btn_share:Node = null
  23. @property(Node) lab_des:Node = null
  24. private call_back = null
  25. private back_home_cb = null
  26. start() {
  27. this.onButtonListen(this.btn_restart,()=>{
  28. if(this.call_back!=null){
  29. GameManager.checkPlayGame(this.node,()=>{
  30. this.call_back(false)
  31. this.close()
  32. })
  33. }
  34. // this.onClickRestart()
  35. })
  36. this.onButtonListen(this.btn_back_home,()=>{
  37. if(this.back_home_cb){
  38. this.back_home_cb()
  39. }
  40. })
  41. this.onButtonListen(this.btn_video_reLife,()=>{
  42. GameManager.showVideoAd(config.ADS_TYPE.GAME_RELIFE_VIDEO, ()=>{
  43. if(this.call_back){
  44. this.call_back(true)
  45. this.close()
  46. }
  47. })
  48. })
  49. this.onButtonListen(this.btn_share,()=>{
  50. SdkUtil.shareGameVideo()
  51. })
  52. }
  53. protected close(): void {
  54. this.node.active = false;
  55. }
  56. public show(scores:number,jiesuan_finish_cb,call,back_home_cb,isReLife:boolean){
  57. this.back_home_cb = back_home_cb
  58. this.btn_video_reLife.active = isReLife
  59. http.post(config.API.sync_integral,{"integral":scores},(err,data)=>{
  60. if(!err){
  61. let d = JSON.parse(data)
  62. if(d.code===config.status.SUCCESS){
  63. let res:user_results = d.content
  64. if(res.obtain_list.length<=0){
  65. this.unlock_car.getComponent(results_unlock_car).hide()
  66. console.log("啥也没获取到")
  67. }else{
  68. this.unlock_car.getComponent(results_unlock_car).show(res.default_car_id)
  69. ClientEvent.dispatchEvent(config.UI_EVENT.GET_NEW_CAR,res)
  70. }
  71. this.lab_des.getComponent(Label).string=`已超过全国${res.ratio}的司机`
  72. ClientEvent.dispatchEvent(config.UI_EVENT.GAME_OVER_SETTLE_ACCOUNT,res)
  73. }
  74. // http.get(config.STATIC_API.regions,(e,d)=>{
  75. // console.log("regions",d)
  76. // })
  77. // http.get(config.STATIC_API.rankings(0),(err,data)=>{
  78. // console.log("rankings",data)
  79. // })
  80. }
  81. jiesuan_finish_cb()
  82. })
  83. audioManager.Instance().playSound(config.AUDIO.win)
  84. this.node.active = true
  85. this.lab_scores.getComponent(Label).string =scores+""
  86. this.call_back = call
  87. }
  88. }