feat(login): 增强密码安全性和用户提示
- 添加用户名显示和旧密码验证 -增强新密码复杂性要求 - 优化密码修改成功后的提示和跳转逻辑 - 新增弱密码登录时的提示和强制修改密码功能master
							parent
							
								
									b32ed7f9dc
								
							
						
					
					
						commit
						ae2a7c28af
					
				|  | @ -5,9 +5,9 @@ | ||||||
| 			<block slot="content">设置密码</block> | 			<block slot="content">设置密码</block> | ||||||
| 		</cu-custom> | 		</cu-custom> | ||||||
| 		<view class="register"> | 		<view class="register"> | ||||||
| 			<view class="reg-title mb40"> |       <view class="user_main"> | ||||||
| 				<text>修改密码</text> |         <view >账号:{{USERNAME}}</view> | ||||||
| 			</view> |       </view> | ||||||
| 			<view class="reg-form"> | 			<view class="reg-form"> | ||||||
| 				<view class="reg-input"> | 				<view class="reg-input"> | ||||||
| 					<input password @input="oldInpPwd" placeholder="旧密码" name="input"></input> | 					<input password @input="oldInpPwd" placeholder="旧密码" name="input"></input> | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
| 				</view> | 				</view> | ||||||
| 			</view> | 			</view> | ||||||
| 			<view class="reg-title"> | 			<view class="reg-title"> | ||||||
| 				<text class="text-gray">需8-20位字符</text> |         <text class="text-gray">需8-20位字母大小写、数字、字符混合</text> | ||||||
| 			</view> | 			</view> | ||||||
| 			<view class="flex flex-direction mt50"> | 			<view class="flex flex-direction mt50"> | ||||||
| 				<button :loading="buttonloading" class="cu-btn bg-blue lg round" @click="updateUserPwd()">提交</button> | 				<button :loading="buttonloading" class="cu-btn bg-blue lg round" @click="updateUserPwd()">提交</button> | ||||||
|  | @ -44,6 +44,7 @@ | ||||||
| 				nowPwd :'', | 				nowPwd :'', | ||||||
| 				buttonloading: false, | 				buttonloading: false, | ||||||
| 				confirmPwd :'', | 				confirmPwd :'', | ||||||
|  |         USERNAME: loginUser.USERNAME | ||||||
| 			} | 			} | ||||||
| 		}, | 		}, | ||||||
| 		methods: { | 		methods: { | ||||||
|  | @ -112,6 +113,15 @@ | ||||||
| 					}); | 					}); | ||||||
| 					return | 					return | ||||||
| 				} | 				} | ||||||
|  |         var reg1 = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*.])[\da-zA-Z~!@#$%^&*.]{8,}$/ | ||||||
|  |         if (!reg1.test(_this.nowPwd)) { | ||||||
|  |           uni.showToast({ | ||||||
|  |             icon: 'none', | ||||||
|  |             title: '密码必须包含大小写字母、数字、特殊符号', | ||||||
|  |             duration: 2000 | ||||||
|  |           }); | ||||||
|  |           return | ||||||
|  |         } | ||||||
| 				this.buttonloading = true | 				this.buttonloading = true | ||||||
| 				uni.request({ | 				uni.request({ | ||||||
| 					url: basePath +'/app/user/editUserPwd' , | 					url: basePath +'/app/user/editUserPwd' , | ||||||
|  | @ -132,16 +142,31 @@ | ||||||
| 						this.buttonloading = false | 						this.buttonloading = false | ||||||
| 						if (res.data != null) { | 						if (res.data != null) { | ||||||
| 							var result = res.data.result; | 							var result = res.data.result; | ||||||
| 							if ("success" == result) { |               var Code = res.data.code; | ||||||
| 								uni.showToast({ |               console.log(res.data.code) | ||||||
| 									title: "密码修改成功", |               if ("success" === result) { | ||||||
| 									duration: 1000 |                 if("9999" === Code){ | ||||||
| 								}); |                   uni.showToast({ | ||||||
| 								uni.navigateTo({ |                     icon: 'none', | ||||||
| 										url: '/pages/login/home', |                     title: "旧密码错误", | ||||||
| 								}); |                     duration: 2000 | ||||||
|  |                   }); | ||||||
|  |                 }else{ | ||||||
|  |                   uni.showToast({ | ||||||
|  |                     title: "密码修改成功", | ||||||
|  |                     duration: 1500, // 适当延长显示时间 | ||||||
|  |                     success: function() { | ||||||
|  |                       // 使用 setTimeout 确保提示框完全显示后再跳转 | ||||||
|  |                       setTimeout(function() { | ||||||
|  |                         uni.navigateTo({ | ||||||
|  |                           url: '/pages/login/home', | ||||||
|  |                         }); | ||||||
|  |                       }, 1500); // 延迟时间与 duration 一致或略长 | ||||||
|  |                     } | ||||||
|  |                   }); | ||||||
|  |                 } | ||||||
| 
 | 
 | ||||||
| 							} else if ("usererror" == result) { |               } else if ("usererror" === result) { | ||||||
| 								uni.showToast({ | 								uni.showToast({ | ||||||
| 									icon: 'none', | 									icon: 'none', | ||||||
| 									title: "密码有误", | 									title: "密码有误", | ||||||
|  | @ -179,4 +204,13 @@ | ||||||
| 	page{ | 	page{ | ||||||
| 		background-color: #FFFFFF; | 		background-color: #FFFFFF; | ||||||
| 	} | 	} | ||||||
|  |   .user_main{ | ||||||
|  |     width: 100%; | ||||||
|  |     padding:30upx 20upx ; | ||||||
|  |     background: #d8e9ff; | ||||||
|  |     border-radius: 10upx; | ||||||
|  |     box-sizing: border-box; | ||||||
|  |     margin-bottom: 40upx; | ||||||
|  |     font-size: 30upx; | ||||||
|  |   } | ||||||
| </style> | </style> | ||||||
|  |  | ||||||
|  | @ -271,13 +271,28 @@ | ||||||
| 							title: res.data.msg, | 							title: res.data.msg, | ||||||
| 							duration: 2000 | 							duration: 2000 | ||||||
| 						}); | 						}); | ||||||
| 						if ("success" == result) { | 						if ("success" === result) { | ||||||
| 							setloginUserId(res.data.USER_ID); | 							setloginUserId(res.data.USER_ID); | ||||||
| 							setCorpinfoId(res.data.CORPINFO_ID); | 							setCorpinfoId(res.data.CORPINFO_ID); | ||||||
| 							setDeptId(res.data.DEPARTMENT_ID); | 							setDeptId(res.data.DEPARTMENT_ID); | ||||||
| 							setDeptLevel(res.data.DEPARTMENT_LEVEL); | 							setDeptLevel(res.data.DEPARTMENT_LEVEL); | ||||||
| 							setIsRest(res.data.ISREST); | 							setIsRest(res.data.ISREST); | ||||||
| 							setloginUser(res.data); | 							setloginUser(res.data); | ||||||
|  |               if(res.data.passwordType === '0'){ | ||||||
|  |                 uni.showToast({ | ||||||
|  |                   icon: 'none', | ||||||
|  |                   title: "登录的密码强度为弱,请修改密码!", | ||||||
|  |                   duration: 2000 // 显示2秒 | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |                 // 延迟2000ms后再执行页面跳转 | ||||||
|  |                 setTimeout(() => { | ||||||
|  |                   uni.navigateTo({ | ||||||
|  |                     url: '/pages/login/forget/forget-reset' | ||||||
|  |                   }); | ||||||
|  |                 }, 2000); // 延迟时间必须大于等于toast的duration | ||||||
|  |                 return | ||||||
|  |               } | ||||||
| 							uni.setStorage({key: 'USER', data: res.data}); | 							uni.setStorage({key: 'USER', data: res.data}); | ||||||
| 						  	const remember = {} | 						  	const remember = {} | ||||||
| 						  	remember.username = 	userName | 						  	remember.username = 	userName | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue