import { _decorator, Component, Label, Node, Animation } from 'cc'; import { uiManager } from '../../manager/uiManager'; import { config } from '../../config'; import { user_info_view } from '../user_info_view'; import { home_bottom_rank_item } from './home_bottom_rank_item'; import { GameManager } from '../../GameManager'; import { tools } from '../../tools'; import { home_honor } from './home_honor'; import { home_bottom_countdown } from './home_bottom_countdown'; import { unLock_view } from '../unLock_view'; import { userDataManager } from '../../manager/userDataManager'; import { home_tt_sidebar } from './home_tt_sidebar'; import { SdkUtil } from '../../sdkUtil'; import { ClientEvent } from '../../lib/clientEvent'; import { rank } from '../rank/rank'; const { ccclass, property } = _decorator; @ccclass('home_bottom') export class home_bottom extends Component { @property(Node) img_honor:Node = null @property(Node) btn_wenhao:Node = null @property(Node) btn_gengduo:Node = null @property(Node) rank1_node:Node = null @property(Node) rank2_node:Node = null @property(Node) rank3_node:Node = null @property(Node) lab_week_score:Node = null @property(Node) btn_wuxiancishu:Node = null @property(Node) countdown_node:Node = null @property(Node) tt_btn_gift:Node = null @property(Node) tt_sidebar:Node = null start() { uiManager.Instance().onButtonListen(this.btn_wenhao, ()=>{ uiManager.Instance().showUi(config.UI.ui_gameplay_view) }) uiManager.Instance().onButtonListen(this.btn_gengduo, ()=>{ this.node.parent.active = false uiManager.Instance().showUi(config.UI.rank, null, (node:Node)=>{ node.getComponent(rank).onReloadCountryDataCallback((d_content)=>{ this.reloadCountryRankData(d_content) }) this.node.parent.active = true }) }) uiManager.Instance().onButtonListen(this.btn_wuxiancishu, ()=>{ if(userDataManager.getUserIsFreeAds()) { return } uiManager.Instance().showUi(config.UI.ui_unLock_view, null, (node:Node)=>{ node.getComponent(unLock_view).initView((v:unLock_view)=>{ this.reloadCountdown() }) }) }) uiManager.Instance().onButtonListen(this.tt_btn_gift, ()=>{ this.onClickTTLihe() }) } public init() { this.reloadWeekScore() this.reloadHonorData() this.reloadCountdown() this.requestCountryRankData() this.reloadTTSidebar() } public reloadWeekScore() { this.lab_week_score.getComponent(Label).string = tools.mine_rank_data.score + '' } private reloadHonorData() { this.img_honor.getComponent(home_honor).initView() } private reloadCountdown() { this.countdown_node.getComponent(home_bottom_countdown).startTime((is_active)=>{ this.btn_wuxiancishu.active = !is_active }) } public requestCountryRankData(){ GameManager.requestRankList(0, (d_content)=>{ this.reloadCountryRankData(d_content) }) } private reloadCountryRankData(d_content) { if(d_content.length>0) { let rank_data = d_content[0] this.rank1_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this)) } if(d_content.length>1) { let rank_data = d_content[1] this.rank2_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this)) } if(d_content.length>2) { let rank_data = d_content[2] this.rank3_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this)) } } private onClickRankGotoUserInfo(item:home_bottom_rank_item) { let data = item.getData() if(data == null) { return } uiManager.Instance().showUi(config.UI.ui_user_info_view, null, (node:Node)=>{ node.getComponent(user_info_view).initView(data) }) } private reloadTTSidebar() { this.tt_btn_gift.active = false if(SdkUtil.ttCheckSceneShowRewards()==false || userDataManager.user_data.tt_sidebar_reward_status==1) { return } this.tt_btn_gift.active = true this.tt_btn_gift.getComponent(Animation).play() } private onClickTTLihe() { let isToEnterFromSidebar = SdkUtil.ttCheckToEnterFromSidebar() this.tt_sidebar.getComponent(home_tt_sidebar).show(isToEnterFromSidebar, (r:home_tt_sidebar)=>{ SdkUtil.ttNavToSidebarScene() r.close() },(r:home_tt_sidebar)=>{ GameManager.requestTTSidebarUserReward(config.USER_TT_SIDEBAR_REWARD.SYNC, (d_content)=>{ userDataManager.user_data.tt_sidebar_reward_status = d_content.status this.tt_btn_gift.active = false this.tt_btn_gift.getComponent(Animation).stop() this.ttSidebarReward() r.close() }) }) } private ttSidebarReward() { let add_seconds = 60*30 //30分钟 userDataManager.addUserFreeAdsSeconds(add_seconds) this.reloadCountdown() } }