12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
- import { base_ui } from '../../fw/base_ui';
- import { userDataManager } from '../../manager/userDataManager';
- const { ccclass, property } = _decorator;
- @ccclass('rank_classify')
- export class rank_classify extends base_ui {
- @property(Node) btn_country:Node = null;
- @property(Node) btn_province:Node = null;
- @property(Node) btn_city:Node = null;
- @property(Node) lab_country:Node = null;
- @property(Node) lab_province:Node = null;
- @property(Node) lab_city:Node = null;
- @property(SpriteFrame) sf_selected:SpriteFrame = null;
- @property(SpriteFrame) sf_un_selected:SpriteFrame = null;
- private m_click_cb = null
- start() {
- this.onButtonListen(this.btn_country, ()=>{
- this.onClassifyItem(1)
- })
- this.onButtonListen(this.btn_province, ()=>{
- this.onClassifyItem(2)
- })
- this.onButtonListen(this.btn_city, ()=>{
- this.onClassifyItem(3)
- })
- }
- init(type:number, click_cb) {
- this.setType(type)
- this.m_click_cb = click_cb
- }
- private setType(type:number) {
- this.btn_country.getComponent(Sprite).spriteFrame = this.sf_un_selected
- this.btn_province.getComponent(Sprite).spriteFrame = this.sf_un_selected
- this.lab_province.getComponent(Label).string = '省排名'
- this.btn_city.getComponent(Sprite).spriteFrame = this.sf_un_selected
- this.lab_city.getComponent(Label).string = '市排名'
- switch (type) {
- case 1:
- this.btn_country.getComponent(Sprite).spriteFrame = this.sf_selected
- break;
- case 2:
- this.btn_province.getComponent(Sprite).spriteFrame = this.sf_selected
- this.lab_province.getComponent(Label).string = userDataManager.user_data.province_name
- break;
- case 3:
- this.btn_city.getComponent(Sprite).spriteFrame = this.sf_selected
- this.lab_city.getComponent(Label).string = userDataManager.user_data.city_name
- break;
- default:
- break;
- }
- }
- private onClassifyItem(type:number) {
- this.setType(type)
- if(this.m_click_cb) {
- this.m_click_cb(type)
- }
- }
- }
|