cc.Class({
    extends: cc.Component,

    properties: {
        gMode: cc.Node,
        /**政务大厅预制体 */
        preGovernment: cc.Prefab,
        /**实名认证预制体 */
        preCertification: cc.Prefab,
        /**人民医院预制体 */
        preHospital: cc.Prefab,
        /**教育大厅预制体 */
        preEducation: cc.Prefab,
        /**旅游大厅预制体 */
        preTravel: cc.Prefab,
        /**数字商城预制体 */
        preDigitalMall: cc.Prefab,
        /**每日签到预制体 */
        preSign: cc.Prefab,

        /**待开放预制体 */
        preToBeOpened: cc.Prefab,
    },
    onLoad() {
        this.gModeScp = this.gMode.getComponent('GameMode');
    },
    onTopUI() {
        if (!this.gModeScp.IsLogIn(this)) return;
    },
    /**政务大厅按钮点击 */
    onBtnGovernmentClick() {
        if (!this.gModeScp.IsLogIn(this)) return;
        let tPrefab = cc.instantiate(this.preGovernment);
        tPrefab.parent = this.node;
        tPrefab.setPosition(0, 0);
    },
    /**政务大厅-实名认证按钮点击 */
    onBtnCertificationClick() {
        if (!this.gModeScp.IsLogIn(this)) return;
        let tPrefab = cc.instantiate(this.preCertification);
        tPrefab.parent = this.node;
        tPrefab.setPosition(0, 0);
    },
    /**人民医院按钮点击 */
    onBtnHospitalClick() {
        if (!this.gModeScp.IsLogIn(this)) return;
        let tPrefab = cc.instantiate(this.preHospital);
        tPrefab.parent = this.node;
        tPrefab.setPosition(0, 0);
    },
    /**教育大厅按钮点击 */
    onBtnEducationClick() {
        if (!this.gModeScp.IsLogIn(this)) return;
        let tPrefab = cc.instantiate(this.preEducation);
        tPrefab.parent = this.node;
        tPrefab.setPosition(0, 0);
    },
    /**旅游大厅按钮点击 */
    onBtnTravelClick() {
        if (!this.gModeScp.IsLogIn(this)) return;
        let tPrefab = cc.instantiate(this.preTravel);
        tPrefab.parent = this.node;
        tPrefab.setPosition(0, 0);
    },
    /**数字商城按钮点击 */
    onBtnDigitalMallClick() {
        if (!this.gModeScp.IsLogIn(this)) return;
        let tPrefab = cc.instantiate(this.preDigitalMall);
        tPrefab.parent = this.node;
        tPrefab.setPosition(0, 0);
    },
    /**UI */
    onNotice() {
        if (!this.gModeScp.IsLogIn(this)) return;
        var self = this;
        cc.loader.loadRes("Prefabs/Notice/Notice", function (err, prefab) {
            let tPrefab = cc.instantiate(prefab);
            tPrefab.parent = self.node;
            tPrefab.setPosition(0, 0);
        });
    },
    //右上角按钮点击
    /**每日签到按钮点击 */
    onBtnSignClick() {
        // if (!this.gModeScp.IsLogIn(this)) return;
        let tPrefab = cc.instantiate(this.preSign);
        tPrefab.parent = this.node;
        tPrefab.setPosition(0, 0);
    },
    /**展示待开放 */
    showToBeOpened() {
        if (!this.gModeScp.IsLogIn(this)) return;
        let tPrefab = cc.instantiate(this.preToBeOpened);
        tPrefab.parent = this.node;
        tPrefab.setPosition(0, 0);
    },
});
