37922210 by joe

登录页增加校验

1 parent bc5307fa
...@@ -11,8 +11,6 @@ import { ...@@ -11,8 +11,6 @@ import {
11 } from '@/api/fetch-api.js' 11 } from '@/api/fetch-api.js'
12 12
13 13
14 import { contactMethodCheck, checkVerifyCode } from '@utils/utils.js';
15
16 import modalComp from '@/components/modal-comp/modal-comp.vue'; 14 import modalComp from '@/components/modal-comp/modal-comp.vue';
17 import modalSimpleComp from '@/components/modal-simple-comp/modal-simple-comp.vue'; 15 import modalSimpleComp from '@/components/modal-simple-comp/modal-simple-comp.vue';
18 import modalProtocolComp from '@/components/modal-protocol-comp/modal-protocol-comp.vue'; 16 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 ...@@ -20,6 +18,9 @@ import modalUploadCardComp from '@/components/modal-upload-card-comp/modal-uploa
20 import { 18 import {
21 passwordEncrypt 19 passwordEncrypt
22 } from '@/utils/encrypt.js'; 20 } from '@/utils/encrypt.js';
21
22 import { contactMethodCheck, checkVerifyCode } from '@utils/utils.js';
23
23 import Vue from 'vue'; 24 import Vue from 'vue';
24 import { Loading } from 'vant'; 25 import { Loading } from 'vant';
25 26
...@@ -114,7 +115,17 @@ export default { ...@@ -114,7 +115,17 @@ export default {
114 let b1 = !this.loginCheck.agreeProtocol; 115 let b1 = !this.loginCheck.agreeProtocol;
115 let b2 = !this.loginForm.userId; 116 let b2 = !this.loginForm.userId;
116 let b3 = !this.loginForm.password; 117 let b3 = !this.loginForm.password;
117 return b1 || b2 || b3; 118
119 let b = b1 || b2 || b3;
120
121 if (this.oneAccountCenterOff && !b) {
122 let mobile = this.loginForm.userId;
123 let m1 = !contactMethodCheck('hkmobile', mobile);
124 let m2 = !contactMethodCheck('mobile', mobile);
125 b = b || m1 || m2;
126 }
127
128 return b;
118 }, 129 },
119 otpLoginDisabled() { 130 otpLoginDisabled() {
120 let b1 = !this.loginCheck.agreeProtocol; 131 let b1 = !this.loginCheck.agreeProtocol;
...@@ -237,6 +248,17 @@ export default { ...@@ -237,6 +248,17 @@ export default {
237 } 248 }
238 } 249 }
239 }, 250 },
251 userIdLegalCheck() {
252 let mobile = this.loginForm.userId;
253 let m1 = contactMethodCheck('hkmobile', mobile);
254 let m2 = contactMethodCheck('mobile', mobile);
255 // console.log("userIdLegalCheck:", m1, m2)
256 if (!m1 && !m2) {
257 this._showMobileNoIllegalTip()
258 return false;
259 }
260 return true;
261 },
240 selfLogin() { 262 selfLogin() {
241 if (this.pwdLoginDisabled) { 263 if (this.pwdLoginDisabled) {
242 return; 264 return;
...@@ -508,6 +530,8 @@ export default { ...@@ -508,6 +530,8 @@ export default {
508 _showMobileNoIllegalTip() { 530 _showMobileNoIllegalTip() {
509 let message = this.i18n.login.tips.oe0; 531 let message = this.i18n.login.tips.oe0;
510 this.errorTips.oe1 = message; 532 this.errorTips.oe1 = message;
533 if (this.oneAccountCenterOff)
534 this.errorTips.e1 = message;
511 // alert("手机号不正确"); 535 // alert("手机号不正确");
512 }, 536 },
513 _startStdSendOTP() { 537 _startStdSendOTP() {
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
36 <img src="@/assets/images/login/icon-login-user.png"> {{$t('login.account')}} 36 <img src="@/assets/images/login/icon-login-user.png"> {{$t('login.account')}}
37 </div> 37 </div>
38 <div class="ipt-wrap"> 38 <div class="ipt-wrap">
39 <input v-model="loginForm.userId" :placeholder="$t('login.accountPlaceholder')" class="ipt" :class="{ err : errorTips.e1.length > 0 }" type="text"> 39 <input v-model="loginForm.userId" :placeholder="$t('login.accountPlaceholder')" class="ipt" :class="{ err : errorTips.e1.length > 0 }" type="text" @blur="userIdLegalCheck">
40 </div> 40 </div>
41 <div class="validator" v-if="errorTips.e1.length > 0 "> 41 <div class="validator" v-if="errorTips.e1.length > 0 ">
42 <img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e1}} 42 <img src="@/assets/images/common/icon-notice.png" alt="">{{errorTips.e1}}
......
...@@ -267,7 +267,7 @@ export function contactMethodCheck(type, value) { ...@@ -267,7 +267,7 @@ export function contactMethodCheck(type, value) {
267 267
268 if (type == 'mobile') { 268 if (type == 'mobile') {
269 // 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); 269 // 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);
270 return /^1\d{10}$/.test(value); 270 return /^(\+)?(86)?(\-)?1\d{10}$/.test(value);
271 } 271 }
272 272
273 if (type == 'email') { 273 if (type == 'email') {
......