From 457f9c817adef8b003ee6379f493798bae5cbb69 Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: Mon, 19 May 2025 09:31:19 +0800
Subject: [PATCH] 修改
---
src/views/Login.vue | 183 +++++++++++++++++++++++++++++----------------
1 files changed, 119 insertions(+), 64 deletions(-)
diff --git a/src/views/Login.vue b/src/views/Login.vue
index 9eb9abe..7d00b20 100644
--- a/src/views/Login.vue
+++ b/src/views/Login.vue
@@ -83,7 +83,32 @@
<a-checkbox :checked="saveAccount" style="color:#fff;" @change="isSave">记住密码</a-checkbox>
<!-- <a style="float: right">忘记密码</a>-->
</div>
- <a-form-item style="text-align: center">
+ <div style="margin-bottom: 20px;height: auto;width: 100%;background-color: white;border-radius: 5px">
+ <div style="margin-left: 10px;display: flex;align-items: center;justify-content: space-between;padding: 0px 12px;">
+ <div v-if="keyMsg">
+ <a-icon style="color: lightcoral" type="exclamation-circle"/>
+ <span style="margin-left: 5px;line-height: 45px;font-size: 16px;color: lightcoral">{{keyMsg}}</span>
+ </div>
+ <div v-else>
+ <a-icon style="color: #52c41a" type="check-circle"/>
+ <span style="margin-left: 5px;line-height: 45px;font-size: 16px;color: #52c41a">加密证书检测成功</span>
+ </div>
+ <a-button
+ type="primary"
+ html-type="submit"
+ style="width: 20%;"
+ size="small"
+ @click="checkKey"
+ >
+ 重新检测
+ </a-button>
+ </div>
+ </div>
+ <div style="margin-bottom: 20px;float: right;" >
+ <span style="color: #1890ff;cursor: pointer" @click="downLoadLKey">驱动下载</span>
+ </div>
+
+ <div style="text-align: center">
<a-button
type="primary"
html-type="submit"
@@ -95,7 +120,7 @@
>
登录
</a-button>
- </a-form-item>
+ </div>
<center><p>技术支持:技术保障部</p></center>
</a-form-model>
</div>
@@ -107,8 +132,7 @@
import { login, getMenuAdmin } from "@/api/login";
import Cookies from 'js-cookie';
import {Base64} from "js-base64";
-import {getAreaWithUserIfo} from "@/api/user";
-
+import SoftKey3W from './Syunew3W.js'
export default {
name: "login",
@@ -120,13 +144,18 @@
// form: this.$form.createForm(this),
form: {
name: '',
- pwd: ''
+ pwd: '',
+ keyId:'',//锁id
+ keyUserName:'',//锁中的用户身份
+ returnEncData:'',//签名数据
+ rnd:"123"//随机字符
},
rules: {
name: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
pwd: [{ required: true, message: '请输入用户密码', trigger: 'blur' }]
},
- menu: []
+ menu: [],
+ keyMsg: '未检测到加密证书,请确保已连接',
};
},
created() {
@@ -134,8 +163,18 @@
// this.form.validateFields();
// });
this.hasUserCodeOrPassword()
+ //检测key
+ this.checkKey()
},
methods: {
+ downLoadLKey () {
+ console.log('222')
+ const { href } = this.$router.resolve({
+ path: '/downKey'
+ })
+ window.open(href,'_blank')
+
+ },
hasUserCodeOrPassword(){
if (localStorage.getItem('userName') && localStorage.getItem('userPassword')) {
this.form.name = localStorage.getItem('userName')
@@ -143,22 +182,91 @@
this.saveAccount = true
}
},
+ async checkKey() {
+ let mSoftKey3A = new SoftKey3W();//注意,由于USB的操作是异步的,所以所有函数的调用前必须加await !!!!!!!!!
+ let DevicePath = await mSoftKey3A.FindPort(1);//'查找是否存在多把加密锁
+ if (mSoftKey3A.GetLastError() == 0) {
+ this.keyMsg = "系统发现有2把及以上的加密证书"
+ return false
+ }
+ DevicePath = await mSoftKey3A.FindPort(0);//'查找是否存在加密锁
+ if (mSoftKey3A.GetLastError() != 0) {
+ this.keyMsg = "未检测到加密证书,请确保已连接"
+ return false
+ }
+ this.keyMsg = ""
+ },
isSave(e){
const t = this
t.saveAccount = !t.saveAccount
},
+ async checkUsbkeyData(){
+ let mSoftKey3A = new SoftKey3W();//注意,由于USB的操作是异步的,所以所有函数的调用前必须加await !!!!!!!!!
+ let DevicePath = await mSoftKey3A.FindPort(1);//'查找是否存在多把加密锁
+ console.log(mSoftKey3A,'mSoftKey3A')
+ if (mSoftKey3A.GetLastError() == 0) {
+ this.keyMsg = "系统发现有2把及以上的加密证书"
+ this.$message.warning( "系统发现有2把及以上的加密证书");
+ return false
+ }
+ DevicePath = await mSoftKey3A.FindPort(0);//'查找是否存在加密锁
+ if (mSoftKey3A.GetLastError() != 0) {
+ this.keyMsg = "未检测到加密证书,请确保已连接"
+ this.$message.warning( "未检测到加密证书,请确保已连接");
+ return false
+ }
+ console.log(DevicePath,'devpathhh')
+ //'读取锁的唯一ID
+ this.form.keyId=await mSoftKey3A.GetChipID(DevicePath);
- handleSubmit() {
+ if( mSoftKey3A.GetLastError()!= 0 )
+ {
+ this.$message.warning("返回芯片唯一ID时出现错误,错误码为:"+mSoftKey3A.GetLastError().toString())
+ return false
+ }
+ console.log(this.form.keyId,'this.form.keyId')
+ //从锁中取出用户身份,与签名后的数据一并送到服务端进行验证。以验证用户身份
+ this.form.keyUserName=await mSoftKey3A.GetSm2UserName(DevicePath);
+
+ if( mSoftKey3A.GetLastError()!= 0 )
+ {
+ this.$message.warning( "返回用户身份时出现错误,错误码为:"+mSoftKey3A.GetLastError().toString());
+ return false
+ }
+ console.log(this.form.keyUserName,'this.form.keyUserName')
+ //使用默认的PIN码
+ var Pin="123"
+ //这里使用锁中的私钥对身份-用户名及消息-随机数的进行数字签名,使用默认的PIN码,返回签名后的数据
+ this.form.rnd=String(parseInt(Math.random()*(65536+1),10));
+ this.form.returnEncData=await mSoftKey3A.YtSign(this.form.rnd,Pin,DevicePath);
+ if( mSoftKey3A.GetLastError()!= 0 )
+ {
+ this.$message.warning( "进行签名时出现错误,错误码为:"+mSoftKey3A.GetLastError().toString());
+ return false
+ }
+ if(this.form.name!=this.form.keyUserName){
+ this.$message.warning( "用户身份不一致,无法登陆");
+ return false
+ }
+ console.log(this.form.returnEncData,'this.form.returnEncData')
+ console.log(this.form,'this.form')
+ return true
+ },
+
+ async handleSubmit() {
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
+ let checkUsb=await this.checkUsbkeyData()
+ if(!checkUsb){
+ return
+ }
this.isLoading = true
const res = await login(this.form)
if (res.data.code === 100) {
Cookies.set('resTk', res.data.data.tk);
Cookies.set('resUid', res.data.data.uid);
Cookies.set('userInfo',JSON.stringify(res.data.data),{expires: 7})
- await this.getAreaUsers(res.data.data.districtId)
if (this.saveAccount) {
localStorage.setItem('userName', this.form.name)
localStorage.setItem('userPassword', Base64.encode(this.form.pwd))
@@ -178,59 +286,6 @@
});
},
- async getAreaUsers(districtId) {
- let t = this
- let res = await getAreaWithUserIfo()
- if (res.data.code == 100) {
- if (res.data.data) {
- t.userTitTree(res.data.data)
- const areaUsers = t.findNodeById(res.data.data, districtId).children
- localStorage.removeItem('areaUsers')
- localStorage.setItem('areaUsers',JSON.stringify(areaUsers))
- } else {
- console.log('暂无数据')
- }
- } else {
- this.$message.warning(res.data.msg);
- }
- },
-
- // 根据id查对象
- findNodeById(data, value) {
- for (const node of data) {
- if (node.id === value) {
- return node;
- }
- if (node.children) {
- const foundNode = this.findNodeById(node.children, value);
- if (foundNode) {
- return foundNode;
- }
- }
- }
- return null;
- },
-
- // 将树状数据name字段放入users的姓名电话
- userTitTree(treeData) {
- for (const node of treeData) {
- if (node.users) {
- node.users = node.users.filter(i => i.roleId == 3)
- node.users = node.users.map((i) => {
- return {
- ...i,
- unittype: node.type,
- districtId: node.id
- }
- })
- node.name = node.name + '(' + node.users.map(i => i.realName + ' ' + i.phone).join(',') + ')'
- }
- if (node.children) {
- this.userTitTree(node.children)
- }
- }
- return treeData
- }
},
};
</script>
@@ -266,11 +321,11 @@
h1{font-size: 48px;color:#fff;}
}
.login {
-
+
.login-form {
width: 400px;
- margin: 60px auto 0px;
-
+ margin: 60px auto 0px;
+
}
}
.ant-tabs{
--
Gitblit v1.9.2