home_bottom.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import { _decorator, Component, Label, Node, Animation } from 'cc';
  2. import { uiManager } from '../../manager/uiManager';
  3. import { config } from '../../config';
  4. import { user_info_view } from '../user_info_view';
  5. import { home_bottom_rank_item } from './home_bottom_rank_item';
  6. import { GameManager } from '../../GameManager';
  7. import { tools } from '../../tools';
  8. import { home_honor } from './home_honor';
  9. import { home_bottom_countdown } from './home_bottom_countdown';
  10. import { unLock_view } from '../unLock_view';
  11. import { userDataManager } from '../../manager/userDataManager';
  12. import { home_tt_sidebar } from './home_tt_sidebar';
  13. import { SdkUtil } from '../../sdkUtil';
  14. const { ccclass, property } = _decorator;
  15. @ccclass('home_bottom')
  16. export class home_bottom extends Component {
  17. @property(Node) img_honor:Node = null
  18. @property(Node) btn_wenhao:Node = null
  19. @property(Node) btn_gengduo:Node = null
  20. @property(Node) rank1_node:Node = null
  21. @property(Node) rank2_node:Node = null
  22. @property(Node) rank3_node:Node = null
  23. @property(Node) lab_week_score:Node = null
  24. @property(Node) btn_wuxiancishu:Node = null
  25. @property(Node) countdown_node:Node = null
  26. @property(Node) tt_btn_gift:Node = null
  27. @property(Node) tt_sidebar:Node = null
  28. start() {
  29. uiManager.Instance().onButtonListen(this.btn_wenhao, ()=>{
  30. uiManager.Instance().showUi(config.UI.ui_gameplay_view)
  31. })
  32. uiManager.Instance().onButtonListen(this.btn_gengduo, ()=>{
  33. this.node.parent.active = false
  34. uiManager.Instance().showUi(config.UI.rank, null, ()=>{
  35. this.node.parent.active = true
  36. })
  37. })
  38. uiManager.Instance().onButtonListen(this.btn_wuxiancishu, ()=>{
  39. if(userDataManager.getUserIsFreeAds()) {
  40. return
  41. }
  42. uiManager.Instance().showUi(config.UI.ui_unLock_view, null, (node:Node)=>{
  43. node.getComponent(unLock_view).initView((v:unLock_view)=>{
  44. this.reloadCountdown()
  45. })
  46. })
  47. })
  48. uiManager.Instance().onButtonListen(this.tt_btn_gift, ()=>{
  49. this.onClickTTLihe()
  50. })
  51. }
  52. public init() {
  53. this.reloadWeekScore()
  54. this.reloadHonorData()
  55. this.reloadCountdown()
  56. this.reloadCountryRankData()
  57. this.reloadTTSidebar()
  58. }
  59. public reloadWeekScore() {
  60. this.lab_week_score.getComponent(Label).string = tools.mine_rank_data.score + ''
  61. }
  62. private reloadHonorData() {
  63. this.img_honor.getComponent(home_honor).initView()
  64. }
  65. private reloadCountdown() {
  66. this.countdown_node.getComponent(home_bottom_countdown).startTime((is_active)=>{
  67. this.btn_wuxiancishu.active = !is_active
  68. })
  69. }
  70. public reloadCountryRankData(){
  71. GameManager.requestRankList(0, (d_content)=>{
  72. if(d_content.length>0) {
  73. let rank_data = d_content[0]
  74. this.rank1_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  75. }
  76. if(d_content.length>1) {
  77. let rank_data = d_content[1]
  78. this.rank2_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  79. }
  80. if(d_content.length>2) {
  81. let rank_data = d_content[2]
  82. this.rank3_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  83. }
  84. })
  85. }
  86. private onClickRankGotoUserInfo(item:home_bottom_rank_item) {
  87. let data = item.getData()
  88. if(data == null) {
  89. return
  90. }
  91. uiManager.Instance().showUi(config.UI.ui_user_info_view, null, (node:Node)=>{
  92. node.getComponent(user_info_view).initView(data)
  93. })
  94. }
  95. private reloadTTSidebar() {
  96. this.tt_btn_gift.active = false
  97. if(SdkUtil.ttCheckSceneShowRewards()==false || userDataManager.user_data.tt_sidebar_reward_status==1) {
  98. return
  99. }
  100. this.tt_btn_gift.active = true
  101. this.tt_btn_gift.getComponent(Animation).play()
  102. }
  103. private onClickTTLihe() {
  104. let isToEnterFromSidebar = SdkUtil.ttCheckToEnterFromSidebar()
  105. this.tt_sidebar.getComponent(home_tt_sidebar).show(isToEnterFromSidebar, (r:home_tt_sidebar)=>{
  106. SdkUtil.ttNavToSidebarScene()
  107. r.close()
  108. },(r:home_tt_sidebar)=>{
  109. GameManager.requestTTSidebarUserReward(config.USER_TT_SIDEBAR_REWARD.SYNC, (d_content)=>{
  110. userDataManager.user_data.tt_sidebar_reward_status = d_content.status
  111. this.tt_btn_gift.active = false
  112. this.tt_btn_gift.getComponent(Animation).stop()
  113. r.close()
  114. })
  115. })
  116. }
  117. }