提交 fd0ec305 编写于 作者: 芊里

forms组件校验不适用于login页面

上级 6516fdf2
......@@ -62,6 +62,23 @@ let mixin = {
}
}
},
computed: {
isPhone(){
let reg_phone = /^1\d{10}$/;
let isPhone = reg_phone.test(this.formData.phone);
return isPhone;
},
isPwd(){
let reg_pwd = /^.{6,20}$/;
let isPwd = reg_pwd.test(this.formData.pwd);
return isPwd;
},
isCode(){
let reg_code = /^\d{6}$/;
let isCode = reg_code.test(this.formData.code);
return isCode;
}
},
methods:{
...mapMutations({
setUserInfo: 'user/login'
......
......@@ -70,19 +70,10 @@
},
computed: {
canGetShortMsg() {
let reg = /^1\d{10}$/;
return reg.test(this.formData.phone);
return this.isPhone;
}
},
methods: {
// 触发提交表单
submit() {
this.$refs.form.submit().then(res => {
console.log('表单数据信息:', res);
}).catch(err => {
console.log('表单错误信息:', err);
})
},
selectPhoneArea(event) {
uni.showToast({
title: '当前仅支持中国大陆手机号',
......@@ -91,7 +82,6 @@
// this.currenPhoneArea = this.phoneArea[event.detail.value];
},
sendShortMsg() {
if (!this.canGetShortMsg) return;
/**
* 发送验证吗
*/
......
......@@ -38,11 +38,7 @@
return `验证码已通过短信发送至${this.currenPhoneArea} ${this.formData.phone}。`;
},
canSubmit() {
let reg_phone = /^1\d{10}$/;
let reg_code = /^\d{6}$/;
let isPhone = reg_phone.test(this.formData.phone);
let isCode = reg_code.test(this.formData.code);
return isPhone && isCode;
return this.isPhone && this.isCode;
}
},
onLoad({phoneNumber,phoneArea}) {
......
......@@ -46,12 +46,7 @@
},
computed: {
canLogin() {
let reg_phone = /^1\d{10}$/;
let reg_pwd = /^.{6,20}$/;
let isPhone = reg_phone.test(this.formData.phone);
let isPwd = reg_pwd.test(this.formData.pwd);
return isPhone && isPwd;
return this.isPhone && this.isPwd;
}
},
methods: {
......@@ -59,9 +54,7 @@
* 页面跳转,找回密码
*/
toRetrievePwd() {
let reg_phone = /^1\d{10}$/;
let isPhone = reg_phone.test(this.formData.phone);
if (!isPhone) return uni.showToast({
if (!this.isPhone) return uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
......@@ -74,7 +67,6 @@
* 密码登录
*/
pwdLogin() {
if (!this.canLogin) return;
// 下边是可以登录
uniCloud.callFunction({
name:"user-center",
......
......@@ -41,13 +41,7 @@ import mixin from '../../common/loginPage.mixin.js';
return `验证码已通过短信发送至${this.currenPhoneArea} ${this.formData.phone}。密码为6 - 20位`
},
canSubmit() {
let reg_phone = /^1\d{10}$/;
let reg_pwd = /^.{6,20}$/;
let reg_code = /^\d{6}$/;
let isPhone = reg_phone.test(this.formData.phone);
let isPwd = reg_pwd.test(this.formData.pwd);
let isCode = reg_code.test(this.formData.code);
return isPhone && isPwd && isCode;
return this.isPhone && this.isPwd && this.isCode;
}
},
onLoad(event) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册