home_top.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { uiManager } from '../../manager/uiManager';
  3. import { config } from '../../config';
  4. import { userDataManager } from '../../manager/userDataManager';
  5. import { select_area } from '../select_area/select_area';
  6. import { area_item_data } from '../../data';
  7. import { GameManager } from '../../GameManager';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('home_top')
  10. export class home_top extends Component {
  11. @property(Node) btn_region:Node = null
  12. @property(Node) lab_region:Node = null
  13. @property(Node) btn_gong_gao:Node = null
  14. @property(Node) btn_setting: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. protected start(): void {
  19. uiManager.Instance().onButtonListen(this.btn_region,()=>{
  20. uiManager.Instance().showUi(config.UI.ui_select_area, null, (node:Node)=>{
  21. node.getComponent(select_area).initView(true, this.onSelectArea.bind(this))
  22. })
  23. })
  24. uiManager.Instance().onButtonListen(this.btn_gong_gao,()=>{
  25. uiManager.Instance().showUi(config.UI.ui_announcement)
  26. })
  27. uiManager.Instance().onButtonListen(this.btn_setting,()=>{
  28. uiManager.Instance().showUi(config.UI.ui_setting)
  29. })
  30. uiManager.Instance().onButtonListen(this.btn_car_lib, ()=>{
  31. uiManager.Instance().showUi(config.UI.car_lib)
  32. })
  33. }
  34. public init(){
  35. let user_data = userDataManager.user_data
  36. this.lab_region.getComponent(Label).string = user_data.province_name + ' - ' + user_data.city_name
  37. this.lab_nickname.getComponent(Label).string = user_data.nickName
  38. this.lab_car_pai.getComponent(Label).string = user_data.license_code
  39. }
  40. private onSelectArea(obj:select_area, data:area_item_data) {
  41. GameManager.requestUserSetRegion(data.id, 2, (d)=>{
  42. obj.closeSelf()
  43. })
  44. }
  45. }