|
@@ -2,6 +2,11 @@ import { _decorator, Component, Label, Node, Sprite } from 'cc';
|
|
|
import { userDataManager } from '../../manager/userDataManager';
|
|
|
import { tools } from '../../tools';
|
|
|
import { GameManager } from '../../GameManager';
|
|
|
+import { select_area } from '../select_area/select_area';
|
|
|
+import { area_item_data, userData } from '../../data';
|
|
|
+import { uiManager } from '../../manager/uiManager';
|
|
|
+import { config } from '../../config';
|
|
|
+import { ClientEvent } from '../../lib/clientEvent';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('car_lib_top')
|
|
@@ -9,14 +14,28 @@ export class car_lib_top extends Component {
|
|
|
@property(Node) img_avatar:Node = null
|
|
|
@property(Node) lab_nickname:Node = null
|
|
|
@property(Node) lab_car_pai:Node = null
|
|
|
+ @property(Node) btn_region:Node = null
|
|
|
+ @property(Node) lab_region:Node = null
|
|
|
@property(Node) img_car:Node = null
|
|
|
|
|
|
+ protected start(): void {
|
|
|
+ uiManager.Instance().onButtonListen(this.btn_region,()=>{
|
|
|
+ if(userDataManager.user_data.update_region_status==1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uiManager.Instance().showUi(config.UI.ui_select_area, null, (node:Node)=>{
|
|
|
+ node.getComponent(select_area).initView(true, this.onSelectArea.bind(this))
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
init() {
|
|
|
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
|
|
|
+ this.reloadUserRegion()
|
|
|
this.lab_car_pai.getComponent(Label).string = user_data.license_code
|
|
|
this.reloadUserCar()
|
|
|
}
|
|
@@ -24,5 +43,26 @@ export class car_lib_top extends Component {
|
|
|
reloadUserCar() {
|
|
|
this.img_car.getComponent(Sprite).spriteFrame = GameManager.getUserDefaultCarSf()
|
|
|
}
|
|
|
+
|
|
|
+ reloadUserRegion(){
|
|
|
+ let user_data = userDataManager.user_data
|
|
|
+ this.lab_region.getComponent(Label).string = user_data.province_name + ' - ' + user_data.city_name
|
|
|
+ }
|
|
|
+
|
|
|
+ private onSelectArea(obj:select_area, data:area_item_data) {
|
|
|
+ GameManager.requestUserSetRegion(data.id, 2, (d)=>{
|
|
|
+ //更改数据
|
|
|
+ let user_data = userDataManager.user_data
|
|
|
+ user_data.province_name = obj.province_selected_data.name
|
|
|
+ user_data.city_name = obj.city_selected_data.name
|
|
|
+ user_data.update_region_status = 1
|
|
|
+ this.reloadUserRegion()
|
|
|
+ //发送通知
|
|
|
+ ClientEvent.dispatchEvent(config.UI_EVENT.UPDATE_USER_REGION)
|
|
|
+ //关闭
|
|
|
+ obj.closeSelf()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|