提交 525b710b 编写于 作者: DCloud_JSON's avatar DCloud_JSON

修复mixin引用错误的问题

上级 c6950357
<template> <template>
<view class="content"> <view class="content">
<!-- 顶部文字 --> <!-- 顶部文字 -->
<text class="title">重置密码</text> <text class="title">重置密码</text>
<login-ikonw v-show="isPhone" class="login-iknow" :text="tipText"></login-ikonw> <login-ikonw v-show="isPhone" class="login-iknow" :text="tipText"></login-ikonw>
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) --> <!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-forms ref="form" :value="formData" :rules="rules"> <uni-forms ref="form" :value="formData" :rules="rules">
<uni-forms-item name="phone"> <uni-forms-item name="phone">
<!-- focus规则如果上一页携带来“手机号码”数据就focus验证码输入框,否则focus手机号码输入框 --> <!-- focus规则如果上一页携带来“手机号码”数据就focus验证码输入框,否则focus手机号码输入框 -->
<uni-easyinput :focus="!formData.phone.length" type="number" class="easyinput" :inputBorder="false" <uni-easyinput :focus="!formData.phone.length" type="number" class="easyinput" :inputBorder="false"
v-model="formData.phone" maxlength="11" placeholder="请输入手机号"></uni-easyinput> v-model="formData.phone" maxlength="11" placeholder="请输入手机号"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="code"> <uni-forms-item name="code">
<uni-easyinput :focus="formData.phone.length!=0" type="number" class="easyinput" :inputBorder="false" <uni-easyinput :focus="formData.phone.length!=0" type="number" class="easyinput" :inputBorder="false"
v-model="formData.code" maxlength="6" placeholder="请输入验证码"> v-model="formData.code" maxlength="6" placeholder="请输入验证码">
<template slot="right"> <template slot="right">
<send-sms-code ref="shortCode" :phone="formData.phone"></send-sms-code> <send-sms-code ref="shortCode" :phone="formData.phone"></send-sms-code>
</template> </template>
</uni-easyinput> </uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="pwd"> <uni-forms-item name="pwd">
<uni-easyinput type="password" class="easyinput" :inputBorder="false" <uni-easyinput type="password" class="easyinput" :inputBorder="false" v-model="formData.pwd"
v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput> placeholder="请输入新密码"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="pwd2"> <uni-forms-item name="pwd2">
<uni-easyinput type="password" class="easyinput" :inputBorder="false" <uni-easyinput type="password" class="easyinput" :inputBorder="false" v-model="formData.pwd2"
v-model="formData.pwd2" placeholder="请确认新密码"></uni-easyinput> placeholder="请确认新密码"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'" <button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
@click="submit">完成</button> @click="submit">完成</button>
</uni-forms> </uni-forms>
</view> </view>
</template> </template>
<script> <script>
import mixin from '../common/loginPage.mixin.js'; import mixin from '../common/login-page.mixin.js';
export default { export default {
mixins:[mixin], mixins: [mixin],
data() { data() {
return { return {
formData: {
"phone": "",
'pwd': '',
'pwd2': ''
},
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位',
}
]
},
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
}
}
]
}
}
} }
}, },
computed: { computed: {
...@@ -46,21 +106,21 @@ import mixin from '../common/loginPage.mixin.js'; ...@@ -46,21 +106,21 @@ import mixin from '../common/loginPage.mixin.js';
}, },
canSubmit() { canSubmit() {
return this.isPhone && this.isPwd && this.isCode; return this.isPhone && this.isPwd && this.isCode;
}, },
isPhone(){ isPhone() {
let reg_phone = /^1\d{10}$/; let reg_phone = /^1\d{10}$/;
let isPhone = reg_phone.test(this.formData.phone); let isPhone = reg_phone.test(this.formData.phone);
return isPhone; return isPhone;
}, },
isPwd(){ isPwd() {
let reg_pwd = /^.{6,20}$/; let reg_pwd = /^.{6,20}$/;
let isPwd = reg_pwd.test(this.formData.pwd); let isPwd = reg_pwd.test(this.formData.pwd);
return isPwd; return isPwd;
}, },
isCode(){ isCode() {
let reg_code = /^\d{6}$/; let reg_code = /^\d{6}$/;
let isCode = reg_code.test(this.formData.code); let isCode = reg_code.test(this.formData.code);
return isCode; return isCode;
} }
}, },
onLoad(event) { onLoad(event) {
...@@ -69,7 +129,7 @@ import mixin from '../common/loginPage.mixin.js'; ...@@ -69,7 +129,7 @@ import mixin from '../common/loginPage.mixin.js';
} }
}, },
onReady() { onReady() {
if(this.formData.phone){ if (this.formData.phone) {
this.$refs.shortCode.start(); this.$refs.shortCode.start();
} }
}, },
...@@ -77,32 +137,33 @@ import mixin from '../common/loginPage.mixin.js'; ...@@ -77,32 +137,33 @@ import mixin from '../common/loginPage.mixin.js';
/** /**
* 完成并提交 * 完成并提交
*/ */
submit(){ submit() {
this.$refs.form.submit() this.$refs.form.submit()
.then(res=>{ .then(res => {
this.request('user-center/resetPwdBySmsCode',{ this.request('user-center/resetPwdBySmsCode', {
"mobile":this.formData.phone, "mobile": this.formData.phone,
"code":this.formData.code, "code": this.formData.code,
"password":this.formData.pwd "password": this.formData.pwd
},result=>{ }, result => {
console.log(result); console.log(result);
uni.showToast({ uni.showToast({
title: result.msg, title: result.msg,
icon: 'none' icon: 'none'
}); });
if(result.code === 0){ if (result.code === 0) {
uni.navigateBack() uni.navigateBack()
} }
})
}) })
})
} }
} }
} }
</script> </script>
<style> <style>
@import url("../common/login-page.css"); @import url("../common/login-page.css");
.content-top-title{
margin-bottom: 6px; .content-top-title {
margin-bottom: 6px;
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册