home_top.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. const { ccclass, property } = _decorator;
  8. @ccclass('home_top')
  9. export class home_top extends Component {
  10. @property(Node) lab_region:Node = null
  11. @property(Node) btn_gong_gao:Node = null
  12. @property(Node) btn_setting: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) guangbo:Node = null
  18. protected start(): void {
  19. uiManager.Instance().onButtonListen(this.btn_gong_gao,()=>{
  20. uiManager.Instance().showUi(config.UI.ui_announcement)
  21. })
  22. uiManager.Instance().onButtonListen(this.btn_setting,()=>{
  23. uiManager.Instance().showUi(config.UI.ui_setting)
  24. })
  25. uiManager.Instance().onButtonListen(this.btn_car_lib, ()=>{
  26. this.node.parent.active = false
  27. uiManager.Instance().showUi(config.UI.car_lib, null, ()=>{
  28. this.node.parent.active = true
  29. })
  30. })
  31. }
  32. public init(){
  33. let user_data = userDataManager.user_data
  34. this.lab_region.getComponent(Label).string = user_data.province_name + ' - ' + user_data.city_name
  35. tools.loadRemoteImg(user_data.avatarUrl, (r)=>{
  36. this.img_avatar.getComponent(Sprite).spriteFrame = r.sf
  37. })
  38. this.lab_nickname.getComponent(Label).string = user_data.nickName
  39. this.lab_car_pai.getComponent(Label).string = user_data.license_code
  40. this.guangbo.getComponent(home_guangbo).init()
  41. }
  42. }