|
@@ -3,6 +3,7 @@ import { base_ui } from '../../fw/base_ui';
|
|
|
import { tools } from '../../tools';
|
|
|
import { car_lib_list_item } from './car_lib_list_item';
|
|
|
import { userDataManager } from '../../manager/userDataManager';
|
|
|
+import { car_item_data } from '../../data';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('car_lib_bottom')
|
|
@@ -11,14 +12,18 @@ export class car_lib_bottom extends base_ui {
|
|
|
@property(Node) btn_num_right:Node = null
|
|
|
@property(Node) lab_num:Node = null
|
|
|
@property(Node) btn_score_sort:Node = null
|
|
|
+ @property(SpriteFrame) sf_score_up:SpriteFrame = null
|
|
|
+ @property(SpriteFrame) sf_score_down:SpriteFrame = null
|
|
|
@property(Node) btn_jiesuo:Node = null
|
|
|
- @property(SpriteFrame) sf_yijiesuo:SpriteFrame = null
|
|
|
- @property(SpriteFrame) sf_weijiesuo:SpriteFrame = null
|
|
|
+ @property(SpriteFrame) sf_jiesuo_select:SpriteFrame = null
|
|
|
+ @property(SpriteFrame) sf_jiesuo_unselect:SpriteFrame = null
|
|
|
@property(Node) list:Node = null
|
|
|
@property(Node) list_content:Node = null
|
|
|
@property(Prefab) list_item:Prefab = null
|
|
|
|
|
|
- private is_jiesuo:boolean = false
|
|
|
+ private data_list:car_item_data[] = []
|
|
|
+ private is_sort_up_status:boolean = true
|
|
|
+ private is_jiesuo_status:boolean = false
|
|
|
private num_current_count:number = 1
|
|
|
private num_total_count:number = 1
|
|
|
private current_select_list_item:car_lib_list_item = null
|
|
@@ -41,11 +46,12 @@ export class car_lib_bottom extends base_ui {
|
|
|
this.updateNumStatus()
|
|
|
})
|
|
|
this.onButtonListen(this.btn_score_sort, ()=>{
|
|
|
-
|
|
|
+ this.is_sort_up_status = !this.is_sort_up_status
|
|
|
+ this.updateSortStatus(true)
|
|
|
})
|
|
|
this.onButtonListen(this.btn_jiesuo, ()=>{
|
|
|
- this.is_jiesuo = !this.is_jiesuo
|
|
|
- this.updateJiesuoStatus()
|
|
|
+ this.is_jiesuo_status = !this.is_jiesuo_status
|
|
|
+ this.updateJiesuoStatus(true)
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -54,6 +60,8 @@ export class car_lib_bottom extends base_ui {
|
|
|
this.num_current_count = 1
|
|
|
this.num_total_count = 1
|
|
|
|
|
|
+ this.data_list = JSON.parse(JSON.stringify(tools.all_car_list))
|
|
|
+ this.updateSortStatus()
|
|
|
this.updateJiesuoStatus()
|
|
|
this.updateNumStatus()
|
|
|
this.initListContentData()
|
|
@@ -68,11 +76,26 @@ export class car_lib_bottom extends base_ui {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- updateJiesuoStatus() {
|
|
|
- if(this.is_jiesuo) {
|
|
|
- this.btn_jiesuo.getComponent(Sprite).spriteFrame = this.sf_yijiesuo
|
|
|
+ updateSortStatus(is_load_data:boolean=false) {
|
|
|
+ if(this.is_sort_up_status) {
|
|
|
+ this.btn_score_sort.getComponent(Sprite).spriteFrame = this.sf_score_down
|
|
|
} else {
|
|
|
- this.btn_jiesuo.getComponent(Sprite).spriteFrame = this.sf_weijiesuo
|
|
|
+ this.btn_score_sort.getComponent(Sprite).spriteFrame = this.sf_score_up
|
|
|
+ }
|
|
|
+ if(is_load_data) {
|
|
|
+ this.data_list = this.data_list.reverse()
|
|
|
+ this.initListContentData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ updateJiesuoStatus(is_load_data:boolean=false) {
|
|
|
+ if(this.is_jiesuo_status) {
|
|
|
+ this.btn_jiesuo.getComponent(Sprite).spriteFrame = this.sf_jiesuo_select
|
|
|
+ } else {
|
|
|
+ this.btn_jiesuo.getComponent(Sprite).spriteFrame = this.sf_jiesuo_unselect
|
|
|
+ }
|
|
|
+ if(is_load_data) {
|
|
|
+ this.initListContentData()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -82,17 +105,33 @@ export class car_lib_bottom extends base_ui {
|
|
|
|
|
|
initListContentData() {
|
|
|
this.list_content.removeAllChildren()
|
|
|
- for (let index = 0; index < tools.all_car_list.length; index++) {
|
|
|
- const element = tools.all_car_list[index];
|
|
|
- let item = instantiate(this.list_item)
|
|
|
- item.parent = this.list_content
|
|
|
- let item_component = item.getComponent(car_lib_list_item)
|
|
|
- item_component.initView(element, index, this.onClickListItem.bind(this))
|
|
|
- if(userDataManager.user_car_list.default_car_id == element.id) {
|
|
|
- this.current_select_list_item = item_component
|
|
|
- item_component.setSelectedStatus()
|
|
|
+ this.current_select_list_item = null
|
|
|
+ for (let index = 0; index < this.data_list.length; index++) {
|
|
|
+ const element = this.data_list[index];
|
|
|
+ let is_jiesuo = userDataManager.user_car_list.car_list.some(obj => obj === element.id)
|
|
|
+ let item = null
|
|
|
+ if(this.is_jiesuo_status) {
|
|
|
+ if(is_jiesuo) {
|
|
|
+ item = instantiate(this.list_item)
|
|
|
+ }
|
|
|
} else {
|
|
|
- item_component.setUnselectedStatus()
|
|
|
+ item = instantiate(this.list_item)
|
|
|
+ }
|
|
|
+ if(item!=null) {
|
|
|
+ item.parent = this.list_content
|
|
|
+ let item_component = item.getComponent(car_lib_list_item)
|
|
|
+ item_component.initView(element, index, this.onClickListItem.bind(this))
|
|
|
+ if(is_jiesuo) {
|
|
|
+ item_component.setJiesuoSelectedStatus()
|
|
|
+ } else {
|
|
|
+ item_component.setJiesuoUnselectedStatus()
|
|
|
+ }
|
|
|
+ if(userDataManager.user_car_list.default_car_id == element.id) {
|
|
|
+ this.current_select_list_item = item_component
|
|
|
+ item_component.setSelectedStatus()
|
|
|
+ } else {
|
|
|
+ item_component.setUnselectedStatus()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -102,6 +141,11 @@ export class car_lib_bottom extends base_ui {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if(item.getIsJiesuo()==false) {
|
|
|
+ console.log('解锁 解锁 解锁')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
this.current_select_list_item.setUnselectedStatus()
|
|
|
item.setSelectedStatus()
|
|
|
this.current_select_list_item = item
|