home_bottom.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. }
  36. public reloadCountryRankData(){
  37. GameManager.requestRankList(0, (d_content)=>{
  38. if(d_content.length>0) {
  39. let rank_data = d_content[0]
  40. this.rank1_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  41. } else if(d_content.length>1) {
  42. let rank_data = d_content[1]
  43. this.rank2_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  44. } else if(d_content.length>2) {
  45. let rank_data = d_content[2]
  46. this.rank3_node.getComponent(home_bottom_rank_item).initView(rank_data, this.onClickRankGotoUserInfo.bind(this))
  47. }
  48. })
  49. }
  50. private onClickRankGotoUserInfo(item:home_bottom_rank_item) {
  51. let data = item.getData()
  52. if(data == null) {
  53. return
  54. }
  55. uiManager.Instance().showUi(config.UI.ui_user_info_view, null, (node:Node)=>{
  56. node.getComponent(user_info_view).initView(data)
  57. })
  58. }
  59. }