future 1 年之前
父節點
當前提交
beda7be7f8

File diff suppressed because it is too large
+ 695 - 56
assets/resources/ui/car_lib.prefab


File diff suppressed because it is too large
+ 136 - 273
assets/resources/ui/home.prefab


+ 1 - 0
assets/script/data.ts

@@ -57,6 +57,7 @@ export class userData{
     public token:string = ""
     public province_name:string = ""
     public city_name:string = ""
+    public update_region_status:number = 1 //1:本周已经设置 0:本周未设置
 }
 
 export class rankData{

+ 40 - 0
assets/script/ui/car_lib/car_lib_top.ts

@@ -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()
+        })
+    }
+    
 }
 

+ 6 - 1
assets/script/ui/home/home.ts

@@ -27,6 +27,7 @@ export class home extends Component {
         })
         ClientEvent.on(config.UI_EVENT.GET_NEW_CAR,this.onGetNewCar.bind(this),this)
         ClientEvent.on(config.UI_EVENT.UPDATE_USER_DEFAULT_CAR,this.onUpdateUserDefaultCar.bind(this),this)
+        ClientEvent.on(config.UI_EVENT.UPDATE_USER_REGION,this.onUpdateUserRegion.bind(this),this)
     }
 
     onGetNewCar(res:user_results){
@@ -41,9 +42,13 @@ export class home extends Component {
         this.home_car.getComponent(home_car).updateCar()
     }
 
+    onUpdateUserRegion() {
+        this.top.getComponent(home_top).reloadUserRegion()
+    }
+
     public init(){
-        this.home_car.getComponent(home_car).updateCar()
         this.top.getComponent(home_top).init()
+        this.home_car.getComponent(home_car).updateCar()
         this.bottom.getComponent(home_bottom).init()
     }
 }

+ 3 - 10
assets/script/ui/home/home_top.ts

@@ -9,7 +9,6 @@ const { ccclass, property } = _decorator;
 
 @ccclass('home_top')
 export class home_top extends Component {
-    @property(Node) btn_region:Node = null
     @property(Node) lab_region:Node = null
     @property(Node) btn_gong_gao:Node = null
     @property(Node) btn_setting:Node = null
@@ -17,11 +16,6 @@ export class home_top extends Component {
     @property(Node) btn_car_lib:Node = null
     @property(Node) lab_car_pai:Node = null
     protected start(): void {
-        uiManager.Instance().onButtonListen(this.btn_region,()=>{
-            uiManager.Instance().showUi(config.UI.ui_select_area, null, (node:Node)=>{
-                node.getComponent(select_area).initView(true, this.onSelectArea.bind(this))
-            })
-        })
         uiManager.Instance().onButtonListen(this.btn_gong_gao,()=>{
             uiManager.Instance().showUi(config.UI.ui_announcement)
         })
@@ -39,10 +33,9 @@ export class home_top extends Component {
         this.lab_car_pai.getComponent(Label).string = user_data.license_code
     }
 
-    private onSelectArea(obj:select_area, data:area_item_data) {
-        GameManager.requestUserSetRegion(data.id, 2, (d)=>{
-            obj.closeSelf()
-        })
+    public reloadUserRegion() {
+        let user_data = userDataManager.user_data
+        this.lab_region.getComponent(Label).string = user_data.province_name + ' - ' + user_data.city_name
     }
 }
 

+ 2 - 2
assets/script/ui/select_area/select_area.ts

@@ -22,9 +22,9 @@ export class select_area extends base_ui {
     @property(Node) note_info:Node = null
     private province_list = []
     private province_selected_index:number = 0
-    private province_selected_data:area_item_data = null
+    province_selected_data:area_item_data = null
     private city_selected_index:number = 0
-    private city_selected_data:area_item_data = null
+    city_selected_data:area_item_data = null
     private m_is_modified:boolean = true //是否为修改
     private m_city_cb = null
 

二進制
assets/texture/ui/car_lib/car_lib_edit.png


+ 134 - 0
assets/texture/ui/car_lib/car_lib_edit.png.meta

@@ -0,0 +1,134 @@
+{
+  "ver": "1.0.26",
+  "importer": "image",
+  "imported": true,
+  "uuid": "0631baa3-3e51-45fb-8192-ea4cb37a2306",
+  "files": [
+    ".json",
+    ".png"
+  ],
+  "subMetas": {
+    "6c48a": {
+      "importer": "texture",
+      "uuid": "0631baa3-3e51-45fb-8192-ea4cb37a2306@6c48a",
+      "displayName": "car_lib_edit",
+      "id": "6c48a",
+      "name": "texture",
+      "userData": {
+        "wrapModeS": "clamp-to-edge",
+        "wrapModeT": "clamp-to-edge",
+        "imageUuidOrDatabaseUri": "0631baa3-3e51-45fb-8192-ea4cb37a2306",
+        "isUuid": true,
+        "visible": false,
+        "minfilter": "linear",
+        "magfilter": "linear",
+        "mipfilter": "none",
+        "anisotropy": 0
+      },
+      "ver": "1.0.22",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    },
+    "f9941": {
+      "importer": "sprite-frame",
+      "uuid": "0631baa3-3e51-45fb-8192-ea4cb37a2306@f9941",
+      "displayName": "car_lib_edit",
+      "id": "f9941",
+      "name": "spriteFrame",
+      "userData": {
+        "trimType": "auto",
+        "trimThreshold": 1,
+        "rotated": false,
+        "offsetX": 0,
+        "offsetY": 0,
+        "trimX": 0,
+        "trimY": 0,
+        "width": 32,
+        "height": 32,
+        "rawWidth": 32,
+        "rawHeight": 32,
+        "borderTop": 0,
+        "borderBottom": 0,
+        "borderLeft": 0,
+        "borderRight": 0,
+        "packable": true,
+        "pixelsToUnit": 100,
+        "pivotX": 0.5,
+        "pivotY": 0.5,
+        "meshType": 0,
+        "vertices": {
+          "rawPosition": [
+            -16,
+            -16,
+            0,
+            16,
+            -16,
+            0,
+            -16,
+            16,
+            0,
+            16,
+            16,
+            0
+          ],
+          "indexes": [
+            0,
+            1,
+            2,
+            2,
+            1,
+            3
+          ],
+          "uv": [
+            0,
+            32,
+            32,
+            32,
+            0,
+            0,
+            32,
+            0
+          ],
+          "nuv": [
+            0,
+            0,
+            1,
+            0,
+            0,
+            1,
+            1,
+            1
+          ],
+          "minPos": [
+            -16,
+            -16,
+            0
+          ],
+          "maxPos": [
+            16,
+            16,
+            0
+          ]
+        },
+        "isUuid": true,
+        "imageUuidOrDatabaseUri": "0631baa3-3e51-45fb-8192-ea4cb37a2306@6c48a",
+        "atlasUuid": ""
+      },
+      "ver": "1.0.12",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    }
+  },
+  "userData": {
+    "type": "sprite-frame",
+    "hasAlpha": true,
+    "fixAlphaTransparencyArtifacts": false,
+    "redirect": "0631baa3-3e51-45fb-8192-ea4cb37a2306@f9941"
+  }
+}

二進制
assets/texture/ui/car_lib/car_lib_location.png


+ 134 - 0
assets/texture/ui/car_lib/car_lib_location.png.meta

@@ -0,0 +1,134 @@
+{
+  "ver": "1.0.26",
+  "importer": "image",
+  "imported": true,
+  "uuid": "29f0e6aa-9bff-425d-9be2-e35fe1bd4a8e",
+  "files": [
+    ".json",
+    ".png"
+  ],
+  "subMetas": {
+    "6c48a": {
+      "importer": "texture",
+      "uuid": "29f0e6aa-9bff-425d-9be2-e35fe1bd4a8e@6c48a",
+      "displayName": "car_lib_location",
+      "id": "6c48a",
+      "name": "texture",
+      "userData": {
+        "wrapModeS": "clamp-to-edge",
+        "wrapModeT": "clamp-to-edge",
+        "imageUuidOrDatabaseUri": "29f0e6aa-9bff-425d-9be2-e35fe1bd4a8e",
+        "isUuid": true,
+        "visible": false,
+        "minfilter": "linear",
+        "magfilter": "linear",
+        "mipfilter": "none",
+        "anisotropy": 0
+      },
+      "ver": "1.0.22",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    },
+    "f9941": {
+      "importer": "sprite-frame",
+      "uuid": "29f0e6aa-9bff-425d-9be2-e35fe1bd4a8e@f9941",
+      "displayName": "car_lib_location",
+      "id": "f9941",
+      "name": "spriteFrame",
+      "userData": {
+        "trimType": "auto",
+        "trimThreshold": 1,
+        "rotated": false,
+        "offsetX": 0,
+        "offsetY": 0,
+        "trimX": 0,
+        "trimY": 0,
+        "width": 44,
+        "height": 38,
+        "rawWidth": 44,
+        "rawHeight": 38,
+        "borderTop": 0,
+        "borderBottom": 0,
+        "borderLeft": 0,
+        "borderRight": 0,
+        "packable": true,
+        "pixelsToUnit": 100,
+        "pivotX": 0.5,
+        "pivotY": 0.5,
+        "meshType": 0,
+        "vertices": {
+          "rawPosition": [
+            -22,
+            -19,
+            0,
+            22,
+            -19,
+            0,
+            -22,
+            19,
+            0,
+            22,
+            19,
+            0
+          ],
+          "indexes": [
+            0,
+            1,
+            2,
+            2,
+            1,
+            3
+          ],
+          "uv": [
+            0,
+            38,
+            44,
+            38,
+            0,
+            0,
+            44,
+            0
+          ],
+          "nuv": [
+            0,
+            0,
+            1,
+            0,
+            0,
+            1,
+            1,
+            1
+          ],
+          "minPos": [
+            -22,
+            -19,
+            0
+          ],
+          "maxPos": [
+            22,
+            19,
+            0
+          ]
+        },
+        "isUuid": true,
+        "imageUuidOrDatabaseUri": "29f0e6aa-9bff-425d-9be2-e35fe1bd4a8e@6c48a",
+        "atlasUuid": ""
+      },
+      "ver": "1.0.12",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    }
+  },
+  "userData": {
+    "type": "sprite-frame",
+    "hasAlpha": true,
+    "fixAlphaTransparencyArtifacts": false,
+    "redirect": "29f0e6aa-9bff-425d-9be2-e35fe1bd4a8e@f9941"
+  }
+}

Some files were not shown because too many files changed in this diff