Browse Source

修改密码验证

hella_online_20241205
lijuncheng 2 months ago
parent
commit
8914a51c54
  1. 25
      src/pages/login/index.vue
  2. 2
      src/pages/setter/index.vue
  3. 59
      src/pages/setter/loginPwdUpdate.vue

25
src/pages/login/index.vue

@ -71,7 +71,7 @@
v-model="code"
style="background-color: lightgray;padding-top: 40rpx;padding-bottom: 40rpx;margin-right: 20rpx;" />
</view> -->
<view class="uni-input-wrapper" >
<view class="uni-input-wrapper">
<input class="" style="height: 80rpx; background-color: #F7F9FF;margin-right: 20rpx;"
placeholder="请输入验证码" type="number" v-model="code" />
</view>
@ -120,7 +120,7 @@
code: "",
uuid: "",
version: "",
needCode:false
needCode: false
}
},
// computed: mapState(['forcedLogin', 'hasLogin']),
@ -132,7 +132,7 @@
storage.clearStorage()
if (process.env.NODE_ENV === 'development') {
this.username = "admin"
this.password = "win123456";
this.password = "CD_win09";
}
uni.setNavigationBarColor({
frontColor: '#ffffff',
@ -158,7 +158,7 @@
},
onLoad() {
if(this.needCode){
if (this.needCode) {
getCaptchaImage().then(res => {
if (res) {
var code = res.data.img;
@ -189,15 +189,13 @@
icon: 'none',
mask: true
})
}
else if (this.needCode&&this.code === '') {
} else if (this.needCode && this.code === '') {
uni.showToast({
title: '验证码不能为空',
icon: 'none',
mask: true
})
}
else {
} else {
// console.log("", this.username, "", this.password, this.tapstyle, this.smloginmsg)
let logininfo = {
username: "",
@ -232,7 +230,7 @@
title: "正在登录",
mask: true
})
try{
try {
var result = await this.$store.dispatch('Login', logininfo);
// await this.$store.dispatch('GetTenantIdInfo', this.tenantName)
console.log(result)
@ -242,7 +240,7 @@
url: '/pages/index/index'
});
uni.setStorageSync('username', this.username);
}catch(e){
} catch (e) {
uni.hideLoading()
this.showErrorMessage(e)
}
@ -262,7 +260,12 @@
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
if (message.includes("密码策略")) {
uni.setStorageSync('username', this.username);
uni.reLaunch({
url: '/pages/setter/loginPwdUpdate'
})
}
}
});
},

2
src/pages/setter/index.vue

@ -143,7 +143,7 @@
}
function modifiedPassWord() {
uni.navigateTo({
url:"./passwordpage"
url:"./loginPwdUpdate"
})
}

59
src/pages/setter/loginPwdUpdate.vue

@ -19,7 +19,9 @@
</template>
<script>
import { loginUpdateUserPwd } from '@/api/request2.js';
import {
loginUpdateUserPwd
} from '@/api/request2.js';
import {
navigateBack,
} from '@/common/basic.js';
@ -36,36 +38,35 @@
oldPassword: {
rules: [{
required: true,
errorMessage: '请输入密码',
}
]
errorMessage: '请输入原密码',
}]
},
// name
password: {
rules: [{
required: true,
errorMessage: '请输入密码',
},
{
minLength: 6,
maxLength: 20,
errorMessage: '密码长度在 {minLength} 到 {maxLength} 个字符',
errorMessage: '请输入新密码',
}
// {
// minLength: 6,
// maxLength: 20,
// errorMessage: ' {minLength} {maxLength} ',
// }
]
},
// email
againPassword: {
rules: [{
required: true,
errorMessage: '请输入密码',
},
{
minLength: 6,
maxLength: 20,
errorMessage: '密码长度在 {minLength} 到 {maxLength} 个字符',
errorMessage: '请输入新密码',
},
// {
// minLength: 6,
// maxLength: 20,
// errorMessage: ' {minLength} {maxLength} ',
// },
{
validateFunction:function(rule,value,data,callback){
validateFunction: function(rule, value, data, callback) {
console.log(value !== data.againPassword)
if (value !== data.againPassword) {
callback('两次输入不同')
@ -90,27 +91,30 @@
// },
//
submit() {
this.$refs.form.validate().then(res=>{
loginUpdateUserPwd(uni.getStorageSync('username'),res.oldPassword,res.password,res.password).then((ress)=>{
this.$refs.form.validate().then(res => {
loginUpdateUserPwd(uni.getStorageSync('username'), res.oldPassword, res.password, res.password)
.then((ress) => {
console.log('返回结果:', ress);
if(ress.data){
this.showCommitSuccessMessage("修改成功")
setTimeout(function (){
if (ress.data) {
uni.showToast({
title: "修改成功"
})
setTimeout(function() {
uni.reLaunch({
url: '../login/index'
})
},2000)
}, 500)
}
}).catch(err =>{
}).catch(err => {
this.$refs.comMessage.showErrorMessage(err)
})
}).catch(err =>{
}).catch(err => {
console.log('表单错误信息:', err);
})
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
navigateBack(1)
})
},
}
@ -118,9 +122,8 @@
</script>
<style>
.content{
.content {
/* padding: 20rpx; */
/* background-color: #fff; */
}
</style>
Loading…
Cancel
Save