home_top.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 { tools } from '../../tools';
  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) lab_car_pai:Node = null
  17. protected start(): void {
  18. uiManager.Instance().onButtonListen(this.btn_region,()=>{
  19. uiManager.Instance().showUi(config.UI.ui_select_area, null, (node:Node)=>{
  20. node.getComponent(select_area).initView(true, this.onSelectArea.bind(this))
  21. })
  22. })
  23. uiManager.Instance().onButtonListen(this.btn_gong_gao,()=>{
  24. uiManager.Instance().showUi(config.UI.ui_announcement)
  25. })
  26. uiManager.Instance().onButtonListen(this.btn_setting,()=>{
  27. uiManager.Instance().showUi(config.UI.ui_setting)
  28. })
  29. }
  30. public init(){
  31. let user_data = userDataManager.user_data
  32. this.lab_region.getComponent(Label).string = user_data.province_name + ' - ' + user_data.city_name
  33. this.lab_nickname.getComponent(Label).string = user_data.nickName
  34. this.lab_car_pai.getComponent(Label).string = user_data.license_code
  35. }
  36. private onSelectArea(obj:select_area, data:area_item_data) {
  37. tools.requestUserSetRegion(data.id, 2, (d)=>{
  38. obj.closeSelf()
  39. })
  40. }
  41. }