Browse Source

电子证照查询bug修改

psj 9 months ago
parent
commit
ef3e0e34f8
1 changed files with 43 additions and 10 deletions
  1. 43 10
      src/views/home/Login.vue

+ 43 - 10
src/views/home/Login.vue

@@ -20,7 +20,10 @@
                     <img src="../../assets/imgs/login/验证码.png" />
                 </div>
                 <input  type="text"  v-model="loginForm.identifyingCode" placeholder="请输入验证码" class="input_type" maxlength="40" />
-                <canvas @click="draw" id="myCanvas" width="90" height="40"></canvas>
+                <img  :src="imageUrl" @click="refreshImage" width="100" height="40"
+                      alt="Image"
+                      style="cursor: pointer;">
+<!--                <canvas @click="draw" id="myCanvas" width="90" height="40"></canvas>-->
             </div>
             <div id="submitBtn_div">
                 <el-button
@@ -108,11 +111,14 @@
 <script>
     import {MessageBox} from "element-ui";
     import {Base64} from "js-base64";
+    // import axios from 'axios';
 
 
     export default {
         data() {
             return {
+                baseURL: this.$baseURL,
+                imageUrl: '', // 初始图片地址为空,待点击时加载
                 canvas: null,
                 context: null,
                 message_text:null,
@@ -170,9 +176,6 @@
                 if(this.loginForm.identifyingCode == "" || this.loginForm.identifyingCode == null){
                     this.message_text = "请输入验证码!";
                 }
-                if(this.show_num.join("") != this.loginForm.identifyingCode.toString().toLocaleLowerCase()){
-                    this.message_text = "验证码输入错误!";
-                }
 
                 if(this.loginForm.passWord == "" || this.loginForm.passWord == null){
                     this.message_text = "请输入密码!";
@@ -181,7 +184,8 @@
                 if(this.loginForm.userName == "" || this.loginForm.userName == null){
                     this.message_text = "请输入用户名!";
                 }
-                this.draw();
+                //this.refreshImage();
+                // this.draw();
                 if(this.message_text != null){
                     MessageBox.alert(this.message_text, '提示', {
                         confirmButtonText: '确定'
@@ -195,11 +199,13 @@
                         "username":this.loginForm.userName,
                         "password":Base64.encode(this.loginForm.passWord),
                         "type":"10",
+                        "verifyCode":this.loginForm.identifyingCode
                     }
                 }).then(response => {
                     //var result = eval("(" + data.msg + ")");
                     var result =response.data.msg;
                     if (result.length == 0) {
+                        this.refreshImage();
                         MessageBox.alert('获取登录信息失败!', '提示', {
                             confirmButtonText: '确定'
                         });
@@ -207,6 +213,7 @@
                     }
                     var rowcount = result[0].TotalRowCount;
                     if (rowcount != "1") {
+                        this.refreshImage();
                         MessageBox.alert('用户名或密码错误!', '提示', {
                             confirmButtonText: '确定'
                         });
@@ -214,6 +221,7 @@
                     }
                     var rows = result[0].Rows;
                     if (rows.length != 1) {
+                        this.refreshImage();
                         MessageBox.alert('用户名或密码错误!', '提示', {
                             confirmButtonText: '确定'
                         });
@@ -304,7 +312,7 @@
             },
             selectConfigModuleByRole(){//判断当前页面上的所有模块 当前角色是否配置使用
                 this.$request({
-                    url:"http://10.81.66.9:9250/ptjkInterface/selectAllZymlRoleModuleByRoleCode?appkey="+localStorage.getItem("ywtb_userkeycode"),
+                    url:"/ptjkInterface/selectAllZymlRoleModuleByRoleCode?appkey="+localStorage.getItem("ywtb_userkeycode"),
                     method:'post',
                     data:{
                         "ROLE_ID":localStorage.getItem("ywtb_role")//暂时使用测试角色  平台管理
@@ -323,7 +331,7 @@
             },
             selectConfigButtonByRole_01(tempConfigButtonMap){
                 this.$request({
-                    url:"http://10.81.66.9:9250/ptjkInterface/selectConfigButtonByRole?appkey="+localStorage.getItem("ywtb_userkeycode"),
+                    url:"/ptjkInterface/selectConfigButtonByRole?appkey="+localStorage.getItem("ywtb_userkeycode"),
                     method:'post',
                     data:{
                         "ROLE_ID":localStorage.getItem("ywtb_role")//暂时使用测试角色  平台管理
@@ -386,17 +394,39 @@
                     context.lineTo(x + 1, y + 1);
                     context.stroke();
                 }
-            },randomColor() {//得到随机的颜色值
+            },
+            randomColor() {//得到随机的颜色值
                 return "#11E3FF";
                         // var r = Math.floor(Math.random() * 256);
                         // var g = Math.floor(Math.random() * 256);
                         // var b = Math.floor(Math.random() * 256);
                         // return "rgb(" + r + "," + g + "," + b + ")";
-                    }
+                    },
+            refreshImage(){
+                // 生成一个随机数作为查询参数,以强制浏览器刷新图片
+                // const randomParam = Math.random();
+                // this.imageUrl = `${this.baseURL}/user/randomImageCode_v1?${randomParam}`;
+                this.$request({
+                    url: '/user/randomImageCode_v1',
+                    method: 'get',
+                    responseType: 'arraybuffer'
+                })
+                    .then(response => {
+                        // 将获取到的图片数据转换为base64格式
+                        const imageData = `data:image/png;base64,${Buffer.from(response.data, 'binary').toString('base64')}`;
+                        this.imageUrl = imageData; // 将base64图片数据存储到Vue组件的imageUrl变量中
+                    })
+                    .catch(error => {
+                        console.error('Failed to load image:', error);
+                    });
+
+
+            }
         },
         mounted() {
             this.canvas = document.getElementById("myCanvas");
-            this.draw();
+            // this.draw();
+            this.refreshImage();
             this.loadLogin();
             //this.context = this.canvas.getContext("2d");
 
@@ -474,6 +504,9 @@
         opacity: 0.4;
         border-radius: 6px;
     }
+    .input_co_type img{
+        background-color: transparent;
+    }
     .input_type{
         height:48px;
         border: none;