123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- 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:0,
- isDisabled:true,
- isSubDisabled:true,
- mobilCount1:0,
- mobileCodeText1:'获取验证码',
- mobilTime1:null,
- isMobileDisabled1:false,
- userParams: {
- mobileOrEmail :'',
- password : '',
- mobile : '',
- linkName :'',
- smsCode :'',
- unionId:'',
- companyMobile:'',
- passOrNote:0
- },
- codeParams:{
- mobile:'',
- code:''
- },
- smsCodeParams:{// 获取手机短信验证码
- mobile: '', //用户登录手机号
- },
- bindCodeParams:{// 获取运营人员手机验证码
- mobile: '',
- bindMobile: '',
- platformType:0,
- isCheckCaptcha:0,
- imgCode:'',
- token:''
- },
- verifiParams:{
- mobileOrEmail :'',
- password : '',
- mobile:'',
- code:'',
- codeType:0
- }
- },
- 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 () {});
- const TIME_COUNT = 60;
- if (!_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(_self.mobilTime1);
- _self.mobilTime1 = null;
- _self.mobileCodeText1 = '获取验证码';
- }
- },1000)
- }
- }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
- }
- 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 () {});
- var TIME_COUNT = 60;
- if (!_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)
- }
- }else{
- _self.handleShowImage();
- _self.isMobileDisabled = false;
- setErrorTxt($('.codeMsgButton'),response.msg);
- }
- })
- })
- },
- 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;
- }
- }
- });
|