home_bottom.ts 2.7 KB

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