提交 4912b726 编写于 作者: 芊里

data变量提取到mixin

上级 c39e90b3
......@@ -10,6 +10,58 @@ let mixin = {
url:helpPage
})
},
data(){
return {
// 用户协议页面跳转
link: [{
text: '用户协议',
to: '/pages/ucenter/agree-list/service/service'
}, {
text: '隐私政策',
to: '/pages/ucenter/agree-list/privacy/privacy'
}],
formData:{
phone:'',
code:'',
pwd:''
},
rules: {
phone:{
rules:[{
required: true,
errorMessage: '请输入手机号',
},
{
pattern: /^1\d{10}$/,
errorMessage: '手机号格式不正确',
}
]
},
code: {
rules: [{
required: true,
errorMessage: '请输入验证码',
},
{
pattern: /^.{6}$/,
errorMessage: '请输入6位验证码',
}
]
},
pwd:{
rules: [{
required: true,
errorMessage: '请输入密码',
},
{
pattern: /^.{6,20}$/,
errorMessage: '密码应为6到20位',
}
]
}
}
}
},
methods:{
...mapMutations({
setUserInfo: 'user/login'
......
......@@ -45,33 +45,8 @@
mixins:[mixin],
data() {
return {
link: [{
text: '用户协议',
to: '/pages/ucenter/agree-list/service/service'
}, {
text: '隐私政策',
to: '/pages/ucenter/agree-list/privacy/privacy'
}],
phoneArea: ['+86'],
currenPhoneArea: '+86',
formData: {
phone: ''
},
rules: {
// 对phone字段进行必填验证
phone: {
rules: [{
required: true,
errorMessage: '请输入手机号',
},
{
pattern: /^1\d{10}$/,
errorMessage: '手机号格式不正确',
}
]
}
}
}
},
onLoad() {
......
......@@ -11,7 +11,7 @@
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.code" maxlength="6" placeholder="请输入验证码">
<template slot="right">
<login-short-code :phone="phoneNumber" ref="shortCode"></login-short-code>
<login-short-code :phone="formData.phone" ref="shortCode"></login-short-code>
</template>
</uni-easyinput>
</uni-forms-item>
......@@ -30,41 +30,23 @@
mixins:[mixin],
data() {
return {
phoneNumber: '',
phoneCode: '',
currenPhoneArea: '',
formData:{
code:''
},
rules: {
code: {
rules: [{
required: true,
errorMessage: '请输入验证码',
},
{
pattern: /^.{6}$/,
errorMessage: '请输入6位验证码',
}
]
}
}
currenPhoneArea: '',
}
},
computed: {
tipText() {
return `验证码已通过短信发送至${this.currenPhoneArea} ${this.phoneNumber}。`;
return `验证码已通过短信发送至${this.currenPhoneArea} ${this.formData.phone}。`;
},
canSubmit() {
let reg_phone = /^1\d{10}$/;
let reg_code = /^\d{6}$/;
let isPhone = reg_phone.test(this.phoneNumber);
let isPhone = reg_phone.test(this.formData.phone);
let isCode = reg_code.test(this.formData.code);
return isPhone && isCode;
}
},
onLoad({phoneNumber,phoneArea}) {
this.phoneNumber = phoneNumber;
this.formData.phone = phoneNumber;
this.currenPhoneArea = '+' + Number(phoneArea);
},
onReady() {
......@@ -80,7 +62,7 @@
"data": {
"action": "loginBySms",
"params":{
"mobile":this.phoneNumber,
"mobile":this.formData.phone,
"code":this.formData.code
}
},
......
......@@ -49,35 +49,6 @@
}],
phoneArea: ['+86'],
currenPhoneArea: '+86',
formData: {
phone: '',
pwd:''
},
rules: {
phone: {
rules: [{
required: true,
errorMessage: '请输入手机号',
},
{
pattern: /^1\d{10}$/,
errorMessage: '手机号格式不正确',
}
]
},
pwd:{
rules: [{
required: true,
errorMessage: '请输入密码',
},
{
pattern: /^.{6,20}$/,
errorMessage: '密码应为6到20位',
}
]
}
}
}
},
computed: {
......
......@@ -33,49 +33,7 @@ import mixin from '../../common/loginPage.mixin.js';
mixins:[mixin],
data() {
return {
password: '',
currenPhoneArea: '',
formData:{
phone:'',
code:'',
pwd:''
},
rules: {
phone:{
rules:[{
required: true,
errorMessage: '请输入手机号',
},
{
pattern: /^1\d{10}$/,
errorMessage: '手机号格式不正确',
}
]
},
code: {
rules: [{
required: true,
errorMessage: '请输入验证码',
},
{
pattern: /^.{6}$/,
errorMessage: '请输入6位验证码',
}
]
},
pwd:{
rules: [{
required: true,
errorMessage: '请输入密码',
},
{
pattern: /^.{6,20}$/,
errorMessage: '密码应为6到20位',
}
]
}
}
currenPhoneArea: '',
}
},
computed: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册