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

data变量提取到mixin

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