home_top.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { _decorator, Component, Label, Node, Sprite } from 'cc';
  2. import { uiManager } from '../../manager/uiManager';
  3. import { config } from '../../config';
  4. import { userDataManager } from '../../manager/userDataManager';
  5. import { home_guangbo } from './home_guangbo';
  6. import { tools } from '../../tools';
  7. import { GameManager } from '../../GameManager';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('home_top')
  10. export class home_top extends Component {
  11. @property(Node) lab_region:Node = null
  12. @property(Node) btn_gong_gao:Node = null
  13. @property(Node) btn_setting:Node = null
  14. @property(Node) img_avatar:Node = null
  15. @property(Node) lab_nickname:Node = null
  16. @property(Node) btn_car_lib:Node = null
  17. @property(Node) lab_car_pai:Node = null
  18. @property(Node) guangbo:Node = null
  19. protected start(): void {
  20. uiManager.Instance().onButtonListen(this.btn_gong_gao,()=>{
  21. uiManager.Instance().showUi(config.UI.ui_announcement)
  22. })
  23. uiManager.Instance().onButtonListen(this.btn_setting,()=>{
  24. uiManager.Instance().showUi(config.UI.ui_setting)
  25. })
  26. uiManager.Instance().onButtonListen(this.btn_car_lib, ()=>{
  27. this.node.parent.active = false
  28. uiManager.Instance().showUi(config.UI.car_lib, null, ()=>{
  29. this.node.parent.active = true
  30. })
  31. })
  32. }
  33. public init(){
  34. let user_data = userDataManager.user_data
  35. this.lab_region.getComponent(Label).string = user_data.province_name + ' - ' + user_data.city_name
  36. tools.loadRemoteImg(user_data.avatarUrl, (r)=>{
  37. this.img_avatar.getComponent(Sprite).spriteFrame = r.sf
  38. })
  39. this.lab_nickname.getComponent(Label).string = user_data.nickName
  40. this.lab_car_pai.getComponent(Label).string = user_data.license_code
  41. this.requestGuangboData()
  42. }
  43. public requestGuangboData() {
  44. GameManager.requestGuangbo((d_content)=>{
  45. this.guangbo.getComponent(home_guangbo).init(d_content)
  46. })
  47. }
  48. }