import { _decorator, Component, Label, Node, Sprite } from 'cc'; import { userDataManager } from '../../manager/userDataManager'; import { home_guangbo } from './home_guangbo'; import { tools } from '../../tools'; import { GameManager } from '../../GameManager'; import { base_ui } from '../../fw/base_ui'; const { ccclass, property } = _decorator; @ccclass('home_top') export class home_top extends base_ui { @property(Node) lab_region:Node = null @property(Node) img_avatar:Node = null @property(Node) img_avatar_border:Node = null @property(Node) lab_nickname:Node = null @property(Node) lab_car_pai:Node = null @property(Node) guangbo:Node = null @property(Node) btn_edit:Node = null protected start(): void { this.onButtonListen(this.btn_edit, ()=>{ GameManager.showEditUserInfoView() }) } public init(){ this.reloadUserInfo() this.reloadUserAvatarBorder() let user_data = userDataManager.user_data this.lab_region.getComponent(Label).string = user_data.province_name + ' - ' + user_data.city_name this.lab_car_pai.getComponent(Label).string = user_data.license_code this.requestGuangboData() } public requestGuangboData() { GameManager.requestGuangbo((d_content)=>{ this.reloadGuangboData(d_content) }) } public reloadGuangboData(d_content) { this.guangbo.getComponent(home_guangbo).init(d_content) } public reloadUserInfo() { let user_data = userDataManager.user_data tools.loadRemoteImg(user_data.avatarUrl, (r)=>{ this.img_avatar.getComponent(Sprite).spriteFrame = r.sf }) this.lab_nickname.getComponent(Label).string = user_data.nickName } public reloadUserAvatarBorder() { let user_data = userDataManager.user_data if(user_data.photo_frame_img && user_data.photo_frame_img.length>0) { tools.loadRemoteImg(user_data.photo_frame_img, (r)=>{ this.img_avatar_border.getComponent(Sprite).spriteFrame = r.sf }) } } }