|
@ -1,71 +1,72 @@ |
|
|
<template> |
|
|
<template> |
|
|
<view class="content passwordpage"> |
|
|
<view class="content passwordpage"> |
|
|
<uni-forms ref="form" :modelValue="formData" :rules="rules"> |
|
|
<uni-forms ref="form" :modelValue="formData" :rules="rules"> |
|
|
<uni-forms-item label="原密码" name="oldPassword" style="margin: 20rpx 0;"> |
|
|
<uni-forms-item label="原密码" name="oldPassword" style="margin: 20rpx 0;"> |
|
|
<uni-easyinput type="password" v-model="formData.oldPassword" placeholder="请输入原来的密码" /> |
|
|
<uni-easyinput type="password" v-model="formData.oldPassword" placeholder="请输入原来的密码" /> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label="新密码" name="password" style="border-bottom: 1px solid #eee;"> |
|
|
<uni-forms-item label="新密码" name="password" style="border-bottom: 1px solid #eee;"> |
|
|
<uni-easyinput type="password" v-model="formData.password" placeholder="请输入新密码" /> |
|
|
<uni-easyinput type="password" v-model="formData.password" placeholder="请输入新密码" /> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label="确认新密码" name="againPassword"> |
|
|
<uni-forms-item label="确认新密码" name="againPassword"> |
|
|
<uni-easyinput type="password" v-model="formData.againPassword" placeholder="请再次输入密码" /> |
|
|
<uni-easyinput type="password" v-model="formData.againPassword" placeholder="请再次输入密码" /> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
</uni-forms> |
|
|
</uni-forms> |
|
|
<view class="new_btn_bot"> |
|
|
<view class="new_btn_bot"> |
|
|
<button class="new_save_btn" @click="submit">确认修改</button> |
|
|
<button class="new_save_btn" @click="submit">确认修改</button> |
|
|
</view> |
|
|
</view> |
|
|
<comMessage ref="comMessage"></comMessage> |
|
|
<comMessage ref="comMessage"></comMessage> |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { loginUpdateUserPwd } from '@/api/request2.js'; |
|
|
import { |
|
|
|
|
|
loginUpdateUserPwd |
|
|
|
|
|
} from '@/api/request2.js'; |
|
|
import { |
|
|
import { |
|
|
navigateBack, |
|
|
navigateBack, |
|
|
} from '@/common/basic.js'; |
|
|
} from '@/common/basic.js'; |
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
// 表单数据 |
|
|
// 表单数据 |
|
|
formData: { |
|
|
formData: { |
|
|
oldPassword: '', |
|
|
oldPassword: '', |
|
|
password: '', |
|
|
password: '', |
|
|
againPassword: '' |
|
|
againPassword: '' |
|
|
}, |
|
|
}, |
|
|
rules: { |
|
|
rules: { |
|
|
oldPassword: { |
|
|
oldPassword: { |
|
|
rules: [{ |
|
|
rules: [{ |
|
|
required: true, |
|
|
required: true, |
|
|
errorMessage: '请输入密码', |
|
|
errorMessage: '请输入原密码', |
|
|
} |
|
|
}] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
// 对name字段进行必填验证 |
|
|
// 对name字段进行必填验证 |
|
|
password: { |
|
|
password: { |
|
|
rules: [{ |
|
|
rules: [{ |
|
|
required: true, |
|
|
required: true, |
|
|
errorMessage: '请输入新密码', |
|
|
errorMessage: '请输入密码', |
|
|
} |
|
|
}, |
|
|
// { |
|
|
{ |
|
|
// minLength: 6, |
|
|
minLength: 6, |
|
|
// maxLength: 20, |
|
|
maxLength: 20, |
|
|
// errorMessage: '密码长度在 {minLength} 到 {maxLength} 个字符', |
|
|
errorMessage: '密码长度在 {minLength} 到 {maxLength} 个字符', |
|
|
// } |
|
|
} |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
// 对email字段进行必填验证 |
|
|
// 对email字段进行必填验证 |
|
|
againPassword: { |
|
|
againPassword: { |
|
|
rules: [{ |
|
|
rules: [{ |
|
|
required: true, |
|
|
required: true, |
|
|
errorMessage: '请输入新密码', |
|
|
errorMessage: '请输入密码', |
|
|
}, |
|
|
}, |
|
|
// { |
|
|
{ |
|
|
// minLength: 6, |
|
|
minLength: 6, |
|
|
// maxLength: 20, |
|
|
maxLength: 20, |
|
|
// errorMessage: '密码长度在 {minLength} 到 {maxLength} 个字符', |
|
|
errorMessage: '密码长度在 {minLength} 到 {maxLength} 个字符', |
|
|
// }, |
|
|
}, |
|
|
|
|
|
{ |
|
|
{ |
|
|
validateFunction:function(rule,value,data,callback){ |
|
|
validateFunction: function(rule, value, data, callback) { |
|
|
console.log(value !== data.againPassword) |
|
|
console.log(value !== data.againPassword) |
|
|
if (value !== data.againPassword) { |
|
|
if (value !== data.againPassword) { |
|
|
callback('两次输入不同') |
|
|
callback('两次输入不同') |
|
@ -73,54 +74,56 @@ |
|
|
return true |
|
|
return true |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
/** |
|
|
/** |
|
|
* 复写 binddata 方法,如果只是为了校验,无复杂自定义操作,可忽略此方法 |
|
|
* 复写 binddata 方法,如果只是为了校验,无复杂自定义操作,可忽略此方法 |
|
|
* @param {String} name 字段名称 |
|
|
* @param {String} name 字段名称 |
|
|
* @param {String} value 表单域的值 |
|
|
* @param {String} value 表单域的值 |
|
|
*/ |
|
|
*/ |
|
|
// binddata(name,value){ |
|
|
// binddata(name,value){ |
|
|
// 通过 input 事件设置表单指定 name 的值 |
|
|
// 通过 input 事件设置表单指定 name 的值 |
|
|
// this.$refs.form.setValue(name, value) |
|
|
// this.$refs.form.setValue(name, value) |
|
|
// }, |
|
|
// }, |
|
|
// 触发提交表单 |
|
|
// 触发提交表单 |
|
|
submit() { |
|
|
submit() { |
|
|
this.$refs.form.validate().then(res=>{ |
|
|
this.$refs.form.validate().then(res => { |
|
|
loginUpdateUserPwd(uni.getStorageSync('username'),res.oldPassword,res.password,res.password).then((ress)=>{ |
|
|
loginUpdateUserPwd(uni.getStorageSync('username'), res.oldPassword, res.password, res.password) |
|
|
console.log('返回结果:', ress); |
|
|
.then((ress) => { |
|
|
if(ress.data){ |
|
|
console.log('返回结果:', ress); |
|
|
this.showCommitSuccessMessage("修改成功") |
|
|
if (ress.data) { |
|
|
setTimeout(function (){ |
|
|
uni.showToast({ |
|
|
uni.reLaunch({ |
|
|
title: "修改成功" |
|
|
url: '../login/index' |
|
|
}) |
|
|
}) |
|
|
setTimeout(function() { |
|
|
},2000) |
|
|
uni.reLaunch({ |
|
|
} |
|
|
url: '../login/index' |
|
|
}).catch(err =>{ |
|
|
}) |
|
|
this.$refs.comMessage.showErrorMessage(err) |
|
|
}, 500) |
|
|
}) |
|
|
} |
|
|
}).catch(err =>{ |
|
|
}).catch(err => { |
|
|
console.log('表单错误信息:', err); |
|
|
this.$refs.comMessage.showErrorMessage(err) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}).catch(err => { |
|
|
|
|
|
console.log('表单错误信息:', err); |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
showCommitSuccessMessage(hint) { |
|
|
showCommitSuccessMessage(hint) { |
|
|
this.$refs.comMessage.showSuccessMessage(hint, res => { |
|
|
this.$refs.comMessage.showSuccessMessage(hint, res => { |
|
|
navigateBack(1) |
|
|
|
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style> |
|
|
<style> |
|
|
.content{ |
|
|
.content { |
|
|
/* padding: 20rpx; */ |
|
|
/* padding: 20rpx; */ |
|
|
/* background-color: #fff; */ |
|
|
/* background-color: #fff; */ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
</style> |
|
|
</style> |