let global = require("Global");
cc.Class({
    extends: cc.Component,

    properties: {
        phoneNum:cc.Label,
        phoneCode:cc.Label,
        mailAdress:cc.Label,
        mailCode:cc.Label,
        pwd1:cc.Label,
        pwd2:cc.Label,
    },
    onLoad () {
        this.receive_phoneCode = '';
        this.receive_mailCode = '';
    },
    onClose () {
        this.node.destroy();
        this.node.parent.destroy();
    },
    sendCodePhone()
    {
        if(this.phoneNum.string.length!=11)
        {
            global.alert('您输入的电话号码不对',this);
            return;
        }
        this.receive_phoneCode = '9527';
    },
    sendCodeMail()
    {
        if(this.mailAdress.string.indexOf("@") == -1)
        {
            global.alert('您输入的邮箱不对',this);
            return;
        }
        this.receive_mailCode = '9527';
    },
    onGotoLogin()
    {
        if(this.phoneNum.string.length!=11)
        {
            global.alert('您输入的电话号码不对',this);
            return;
        }
        let phoneCode = this.phoneCode.string;
        if(phoneCode =!this.receive_phoneCode)
        {
            global.alert('手机验证码不正确',this);
            return;
        }
        
        if(this.mailAdress.string.indexOf("@") == -1)
        {
            global.alert('您输入的邮箱不对',this);
            return;
        }
        let mailCode = this.mailCode.string;
        if(mailCode=!this.receive_mailCode)
        {
            global.alert('邮箱验证码不正确',this);
            return;
        }
        let pwd1 = this.pwd1.string;
        let pwd2 = this.pwd2.string;
        if(pwd1=!pwd2)
        {
            global.alert('两次输入密码不一致',this);
            return;
        }

        this.node.destroy();
    },
});
