methods: {
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
alert('submit!');
} else {
console.log('error submit!!');
return false;
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
}
}
//https://element.eleme.cn/#/zh-CN/component/form
codeSign() {
let mobile = /^[1][3,4,5,7,8,9][0-9]{9}$/
if (!this.mobileFrom.mobile) {
this.$message.error('请输入手机号')
return false
}
if (!mobile.test(this.mobileFrom.mobile)) {
this.$message.error('手机号格式不正确,请重新输入')
return false
}
if (!this.mobileFrom.code) {
this.$message.error('请输入验证码')
return false
}
if (!this.protocolFlag) {
this.$message.error('请先阅读用户 隐私协议 以及 服务协议')
return false
}
this.setLoginType('Basic cG5hYXM6cG5hYXM=')
const form: any = this.$refs.mobileFrom
if (form.validate) {
form.validate((valid: boolean) => {
if (valid) {
LoginApi.phoneLogin(this.mobileFrom.mobile, this.mobileFrom.code)
.then((resp: any) => {
if (resp.is_first == 1) {
this.$message.success('登录成功')
this.setUser(resp)
this.setLoginType('Bearer ')
this.$router.push({
path: '/setUserInfo',
query: {
phone: this.mobileFrom.mobile
}
})
} else {
this.$message.success('登录成功')
this.setUser(resp)
this.setLoginType('Bearer ')
this.$router.push('/')
}
})
.catch(error => {
this.$message.error(error.message)
})
}
})
}
}