home_top.ts 2.3 KB

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