import { _decorator, Component, Label, Node } from 'cc'; import { http } from '../http'; import { config } from '../config'; import { audioManager } from '../manager/audioManager'; import { uiManager } from '../manager/uiManager'; import { user_results } from '../data'; import { userDataManager } from '../manager/userDataManager'; import { ClientEvent } from '../lib/clientEvent'; import { SdkUtil } from '../sdkUtil'; import { results_unlock_car } from './results_unlock_car'; import { base_ui } from '../fw/base_ui'; import { GameManager } from '../GameManager'; import { restart_view } from '../ui/restart_view'; const { ccclass, property } = _decorator; @ccclass('results') export class results extends base_ui { @property(Node) btn_restart:Node = null @property(Node) lab_scores:Node = null @property(Node) btn_back_home:Node = null @property(Node) btn_video_reLife:Node = null @property(Node) unlock_car:Node = null @property(Node) btn_share:Node = null @property(Node) lab_des:Node = null private call_back = null private back_home_cb = null start() { this.onButtonListen(this.btn_restart,()=>{ if(this.call_back!=null){ GameManager.checkPlayGame(this.node,()=>{ this.call_back(false) this.close() }) } // this.onClickRestart() }) this.onButtonListen(this.btn_back_home,()=>{ if(this.back_home_cb){ this.back_home_cb() } }) this.onButtonListen(this.btn_video_reLife,()=>{ GameManager.showVideoAd(config.ADS_TYPE.GAME_RELIFE_VIDEO, ()=>{ if(this.call_back){ this.call_back(true) this.close() } }) }) this.onButtonListen(this.btn_share,()=>{ SdkUtil.shareGameVideo() }) } protected close(): void { this.node.active = false; } public show(scores:number,jiesuan_finish_cb,call,back_home_cb,isReLife:boolean){ this.back_home_cb = back_home_cb this.btn_video_reLife.active = isReLife http.post(config.API.sync_integral,{"integral":scores},(err,data)=>{ if(!err){ let d = JSON.parse(data) if(d.code===config.status.SUCCESS){ let res:user_results = d.content if(res.obtain_list.length<=0){ this.unlock_car.getComponent(results_unlock_car).hide() console.log("啥也没获取到") }else{ this.unlock_car.getComponent(results_unlock_car).show(res.default_car_id) ClientEvent.dispatchEvent(config.UI_EVENT.GET_NEW_CAR,res) } this.lab_des.getComponent(Label).string=`已超过全国${res.ratio}的司机` ClientEvent.dispatchEvent(config.UI_EVENT.GAME_OVER_SETTLE_ACCOUNT,res) } // http.get(config.STATIC_API.regions,(e,d)=>{ // console.log("regions",d) // }) // http.get(config.STATIC_API.rankings(0),(err,data)=>{ // console.log("rankings",data) // }) } jiesuan_finish_cb() }) audioManager.Instance().playSound(config.AUDIO.win) this.node.active = true this.lab_scores.getComponent(Label).string =scores+"" this.call_back = call } }