Browse Source

修改测试的bug

plg 4 months ago
parent
commit
788d78172e
4 changed files with 73 additions and 11 deletions
  1. 6 1
      src/views/Community.vue
  2. 1 0
      src/views/Plan.vue
  3. 29 5
      src/views/Register.vue
  4. 37 5
      src/views/UpdatePas.vue

+ 6 - 1
src/views/Community.vue

@@ -233,10 +233,14 @@ const pubMsg = async () => {
     // pageNum.value = 1
     // getData()
     if (res.code == 200) {
-        list.value.push(res.data)
+        list.value.unshift(res.data)
         des_input.value = ''
         isLock.value = false
         pub_visible.value = false
+        ElMessage({
+            message: res.msg,
+            type: 'success'
+        })
     } else {
         ElMessage({
             message: res.msg,
@@ -630,6 +634,7 @@ label {
     background-repeat: no-repeat;
     background-size: contain;
     background-color: #B3F1DA; //估计是需要动态
+    flex: 1;
 
     //获取屏幕宽度home_header_out 这个div的宽度--然后宽度*1000再除1920即为当前div的宽度
     .home_header_inner {

+ 1 - 0
src/views/Plan.vue

@@ -363,6 +363,7 @@ onUnmounted(() => {
     background-repeat: no-repeat;
     background-size: contain;
     background-color: #B3F1DA;
+    flex: 1;
 
     //获取屏幕宽度home_header_out 这个div的宽度--然后宽度*1000再除1920即为当前div的宽度
     .home_header_inner {

+ 29 - 5
src/views/Register.vue

@@ -65,6 +65,12 @@ const loginFun = () => {
     router.push({ name: 'login' })
 
 }
+
+//校验密码的方法
+const validatePassword = (password: string) => {
+    const regex = /^[a-zA-Z0-9!@#$%^&*(),.?":{}|<>]+$/;
+    return regex.test(password);
+}
 //注册方法
 const registerFun = async () => {
     if (isLock.value) {
@@ -97,15 +103,15 @@ const registerFun = async () => {
 
     if (account.value == '') {
         ElMessage({
-            message: '请填写账号',
+            message: '请输入学号/编号',
             type: 'warning'
         })
         isLock.value = false
         return
     }
-    if (!/^[A-Za-z0-9]+$/.test(account.value)) {
+    if (!/^[A-Za-z0-9]{3,18}$/.test(account.value)) {
         ElMessage({
-            message: '账号只允许输入数字和英文',
+            message: '学号/编号只允许输入数字和英文且长度为3到18位',
             type: 'warning'
         })
         isLock.value = false
@@ -143,9 +149,17 @@ const registerFun = async () => {
         isLock.value = false
         return
     }
-    if (password.value.length < 6) {
+    if (!validatePassword(password.value)) {
+        ElMessage({
+            message: '密码规则为数字或英文或字符,可任意组合。',
+            type: 'warning'
+        })
+        isLock.value = false
+        return
+    }
+    if (password.value.length < 6 || password.value.length > 18) {
         ElMessage({
-            message: '密码长度最小6位',
+            message: '密码为6到18位',
             type: 'warning'
         })
         isLock.value = false
@@ -159,6 +173,15 @@ const registerFun = async () => {
         isLock.value = false
         return
     }
+    if (!validatePassword(comPassword.value)) {
+        ElMessage({
+            message: '密码规则为数字或英文或字符,可任意组合。',
+            type: 'warning'
+        })
+        isLock.value = false
+        return
+    }
+
     if (comPassword.value != password.value) {
         ElMessage({
             message: '两次密码输入不一致',
@@ -168,6 +191,7 @@ const registerFun = async () => {
         return
     }
 
+
     queryOrgName()
     //开始组织参数
     let params = {

+ 37 - 5
src/views/UpdatePas.vue

@@ -49,10 +49,15 @@ onUnmounted(() => {
 
 })
 
-
+//校验密码的方法
+const validatePassword = (password: string) => {
+    const regex = /^[a-zA-Z0-9!@#$%^&*(),.?":{}|<>]+$/;
+    return regex.test(password);
+}
 
 //登录方法
 const loginFun = async () => {
+    debugger;
     if (isLock.value) {
         return
     }
@@ -63,6 +68,7 @@ const loginFun = async () => {
             message: '当前密码不能为空',
             type: 'warning'
         })
+        isLock.value = false
         return
     }
     if (password.value == '') {
@@ -70,12 +76,21 @@ const loginFun = async () => {
             message: '密码不能为空',
             type: 'warning'
         })
+        isLock.value = false
+        return
+    } else if (!validatePassword(password.value)) {
+        ElMessage({
+            message: '密码规则为数字或英文或字符,可任意组合。',
+            type: 'warning'
+        })
+        isLock.value = false
         return
-    } else if (password.value.length < 6) {
+    } else if (password.value.length < 6 || password.value.length > 18) {
         ElMessage({
-            message: '密码最少6位',
+            message: '密码为6到18位',
             type: 'warning'
         })
+        isLock.value = false
         return
     }
 
@@ -84,12 +99,21 @@ const loginFun = async () => {
             message: '确认密码不能为空',
             type: 'warning'
         })
+        isLock.value = false
         return
-    } else if (comPassword.value.length < 6) {
+    } else if (!validatePassword(comPassword.value)) {
         ElMessage({
-            message: '确认密码最少6位',
+            message: '确认密码规则为数字或英文或字符,可任意组合。',
             type: 'warning'
         })
+        isLock.value = false
+        return
+    } else if (comPassword.value.length < 6 || comPassword.value.length > 18) {
+        ElMessage({
+            message: '确认密码为6到18位',
+            type: 'warning'
+        })
+        isLock.value = false
         return
     }
 
@@ -98,6 +122,7 @@ const loginFun = async () => {
             message: '两次密码输入不一致',
             type: 'warning'
         })
+        isLock.value = false
         return
     }
 
@@ -115,6 +140,13 @@ const loginFun = async () => {
         // userInfo.saveToken(res.data.token)
         // userInfo.saveUserInfo(res.data.user)
         ElMessage({ message: `${res.msg}`, type: 'success' })
+
+        //修改成功后
+        //清空缓存
+        //跳转到登录页面
+        userInfo.clearUserInfo()
+        //跳转到首页
+        router.push({ name: 'login' })
     } else {
         ElMessage({ message: `${res.msg}`, type: 'error' })
     }