Browse Source

fix:新增更改密码校验

sunchengjie 9 months ago
parent
commit
877d3fd588
2 changed files with 9 additions and 6 deletions
  1. 1 2
      src/pages/express.vue
  2. 8 4
      src/pages/forgetpassword.vue

+ 1 - 2
src/pages/express.vue

@@ -308,7 +308,6 @@ export default {
 		const res = await getSendInfo({ userId: localStorage.getItem("userId") }, { emulateJSON: true, loading: true, message: '获取寄件人信息...' })
 		if (res.code == 444) {
 			Toast(res.error)
-			Toast(res.msg)
 		} else {
 			this.SendInfoValue = res
 		}
@@ -673,7 +672,7 @@ export default {
 				Toast('寄件成功')
 				this.$router.push('/')
 			} else {
-				this.$toast(res.error)
+				// this.$toast(res.error)
 				this.$toast(res.msg)
 			}
 			$toast.clear()

+ 8 - 4
src/pages/forgetpassword.vue

@@ -14,7 +14,7 @@
 			</div>
 			<div class="item">
 				<van-cell-group>
-					<van-field v-model="password2" type="password" placeholder="请再次输入密码" />
+					<van-field v-model="confirmPassword" type="password" placeholder="请再次输入密码" />
 				</van-cell-group>
 			</div>
 			<div class="btn">
@@ -38,7 +38,7 @@ export default {
 			titlename: "修改密码",
 			name: "",
 			password: "",
-			password2: "",
+			confirmPassword: "",
 			yzm: "",
 			userId: "",
 		}
@@ -49,15 +49,19 @@ export default {
 	},
 	methods: {
 		async save() {
+			if (!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$/.test(this.confirmPassword)) {  
+				Toast('密码需包含大小写字母及数字,长度至少为8位!');
+				return;
+			}
 			if (this.password == '' || this.password == undefined) {
 				Toast('请输入密码!');
 				return;
 			}
-			if (this.password2 == '' || this.password2 == undefined) {
+			if (this.confirmPassword == '' || this.confirmPassword == undefined) {
 				Toast('请再次输入密码!');
 				return;
 			}
-			if (this.password2 != this.password) {
+			if (this.confirmPassword != this.password) {
 				Toast('两次输入密码不相同!');
 				return;
 			}