Browse Source

修改密码验证

hella_online_20241205
lijuncheng 2 months ago
parent
commit
8914a51c54
  1. 8
      src/api/httpRequest3.js
  2. 61
      src/pages/login/index.vue
  3. 2
      src/pages/setter/index.vue
  4. 185
      src/pages/setter/loginPwdUpdate.vue

8
src/api/httpRequest3.js

@ -48,10 +48,10 @@ function service(options = {}) {
})
}
// if (res.data.code == 1002000008) {
// uni.setStorageSync('username',options.data.username)
// uni.reLaunch({
// url: '/pages/setter/loginPwdUpdate'
// })
// uni.setStorageSync('username',options.data.username)
// uni.reLaunch({
// url: '/pages/setter/loginPwdUpdate'
// })
// }
if (res.data.msg) {
if (res.data.msg.includes('get lock')) {

61
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>
@ -119,8 +119,8 @@
imageSrc: "",
code: "",
uuid: "",
version: "",
needCode:false
version: "",
needCode: false
}
},
// computed: mapState(['forcedLogin', 'hasLogin']),
@ -128,11 +128,11 @@
this.tenantValue = this.tenantArray[0].value
// uni.clearStorageSync()
// uni.clearStorage(); //
storage.clearStorage()
if (process.env.NODE_ENV === 'development') {
this.username = "admin"
this.password = "win123456";
this.password = "CD_win09";
}
uni.setNavigationBarColor({
frontColor: '#ffffff',
@ -157,21 +157,21 @@
}
},
onLoad() {
if(this.needCode){
getCaptchaImage().then(res => {
if (res) {
var code = res.data.img;
let base64 = 'data:image/jpeg;base64,' + code
// console.log("", base64)
this.imageSrc = base64.replace(/[\r\n]/g, "")
this.uuid = res.data.uuid
}
}).catch(error => {
this.showErrorMessage(error);
})
onLoad() {
if (this.needCode) {
getCaptchaImage().then(res => {
if (res) {
var code = res.data.img;
let base64 = 'data:image/jpeg;base64,' + code
// console.log("", base64)
this.imageSrc = base64.replace(/[\r\n]/g, "")
this.uuid = res.data.uuid
}
}).catch(error => {
this.showErrorMessage(error);
})
}
this.getAppVersion()
},
methods: {
@ -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,11 +240,11 @@
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'
})
}
}
});
},
@ -275,8 +278,8 @@
this.uuid = res.data.uuid
}
}).catch(error => {
this.showErrorMessage(error);
})
this.showErrorMessage(error);
})
},
getAppVersion() {
const systemInfo = uni.getSystemInfoSync();

2
src/pages/setter/index.vue

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

185
src/pages/setter/loginPwdUpdate.vue

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