var bindPage = new Vue({ el: "#bindPage", data: { rule:{ mobileOrEmail: '(^([\\w-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([\\w-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$)|(^\\d{6,12}$)', name: '^[a-zA-Z\\u4e00-\\u9fa5]{2,}$', phone: '^\\d{6,12}$', code: '^\\d{6}$', password: "^[^\\u4e00-\\u9fa5]{8,16}$", mobile:'^1[1-9][0-9]{9}$' }, loginLoading:false, mobilCount:0, mobileCodeText:'获取验证码', mobilTime:null, isMobileDisabled:false, isCodeModel:false, codeImagePath:'', codeImageToken:'', imageCode:'', activeNum:0, loginTabs:1, isDisabled:true, isSubDisabled:true, mobilCount1:0, mobileCodeText1:'获取验证码', mobilTime1:null, isMobileDisabled1:false, userParams: { mobileOrEmail :'', password : '', mobile : '', linkName :'', smsCode :'', unionId:'', companyMobile:'', passOrNote:1 }, codeParams:{ mobile:'', code:'' }, smsCodeParams:{// 获取手机短信验证码 mobile: '', //用户登录手机号 }, bindCodeParams:{// 获取运营人员手机验证码 mobile: '', bindMobile: '', platformType:0, isCheckCaptcha:0, imgCode:'', token:'' }, verifiParams:{ mobileOrEmail :'', password : '', mobile:'', code:'', codeType:1 } }, computed: { }, methods: { handleTabsClick(index){// tabs切换 this.loginTabs = this.userParams.passOrNote = this.verifiParams.codeType = index; this.isDisabled = true; if(this.loginTabs === 1){ this.userParams.mobileOrEmail = ''; this.userParams.password = ''; }else{ this.userParams.companyMobile = ''; this.codeParams.mobile = ''; this.codeParams.code = ''; } }, handleStepNext(){// 账号密码 下一步 if(this.isDisabled){ return } this.userLoginVerification(); }, userLoginVerification(){// 校验短信验证码 const _self = this; UserApi.userLoginVerification(this.verifiParams,function(response){ if(response.code === 0){ _self.activeNum = 1; }else{ CAIMEI.Alert(response.msg,'确定',false); } }); }, handleInputMobileOrEmail(e){// 账号输入 this.userParams.mobileOrEmail = this.verifiParams.mobileOrEmail = e.target.value; this.handldeCheckInput(); }, handleInputPassword(e){// 密码输入 this.userParams.password = this.verifiParams.password = e.target.value; this.handldeCheckInput(); }, handleInputPhone(e){// 已注册手机号输入 this.codeParams.mobile = this.smsCodeParams.mobile = this.verifiParams.mobile = this.userParams.companyMobile = e.target.value; this.handldeCheckInput(); }, handleInputSmsCode(e){// 短信验证码输入 this.codeParams.code = this.verifiParams.code = e.target.value; this.handldeCheckInput(); }, handleInputLinkName(e){// 运营人员输入 this.userParams.linkName = e.target.value; this.handldeCheckInput(); }, handleInputMobile(e){// 运营人员手机号输入 this.userParams.mobile = e.target.value; this.handldeCheckInput(); }, handleInputSmsCodee(e){// 运营人员手机验证码输入 this.userParams.smsCode = e.target.value; this.handldeCheckInput(); }, handldeCheckInput(){// 控制按钮高亮 if(this.activeNum === 1){ this.isSubDisabled = !(this.userParams.linkName !== '' && this.userParams.mobile !== '' && this.userParams.smsCode !== ''); }else{ if(this.loginTabs === 0){ this.isDisabled = !(this.userParams.mobileOrEmail !== '' && this.userParams.password !== ''); }else{ this.isDisabled = !(this.codeParams.mobile !== '' && this.codeParams.code !== ''); } } }, handleMobileCode(){// 点击获取短信验证码 const _self = this; if( this.isMobileDisabled1){ return } this.$nextTick(function() { if (!verifyCheack('.codeParamsMobile')) { return false; } UserApi.userOperateCode(_self.smsCodeParams,function (response) { if(response.code === 0){ CAIMEI.dialog('获取验证码成功~',false,function () {}); _self.genereateMobileCodeText() }else{ CAIMEI.Alert(response.msg,'确定',false); _self.isMobileDisabled1 = false; } }) }) }, handleBindConfirm(){ //绑定运营人员 const _self = this; if(this.isSubDisabled){ return } if (this.loginLoading) { return false; } if (!verifyForm()) {return false;} _self.loginLoading = true; UserApi.BindOrganization(_self.userParams,function (response) { if(response.code === 0){ var _userIdentity = response.data.userIdentity; CAIMEI.dialog('绑定成功!',true,function () { _self.userData = { account: response.data.account, email: response.data.email, phone: response.data.bindMobile, name: response.data.name ? response.data.name : response.data.userName, userName: response.data.userName, userId: response.data.userId, spId: response.data.serviceProviderId, clubId: response.data.clubId, shopId: response.data.shopId, userIdentity: response.data.userIdentity, firstClubType: response.data.firstClubType, permission: response.data.userPermission, token: response.data.token }; _self.setStorages( _self.userData); _self.loginLoading = false; // 绑定成功后跳转 if(_userIdentity === 4 || _userIdentity ===2){ window.location.href = '/user/dashboard.html'; }else if(_userIdentity === 3){ window.location.href = '/supplier/dashboard.html'; } }); } else { CAIMEI.Alert(response.msg,'确定',false); _self.loginLoading = false; } }); }, handleShowImage:function() { //获取图形验证码 const _self = this; if (!verifyCheack('.mobileOrEmail')) { return false; } if (!verifyCheack('.massageBtn')) { return false; } if (this.isMobileDisabled) { return false; } PublicApi.getImgVerifyCode({platformType: 0},function(response){ if(response.code === 0){ _self.bindCodeParams.imgCode = ''; _self.codeImagePath = response.data.baseImage; _self.bindCodeParams.token = response.data.token; _self.isCodeModel = true; }else{ CAIMEI.Alert(response.msg,'确定',false); } }) }, getMobileCodeFn:function(){//机构注册获取注册短信验证码 const _self = this; if(this.loginTabs === 0){ this.bindCodeParams.bindMobile = this.userParams.mobileOrEmail }else{ this.bindCodeParams.bindMobile = this.codeParams.mobile } if(this.activeNum === 0){ this.bindCodeParams.mobile = this.codeParams.mobile }else{ this.bindCodeParams.mobile = this.userParams.mobile } if( this.isMobileDisabled){ return } this.$nextTick(function() { if (!verifyCheack('.codeMsgButton')) {return false; } UserApi.getNoteSMScode(this.bindCodeParams,function (response) { if(response.code === 0){ _self.isCodeModel = false; CAIMEI.dialog('验证短信已发送',false,function () {}); _self.genereateMobileCodeText() }else{ _self.handleShowImage(); _self.isMobileDisabled = false; setErrorTxt($('.codeMsgButton'),response.msg); } }) }) }, genereateMobileCodeText: function(){ const TIME_COUNT = 60; const _self = this if(this.activeNum === 0 && !_self.mobilTime1){ _self.mobilCount1 = TIME_COUNT; _self.isMobileDisabled1 = true; _self.mobilTime1 = setInterval(function(){ if (_self.mobilCount1 > 1 && _self.mobilCount1 <= TIME_COUNT) { _self.mobilCount1--; _self.mobileCodeText1 = _self.mobilCount1 +'s'; } else { _self.isMobileDisabled1 = false; clearInterval(this.mobilTime1); _self.mobilTime1 = null; _self.mobileCodeText1 = '获取验证码'; } },1000) }else if(this.activeNum === 1 && !_self.mobilTime){ _self.mobilCount = TIME_COUNT; _self.isMobileDisabled = true; _self.mobilTime = setInterval(function(){ if (_self.mobilCount > 1 && _self.mobilCount <= TIME_COUNT) { _self.mobilCount--; _self.mobileCodeText = _self.mobilCount +'s重新发送'; } else { _self.isMobileDisabled = false; clearInterval(_self.mobilTime); _self.mobilTime = null; _self.mobileCodeText = '获取验证码'; } },1000) } }, setStorages:function(data){//存储本地数据 localStorage.setItem('userInfo',JSON.stringify(data)); }, handleRefreshCodeImage:function(){ this.handleShowImage() }, closeCodeModel:function(){ this.isCodeModel = false; }, blurHandle: function(event) { // 失去焦点校验 var el = event.currentTarget; verifyHandle(el); } }, created: function () { }, mounted: function () { if(globalUserData){ this.userParams.unionId = globalUserData.unionId; } } });