home_bottom.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { _decorator, Component, Label, Node, Sprite, SpriteFrame } 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. const { ccclass, property } = _decorator;
  13. @ccclass('home_bottom')
  14. export class home_bottom extends Component {
  15. @property(Node) img_honor:Node = null
  16. @property(Node) btn_wenhao:Node = null
  17. @property(Node) btn_gengduo:Node = null
  18. @property(Node) rank1_node:Node = null
  19. @property(Node) rank2_node:Node = null
  20. @property(Node) rank3_node:Node = null
  21. @property(Node) lab_week_score:Node = null
  22. @property(Node) btn_wuxiancishu:Node = null
  23. @property(Node) countdown_node:Node = null
  24. start() {
  25. uiManager.Instance().onButtonListen(this.btn_wenhao, ()=>{
  26. uiManager.Instance().showUi(config.UI.ui_gameplay_view)
  27. })
  28. uiManager.Instance().onButtonListen(this.btn_gengduo, ()=>{
  29. this.node.parent.active = false
  30. uiManager.Instance().showUi(config.UI.rank, null, ()=>{
  31. this.node.parent.active = true
  32. })
  33. })
  34. uiManager.Instance().onButtonListen(this.btn_wuxiancishu, ()=>{
  35. if(userDataManager.getUserIsFreeAds()) {
  36. return
  37. }
  38. uiManager.Instance().showUi(config.UI.ui_unLock_view, null, (node:Node)=>{
  39. node.getComponent(unLock_view).initView((v:unLock_view)=>{
  40. v.closeSelf()
  41. this.reloadCountdown()
  42. })
  43. })
  44. })
  45. }
  46. public init() {
  47. this.lab_week_score.getComponent(Label).string = tools.mine_rank_data.score + ''
  48. this.reloadHonorData()
  49. this.reloadCountdown()
  50. this.reloadCountryRankData()
  51. }
  52. private reloadHonorData() {
  53. this.img_honor.getComponent(home_honor).initView()
  54. }
  55. private reloadCountdown() {
  56. this.countdown_node.getComponent(home_bottom_countdown).startTime()
  57. }
  58. private reloadCountryRankData(){
  59. GameManager.requestRankList(0, (d_content)=>{
  60. if(d_content.length>0) {
  61. let rank_data = d_content[0]
  62. this.rank1_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  63. } else if(d_content.length>1) {
  64. let rank_data = d_content[1]
  65. this.rank2_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  66. } else if(d_content.length>2) {
  67. let rank_data = d_content[2]
  68. this.rank3_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  69. }
  70. })
  71. }
  72. private onClickRankGotoUserInfo(item:home_bottom_rank_item) {
  73. let data = item.getData()
  74. if(data == null) {
  75. return
  76. }
  77. uiManager.Instance().showUi(config.UI.ui_user_info_view, null, (node:Node)=>{
  78. node.getComponent(user_info_view).initView(data)
  79. })
  80. }
  81. }