future 1 year ago
parent
commit
109272a7aa

+ 2 - 2
assets/resources/ui/announcement.prefab

@@ -281,7 +281,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 0,
+      "y": 100,
       "z": 0
     },
     "_lrot": {
@@ -825,7 +825,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": -680,
+      "y": -580,
       "z": 0
     },
     "_lrot": {

+ 2 - 2
assets/resources/ui/gameplay_view.prefab

@@ -278,7 +278,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 0,
+      "y": 100,
       "z": 0
     },
     "_lrot": {
@@ -686,7 +686,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": -680,
+      "y": -580,
       "z": 0
     },
     "_lrot": {

+ 1 - 4
assets/resources/ui/select_area.prefab

@@ -1452,10 +1452,7 @@
       "b": 255,
       "a": 255
     },
-    "_spriteFrame": {
-      "__uuid__": "b730527c-3233-41c2-aaf7-7cdab58f9749@f9941",
-      "__expectedType__": "cc.SpriteFrame"
-    },
+    "_spriteFrame": null,
     "_type": 1,
     "_fillType": 0,
     "_sizeMode": 0,

+ 183 - 9
assets/resources/ui/select_area_item.prefab

@@ -17,21 +17,25 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": null,
-    "_children": [],
+    "_children": [
+      {
+        "__id__": 2
+      }
+    ],
     "_active": true,
     "_components": [
       {
-        "__id__": 2
+        "__id__": 8
       },
       {
-        "__id__": 4
+        "__id__": 10
       },
       {
-        "__id__": 6
+        "__id__": 12
       }
     ],
     "_prefab": {
-      "__id__": 8
+      "__id__": 14
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -62,6 +66,165 @@
     },
     "_id": ""
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "lab_name",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 3
+      },
+      {
+        "__id__": 5
+      }
+    ],
+    "_prefab": {
+      "__id__": 7
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 4,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 4
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 170,
+      "height": 95
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "51ovVaUnFDbLG2v30YS7HZ"
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 6
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_string": "北京",
+    "_horizontalAlign": 1,
+    "_verticalAlign": 1,
+    "_actualFontSize": 41,
+    "_fontSize": 40,
+    "_fontFamily": "Arial",
+    "_lineHeight": 40,
+    "_overflow": 2,
+    "_enableWrapText": true,
+    "_font": null,
+    "_isSystemFontUsed": true,
+    "_spacingX": 0,
+    "_isItalic": false,
+    "_isBold": false,
+    "_isUnderline": false,
+    "_underlineHeight": 2,
+    "_cacheMode": 0,
+    "_enableOutline": false,
+    "_outlineColor": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_outlineWidth": 2,
+    "_enableShadow": false,
+    "_shadowColor": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_shadowOffset": {
+      "__type__": "cc.Vec2",
+      "x": 2,
+      "y": 2
+    },
+    "_shadowBlur": 2,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "dbCkrxYVhLs7alNcSRb7sA"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "ecWjgHT5ZI6KGxjvYO9yRy",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
   {
     "__type__": "cc.UITransform",
     "_name": "",
@@ -72,12 +235,12 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 3
+      "__id__": 9
     },
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 190,
-      "height": 90
+      "height": 110
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -100,7 +263,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 5
+      "__id__": 11
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -145,7 +308,18 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 7
+      "__id__": 13
+    },
+    "sf_unselected": {
+      "__uuid__": "3700a2fc-dab3-4712-81ac-0b4e94bce9c9@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "sf_selected": {
+      "__uuid__": "0c074e7e-6cd1-426a-9dca-daa2639f3201@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "lab_name": {
+      "__id__": 2
     },
     "_id": ""
   },

+ 2 - 2
assets/resources/ui/setting.prefab

@@ -290,7 +290,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 0,
+      "y": 100,
       "z": 0
     },
     "_lrot": {
@@ -2301,7 +2301,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": -680,
+      "y": -580,
       "z": 0
     },
     "_lrot": {

+ 7 - 0
assets/script/data.ts

@@ -106,6 +106,13 @@ export class box_random_data{
     public type:number = 0;
 }
 
+export class area_item_data{
+    public id:number = -1;
+    public name:string = '';
+    public pid:number = -1;
+    public list:area_item_data[] = []
+}
+
 export enum DirType{
     LEFT,
     RIGHT,

+ 87 - 6
assets/script/ui/select_area/select_area.ts

@@ -1,6 +1,9 @@
 import { _decorator, Component, instantiate, Node, Prefab, Sprite, SpriteFrame } from 'cc';
 import { base_ui } from '../../fw/base_ui';
 import { select_area_item } from './select_area_item';
+import { http } from '../../http';
+import { config } from '../../config';
+import { area_item_data } from '../../data';
 const { ccclass, property } = _decorator;
 
 @ccclass('select_area')
@@ -16,6 +19,11 @@ export class select_area extends base_ui {
     @property(Node) city_btn_true:Node = null
     @property(Node) list_content:Node = null
     @property(Prefab) list_item:Prefab = null
+    private province_list = []
+    private province_selected_index:number = 0
+    private province_selected_data:area_item_data = null
+    private city_selected_index:number = 0
+    private city_selected_data:area_item_data = null
 
     protected start(): void {
         this.onButtonListen(this.btn_close, ()=>{
@@ -31,38 +39,111 @@ export class select_area extends base_ui {
             this.onClickCityTrue()
         })
 
-        this.reloadProvinceListData()
+        this.requestProvinceListData()
     }
 
     private onClickProviceNext() {
         this.img_title.getComponent(Sprite).spriteFrame = this.sf_city
         this.province_btn_node.active = false
         this.city_btn_node.active = true
+
+        let data_list = this.province_selected_data.list
+        this.reloadCityListData(data_list)
     }
 
     private onClickCityUp() {
         this.img_title.getComponent(Sprite).spriteFrame = this.sf_province
         this.province_btn_node.active = true
         this.city_btn_node.active = false
+
+        this.city_selected_index = 0
+        this.city_selected_data = null
+        this.reloadProvinceListData(this.province_list)
     }
 
     private onClickCityTrue() {
+        console.log('province:',this.province_selected_data.name,'  ','city:',this.city_selected_data.name)
         this.close()
     }
 
-    private reloadProvinceListData() {
+    private requestProvinceListData() {
+        http.get(config.STATIC_API.regions, (err,d)=>{
+            if(!err){
+                let data = JSON.parse(d)
+                if(data.code===config.status.SUCCESS){
+                    // console.log('data=',data.content)
+                    this.province_list = data.content
+                    this.reloadProvinceListData(data.content)
+                }
+            } else{
+                console.log("initData err",err)
+            }
+        })
+    }
+
+    private reloadProvinceListData(data_list) {
         this.list_content.removeAllChildren()
-        for (let index = 0; index < 50; index++) {
+        for (let index = 0; index < data_list.length; index++) {
+            const element = data_list[index]
             let item = instantiate(this.list_item)
             item.parent = this.list_content;
-            item.getComponent(select_area_item).initView(()=>{
+            
+            let area_item = item.getComponent(select_area_item)
+            if(this.province_selected_index == index) {
+                area_item.setSelectStatus()
+                this.province_selected_data = element
+            } else {
+                area_item.setUnselectStatus()
+            }
+            area_item.initView(element,index, this.onClickProvinceItem.bind(this))
+        }
+    }
+
+    private onClickProvinceItem(item:select_area_item) {
+        let cur_index = item.getIndex()
+        if(this.province_selected_index==cur_index) {
+            return
+        }
+        let previous_item = this.list_content.children[this.province_selected_index].getComponent(select_area_item)
+        previous_item.setUnselectStatus()
 
-            })
+        item.setSelectStatus()
+
+        this.province_selected_index = cur_index
+        this.province_selected_data = item.getData()
+    }
+
+    private reloadCityListData(data_list) {
+        this.list_content.removeAllChildren()
+        for (let index = 0; index < data_list.length; index++) {
+            const element = data_list[index]
+            let item = instantiate(this.list_item)
+            item.parent = this.list_content;
+            
+            let area_item = item.getComponent(select_area_item)
+            if(this.city_selected_index == index) {
+                area_item.setSelectStatus()
+                this.city_selected_data = element
+            } else {
+                area_item.setUnselectStatus()
+            }
+            area_item.initView(element,index, this.onClickCityItem.bind(this))
         }
     }
 
-    private reloadCityListData() {
+    private onClickCityItem(item:select_area_item) {
+        let cur_index = item.getIndex()
+        if(this.city_selected_index==cur_index) {
+            return
+        }
+
+        let previous_item = this.list_content.children[this.city_selected_index].getComponent(select_area_item)
+        previous_item.setUnselectStatus()
+
+        item.setSelectStatus()
 
+        this.city_selected_index = cur_index
+        this.city_selected_data = item.getData()
     }
 
 }

+ 37 - 5
assets/script/ui/select_area/select_area_item.ts

@@ -1,21 +1,53 @@
-import { _decorator, Component, Node } from 'cc';
+import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
 import { base_ui } from '../../fw/base_ui';
+import { area_item_data } from '../../data';
 const { ccclass, property } = _decorator;
 
 @ccclass('select_area_item')
 export class select_area_item extends base_ui  {
-    private m_callback = null;
+    @property(SpriteFrame) sf_unselected:SpriteFrame = null
+    @property(SpriteFrame) sf_selected:SpriteFrame = null
+    @property(Node) lab_name:Node = null
+    private m_data:area_item_data = null
+    private m_callback = null
+    private m_index:number = 0
+    private m_is_selected:boolean = false
     
     protected start(): void {
         this.onButtonListen(this.node, ()=>{
             if(this.m_callback!=null) {
-                this.m_callback()
+                this.m_callback(this)
             }
         })
     }
 
-    initView(call) {
-        this.m_callback = null
+    initView(data:area_item_data,index,call) {
+        this.m_data = data
+        this.m_callback = call
+        this.m_index = index
+        this.lab_name.getComponent(Label).string = data.name
+    }
+
+    public getData():area_item_data {
+        return this.m_data
+    }
+
+    public getIndex():number {
+        return this.m_index
+    }
+
+    public setSelectStatus() {
+        this.m_is_selected = true
+        this.node.getComponent(Sprite).spriteFrame = this.sf_selected
+    }
+
+    public setUnselectStatus() {
+        this.m_is_selected = false
+        this.node.getComponent(Sprite).spriteFrame = this.sf_unselected
+    }
+
+    public getIsSelected():boolean {
+        return this.m_is_selected
     }
 
 }