
import Panel from "../views/Panel";
import MItem from '../components/MItem';

import { GDispatcher } from '../../libs/tc/util/GDispatcher';

export default class CityItem extends MItem {

    public cityName:eui.Label;
    public cityBtnGroup:eui.Group;

    constructor() {
        super();
    }
   
    dataChanged(){
        let showString = '';
        
        if(this.data.address)
        {
            showString = this.data.address + '\n' + '联系电话：'+this.data.telephone;
            this.data.select = 'address';
        }else if(this.data.city){
            showString = this.data.city;
            this.data.select = 'city';
        }else{
            showString = this.data.province;
            this.data.select = 'province';
        }
        this.cityName.text = showString;
    }

    onSkinComplete(){
        //去完成按钮
        this.cityBtnGroup.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick,this)
    }
    
    onClick():void{
        GDispatcher.dispatchEvent("onClickSelect",this.data)
    }
    
}