jqMultipleShow("click", ".navList", ".tab", ".con");
var phonePage = new Vue({
    el: "#phonePage",
    data: {
        loginLoading:false,
        count: '',					//倒计时
        newCount: '',				//倒计时
        codeTime: null,
        codeTimeNew: null,
        mobileCodeText: '获取验证码',
        newMobileCodeText: '获取验证码',
        isMobileDisabled: false,	//手机验证码按钮控制
        isNewMobileDisabled: false,	//手机验证码按钮控制
        form:{
            contractMobile2:'', //新联系人手机号
            contractMobile:'',  //旧联系人手机号
            mobileCode:'',      //原手机号验证码
            newMobileCode:'',   //新手机号手机验证码
            userID:0
        },
        rule:{
            phone: '^\\d{6,12}$',
            code: '^\\d{6}$',
        }
    },
    computed: {

    },
    methods: {
        bindMobileCheck:function(){
            var _self = this;
            var pass = verifyForm();
            if (_self.loginLoading) { return false; }
            if (!pass) {return false;}
            _self.loginLoading = true;
            PublicApi.clubChangeMobile(_self.form,function (response) {
                if(response.code === 0){
                    CAIMEI.dialog('修改成功',true,function () {
                        _self.loginLoading = false;
                        CAIMEI.Storage.clear();
                        window.location.href = '/login.html';
                    });
                } else {
                    CAIMEI.Alert(response.msg,'确定',false);
                    _self.loginLoading = false;
                }
            });
        },
        getMobileCodeFn:function(){//获取旧手机号验证码
            var _self = this;
            _self.isMobileDisabled = true;
            PublicApi.getClubMobileCode({ mobile : _self.form.contractMobile2 },function(response){
                if(response.code == 0){
                    CAIMEI.dialog('验证短信已发送',false,function () {});
                    var TIME_COUNT = 60;
                    if (!_self.mobilTime) {
                            _self.count = TIME_COUNT;
                            _self.isMobileDisabled = true;
                            _self.codeTime = setInterval(function(){
                                if (_self.count > 1 && _self.count <= TIME_COUNT) {
                                    _self.count--;
                                    _self.mobileCodeText = _self.count +'s重新发送';
                                } else {
                                    _self.isMobileDisabled = false;
                                    clearInterval(_self.codeTime);
                                    _self.codeTime = null;
                                    _self.mobileCodeText = '获取验证码';
                                }
                            },1000)
                        }
                }else{
                    CAIMEI.Alert(response.msg,'确定',false);
                    _self.isMobileDisabled = false;
                }
            })
        },
        getNewMobileCodeFn:function(){//获取新手机号短信验证码
            var _self = this;
            _self.isNewMobileDisabled = true;
            PublicApi.getClubMobileCode({ mobile : _self.form.contractMobile },function(response){
                    if(response.code == 0){
                        CAIMEI.dialog('验证短信已发送',false,function () {});
                        var TIME_COUNT = 60;
                        if (!_self.codeTimeNew) {
                            _self.newCount = TIME_COUNT;
                            _self.isNewMobileDisabled = true;
                            _self.codeTimeNew = setInterval(function(){
                                if (_self.newCount > 1 && _self.newCount <= TIME_COUNT) {
                                    _self.newCount--;
                                    _self.newMobileCodeText = _self.newCount +'s重新发送';
                                } else {
                                    _self.isNewMobileDisabled = false;
                                    clearInterval(_self.codeTimeNew);
                                    _self.codeTimeNew = null;
                                    _self.newMobileCodeText = '获取验证码';
                                }
                            },1000)
                        }
                    }else{
                        CAIMEI.Alert(response.msg,'确定',false);
                        _self.isNewMobileDisabled = false;
                    }
                })
        },
        blurHandle: function(event) { // 失去焦点校验
            var el = event.currentTarget;
            verifyHandle(el);
        }
    },
    created: function () {

    },
    mounted: function () {
        var _self = this;
        if(globalUserData){
            _self.form.contractMobile2 = globalUserData.phone;
            _self.form.userID = globalUserData.userId;
        }
        $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on");
        $('.navLayout').find('.navList').eq(2).addClass("on").find('.con').show().find('a').eq(1).addClass("on");
    }
});
