提交 0436220a 编写于 作者: 芊里

登陆界面表单校验

上级 5b57105f
......@@ -353,7 +353,8 @@
this.formData[i] = this._getValue(i, this.value[i])
}
}
}
}
console.log(this.formData, this.formRules);
return this.validateAll(this.formData, 'submit', callback)
},
......
......@@ -21,7 +21,8 @@ let mixin = {
formData:{
phone:'',
code:'',
pwd:''
pwd:'',
pwd2:''
},
rules: {
phone:{
......@@ -56,6 +57,26 @@ let mixin = {
errorMessage: '密码应为6到20位',
}
]
},
pwd2:{
rules:[{
required: true,
errorMessage: '请确认密码',
},
{
pattern: /^.{6,20}$/,
errorMessage: '密码应为6到20位',
},
{
validateFunction:function(rule,value,data,callback){
console.log(value);
if(value!=data.pwd){
callback('两次输入密码不一致')
};
return true
}
}
]
}
}
}
......
......@@ -16,19 +16,23 @@
<text class="phone-area" @click="selectPhoneArea">{{currenPhoneArea}}</text>
<!-- </picker> -->
</template>
</uni-easyinput>
</uni-easyinput>
</uni-forms-item>
<uni-forms-item name="pwd">
<uni-easyinput type="password" class="phone-input-box" :inputBorder="false"
v-model="formData.pwd" placeholder="请输入密码"></uni-easyinput>
</uni-forms-item>
<button class="send-btn-box" :disabled="!canLogin" :type="canLogin?'primary':'default'"
@click="pwdLogin">登录</button>
</uni-forms>
<!-- 忘记密码 -->
<view class="auth-box">
<text class="login-text login-text-sub">忘记了?</text>
<text class="login-text" @click="toRetrievePwd">找回密码</text>
</view>
<button type="primary" class="toRegister" @click="toRegister">注册账号</button>
<!-- 忘记密码/注册账号 -->
<view class="auth-box">
<view class="auth-box-left">
<text class="login-text login-text-sub">忘记了?</text>
<text class="login-text" @click="toRetrievePwd">找回密码</text>
</view>
<text @click="toRegister" class="login-text">注册账号</text>
</view>
</view>
</view>
<uni-quick-login ref="uniQuickLogin"></uni-quick-login>
......@@ -131,9 +135,14 @@
.phone-input-box {
margin-top: 20rpx;
}
.auth-box {
justify-content: flex-start;
.auth-box {
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-top: 20rpx;
}
.auth-box-left{
flex-direction: row;
}
.login-text-sub {
color: #8a8f8b;
......
......@@ -3,22 +3,30 @@
<view class="wrap-content">
<view class="content">
<!-- 顶部文字 -->
<text class="content-top-title">重置密码</text>
<login-ikonw v-show="formData.phone" class="login-iknow" :text="tipText"></login-ikonw>
<text class="content-top-title">重置密码</text>
<login-ikonw v-show="isPhone" class="login-iknow" :text="tipText"></login-ikonw>
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-forms ref="form" :value="formData" :rules="rules">
<uni-forms-item name="phone">
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.phone" maxlength="11" placeholder="请输入手机号"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="code">
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.code" maxlength="6" placeholder="请输入验证码">
<template slot="right">
<login-short-code ref="shortCode" :phone="formData.phone"></login-short-code>
</template>
</uni-easyinput>
</uni-forms-item>
<uni-forms-item name="pwd">
<uni-easyinput type="password" class="phone-input-box" :inputBorder="false"
v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="pwd2">
<uni-easyinput type="password" class="phone-input-box" :inputBorder="false"
v-model="formData.pwd2" placeholder="请确认新密码"></uni-easyinput>
</uni-forms-item>
<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
@click="submit">完成</button>
</uni-forms>
......@@ -52,7 +60,7 @@ import mixin from '../../common/loginPage.mixin.js';
},
onReady() {
if(this.formData.phone){
this.$refs.shortCode.start();
// this.$refs.shortCode.start();
}
},
methods: {
......@@ -60,19 +68,22 @@ import mixin from '../../common/loginPage.mixin.js';
* 完成并提交
*/
submit(){
this.request('user-center/resetPwdBySmsCode',{
"mobile":this.formData.phone,
"code":this.formData.code,
"password":this.formData.pwd
},(data,result)=>{
console.log(result);
uni.showToast({
title: result.msg,
icon: 'none'
});
if(result.code === 0){
uni.navigateBack()
}
this.$refs.form.submit()
.then(res=>{
this.request('user-center/resetPwdBySmsCode',{
"mobile":this.formData.phone,
"code":this.formData.code,
"password":this.formData.pwd
},(data,result)=>{
console.log(result);
uni.showToast({
title: result.msg,
icon: 'none'
});
if(result.code === 0){
uni.navigateBack()
}
})
})
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册