37922210 by joe

登录页增加校验

1 parent bc5307fa
......@@ -11,8 +11,6 @@ import {
} from '@/api/fetch-api.js'
import { contactMethodCheck, checkVerifyCode } from '@utils/utils.js';
import modalComp from '@/components/modal-comp/modal-comp.vue';
import modalSimpleComp from '@/components/modal-simple-comp/modal-simple-comp.vue';
import modalProtocolComp from '@/components/modal-protocol-comp/modal-protocol-comp.vue';
......@@ -20,6 +18,9 @@ import modalUploadCardComp from '@/components/modal-upload-card-comp/modal-uploa
import {
passwordEncrypt
} from '@/utils/encrypt.js';
import { contactMethodCheck, checkVerifyCode } from '@utils/utils.js';
import Vue from 'vue';
import { Loading } from 'vant';
......@@ -114,7 +115,17 @@ export default {
let b1 = !this.loginCheck.agreeProtocol;
let b2 = !this.loginForm.userId;
let b3 = !this.loginForm.password;
return b1 || b2 || b3;
let b = b1 || b2 || b3;
if (this.oneAccountCenterOff && !b) {
let mobile = this.loginForm.userId;
let m1 = !contactMethodCheck('hkmobile', mobile);
let m2 = !contactMethodCheck('mobile', mobile);
b = b || m1 || m2;
}
return b;
},
otpLoginDisabled() {
let b1 = !this.loginCheck.agreeProtocol;
......@@ -237,6 +248,17 @@ export default {
}
}
},
userIdLegalCheck() {
let mobile = this.loginForm.userId;
let m1 = contactMethodCheck('hkmobile', mobile);
let m2 = contactMethodCheck('mobile', mobile);
// console.log("userIdLegalCheck:", m1, m2)
if (!m1 && !m2) {
this._showMobileNoIllegalTip()
return false;
}
return true;
},
selfLogin() {
if (this.pwdLoginDisabled) {
return;
......@@ -508,6 +530,8 @@ export default {
_showMobileNoIllegalTip() {
let message = this.i18n.login.tips.oe0;
this.errorTips.oe1 = message;
if (this.oneAccountCenterOff)
this.errorTips.e1 = message;
// alert("手机号不正确");
},
_startStdSendOTP() {
......
......@@ -36,7 +36,7 @@
<img src="@/assets/images/login/icon-login-user.png"> {{$t('login.account')}}
</div>
<div class="ipt-wrap">
<input v-model="loginForm.userId" :placeholder="$t('login.accountPlaceholder')" class="ipt" :class="{ err : errorTips.e1.length > 0 }" type="text">
<input v-model="loginForm.userId" :placeholder="$t('login.accountPlaceholder')" class="ipt" :class="{ err : errorTips.e1.length > 0 }" type="text" @blur="userIdLegalCheck">
</div>
<div class="validator" v-if="errorTips.e1.length > 0 ">
<img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e1}}
......
......@@ -267,7 +267,7 @@ export function contactMethodCheck(type, value) {
if (type == 'mobile') {
// return /^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$/.test(value);
return /^1\d{10}$/.test(value);
return /^(\+)?(86)?(\-)?1\d{10}$/.test(value);
}
if (type == 'email') {
......