home_bottom.ts 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.reloadWeekScore()
  48. this.reloadHonorData()
  49. this.reloadCountdown()
  50. this.reloadCountryRankData()
  51. }
  52. public reloadWeekScore() {
  53. this.lab_week_score.getComponent(Label).string = tools.mine_rank_data.score + ''
  54. }
  55. private reloadHonorData() {
  56. this.img_honor.getComponent(home_honor).initView()
  57. }
  58. private reloadCountdown() {
  59. this.countdown_node.getComponent(home_bottom_countdown).startTime()
  60. }
  61. public reloadCountryRankData(){
  62. GameManager.requestRankList(0, (d_content)=>{
  63. if(d_content.length>0) {
  64. let rank_data = d_content[0]
  65. this.rank1_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  66. } else if(d_content.length>1) {
  67. let rank_data = d_content[1]
  68. this.rank2_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  69. } else if(d_content.length>2) {
  70. let rank_data = d_content[2]
  71. this.rank3_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  72. }
  73. })
  74. }
  75. private onClickRankGotoUserInfo(item:home_bottom_rank_item) {
  76. let data = item.getData()
  77. if(data == null) {
  78. return
  79. }
  80. uiManager.Instance().showUi(config.UI.ui_user_info_view, null, (node:Node)=>{
  81. node.getComponent(user_info_view).initView(data)
  82. })
  83. }
  84. }