home_top.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. uiManager.Instance().showUi(config.UI.bag)
  25. })
  26. uiManager.Instance().onButtonListen(this.btn_setting,()=>{
  27. uiManager.Instance().showUi(config.UI.ui_setting)
  28. })
  29. uiManager.Instance().onButtonListen(this.btn_car_lib, ()=>{
  30. this.node.parent.active = false
  31. uiManager.Instance().showUi(config.UI.car_lib, null, ()=>{
  32. this.node.parent.active = true
  33. })
  34. })
  35. uiManager.Instance().onButtonListen(this.btn_feedback, ()=>{
  36. uiManager.Instance().showUi(config.UI.ui_feedback)
  37. })
  38. }
  39. public init(){
  40. let user_data = userDataManager.user_data
  41. this.lab_region.getComponent(Label).string = user_data.province_name + ' - ' + user_data.city_name
  42. tools.loadRemoteImg(user_data.avatarUrl, (r)=>{
  43. this.img_avatar.getComponent(Sprite).spriteFrame = r.sf
  44. })
  45. this.lab_nickname.getComponent(Label).string = user_data.nickName
  46. this.lab_car_pai.getComponent(Label).string = user_data.license_code
  47. this.requestGuangboData()
  48. }
  49. public requestGuangboData() {
  50. GameManager.requestGuangbo((d_content)=>{
  51. this.reloadGuangboData(d_content)
  52. })
  53. }
  54. public reloadGuangboData(d_content) {
  55. this.guangbo.getComponent(home_guangbo).init(d_content)
  56. }
  57. }