浏览代码

fix bug
add 登录验证码

dusenyao 3 年之前
父节点
当前提交
82b6af0157
共有 6 个文件被更改,包括 238 次插入43 次删除
  1. 162 36
      package-lock.json
  2. 1 0
      package.json
  3. 16 0
      src/api/app.js
  4. 13 0
      src/api/course.js
  5. 38 4
      src/views/login/index.vue
  6. 8 3
      src/views/teacher/create_course/step_table/SelectBook.vue

文件差异内容过多而无法显示
+ 162 - 36
package-lock.json


+ 1 - 0
package.json

@@ -25,6 +25,7 @@
     "js-base64": "^3.7.2",
     "js-cookie": "^3.0.1",
     "jsplumb": "^2.15.6",
+    "md5": "^2.3.0",
     "normalize.css": "^8.0.1",
     "nprogress": "^0.2.0",
     "vue": "^2.6.14",

+ 16 - 0
src/api/app.js

@@ -141,3 +141,19 @@ export function getContentFile(MethodName, data) {
     params
   });
 }
+
+/**
+ * 得到验证码图像
+ * @param { Object } data
+ * @returns
+ */
+export function GetVerificationCodeImage(data) {
+  const params = getRequestParams('login_control-GetVerificationCodeImage');
+
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_FileServer,
+    params,
+    data
+  });
+}

+ 13 - 0
src/api/course.js

@@ -589,3 +589,16 @@ export function GetMyOrder(data) {
     data
   });
 }
+
+/**
+ * 得到课程教材概要信息
+ * @param { Object } data
+ */
+export function GetCourseBookInfo_Brief(data) {
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params: getRequestParams('teaching-course_manager-GetCourseBookInfo_Brief'),
+    data
+  });
+}

+ 38 - 4
src/views/login/index.vue

@@ -34,6 +34,11 @@
         />
       </el-form-item>
 
+      <el-form-item class="verification-code" prop="verification_code_image_text">
+        <el-input v-model="loginForm.verification_code_image_text" />
+        <el-image v-if="image_content_base64.length > 0" :src="`data:image/jpg;base64,${image_content_base64}`" />
+      </el-form-item>
+
       <el-row>
         <el-col :span="12">
           <el-button
@@ -62,7 +67,9 @@
 </template>
 
 <script>
+import { GetVerificationCodeImage } from '@/api/app';
 import { getConfigInformation } from '@/utils/index';
+import md5 from 'md5';
 
 export default {
   data() {
@@ -85,14 +92,19 @@ export default {
       loginForm: {
         user_name: '',
         password: '',
-        user_type: ''
+        user_type: '',
+        is_password_md5: 'true',
+        verification_code_image_id: '',
+        verification_code_image_text: ''
       },
       loginRules: {
         user_name: [{ trigger: 'blur', validator: validateUsername }],
-        password: [{ trigger: 'blur', validator: validatePassword }]
+        password: [{ trigger: 'blur', validator: validatePassword }],
+        verification_code_image_text: [{ required: true, trigger: 'blur', message: '验证码不能为空' }]
       },
       loading: false,
-      redirect: null
+      redirect: null,
+      image_content_base64: ''
     };
   },
   watch: {
@@ -104,6 +116,11 @@ export default {
   },
   created() {
     this.getConfig();
+
+    GetVerificationCodeImage().then(({ image_id, image_content_base64 }) => {
+      this.loginForm.verification_code_image_id = image_id;
+      this.image_content_base64 = image_content_base64;
+    });
   },
   methods: {
     async getConfig() {
@@ -114,8 +131,10 @@ export default {
         if (valid) {
           this.loginForm.user_type = user_type;
           this.loading = true;
+          const loginForm = { ...this.loginForm };
+          loginForm.password = md5(loginForm.password).toUpperCase();
           this.$store
-            .dispatch('user/login', { loginForm: this.loginForm })
+            .dispatch('user/login', { loginForm })
             .then(() => {
               this.$router.push({ path: this.redirect || '/' });
               this.loading = false;
@@ -159,6 +178,21 @@ export default {
     padding: 160px 35px 0;
     margin: 0 auto;
     overflow: hidden;
+
+    .verification-code {
+      .el-input {
+        width: 120px;
+      }
+
+      .el-image {
+        margin-left: 24px;
+        vertical-align: bottom;
+
+        &__inner {
+          vertical-align: middle;
+        }
+      }
+    }
   }
 
   .login-button {

+ 8 - 3
src/views/teacher/create_course/step_table/SelectBook.vue

@@ -71,7 +71,7 @@
 <script>
 import StepBar from '@/components/StepBar.vue';
 import { PageQueryBookList_SelectBookForCourse } from '@/api/list';
-import { AddBookToCourse, RemoveBookFromCourse } from '@/api/course';
+import { AddBookToCourse, RemoveBookFromCourse, GetCourseBookInfo_Brief } from '@/api/course';
 
 export default {
   name: 'SelectBook',
@@ -134,8 +134,13 @@ export default {
       this.$router.push(`/create_course_step_table/course_info?id=${this.id}&is_template=${this.is_template}`);
     },
     nextStep() {
-      this.$router.push({
-        path: `/create_course_step_table/create_task/${this.id}?is_template=${this.is_template}`
+      GetCourseBookInfo_Brief({ course_id: this.id }).then(({ book_count }) => {
+        if (book_count <= 0) {
+          return this.$message.warning('请至少选择一本教材');
+        }
+        this.$router.push({
+          path: `/create_course_step_table/create_task/${this.id}?is_template=${this.is_template}`
+        });
       });
     }
   }

部分文件因为文件数量过多而无法显示