home_bottom.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { _decorator, Component, Label, Node, Sprite } 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. const { ccclass, property } = _decorator;
  9. @ccclass('home_bottom')
  10. export class home_bottom extends Component {
  11. @property(Node) btn_up_rank:Node = null
  12. @property(Node) btn_wenhao:Node = null
  13. @property(Node) btn_gengduo:Node = null
  14. @property(Node) rank1_node:Node = null
  15. @property(Node) rank2_node:Node = null
  16. @property(Node) rank3_node:Node = null
  17. @property(Node) lab_week_score:Node = null
  18. @property(Node) btn_wuxiancishu:Node = null
  19. start() {
  20. uiManager.Instance().onButtonListen(this.btn_up_rank, ()=>{
  21. uiManager.Instance().showUi(config.UI.rank)
  22. })
  23. uiManager.Instance().onButtonListen(this.btn_wenhao, ()=>{
  24. uiManager.Instance().showUi(config.UI.ui_gameplay_view)
  25. })
  26. uiManager.Instance().onButtonListen(this.btn_gengduo, ()=>{
  27. uiManager.Instance().showUi(config.UI.rank)
  28. })
  29. uiManager.Instance().onButtonListen(this.btn_wuxiancishu, ()=>{
  30. uiManager.Instance().showUi(config.UI.ui_unLock_view)
  31. })
  32. }
  33. public init() {
  34. this.lab_week_score.getComponent(Label).string = tools.mine_rank_data.score + ''
  35. this.reloadCountryRankData()
  36. }
  37. public reloadCountryRankData(){
  38. GameManager.requestRankList(0, (d_content)=>{
  39. if(d_content.length>0) {
  40. let rank_data = d_content[0]
  41. this.rank1_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  42. } else if(d_content.length>1) {
  43. let rank_data = d_content[1]
  44. this.rank2_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  45. } else if(d_content.length>2) {
  46. let rank_data = d_content[2]
  47. this.rank3_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  48. }
  49. })
  50. }
  51. private onClickRankGotoUserInfo(item:home_bottom_rank_item) {
  52. let data = item.getData()
  53. if(data == null) {
  54. return
  55. }
  56. uiManager.Instance().showUi(config.UI.ui_user_info_view, null, (node:Node)=>{
  57. node.getComponent(user_info_view).initView(data)
  58. })
  59. }
  60. }