<template>
|
<el-form
|
label-position="top"
|
class="params-dialog">
|
<el-row>
|
<el-col :span="6"><div style="visibility: hidden">1</div></el-col>
|
<el-col :span="12">
|
<el-form-item label="用户名">
|
<el-input
|
type="text"
|
placeholder="请输入用户名"
|
resize="none"
|
v-model="userName"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="6"></el-col>
|
</el-row>
|
<div class="form-footer">
|
<three-btn @click="confirmBindUser">绑定用户</three-btn>
|
</div>
|
</el-form>
|
</template>
|
|
<script>
|
import SoftUKey from "@/assets/js/tools/SoftUKey";
|
import SoftKey3W from "@/assets/js/Syunew3";
|
export default {
|
name: "BindStep3",
|
props: {
|
id: {
|
type: String,
|
default: ""
|
}
|
},
|
data() {
|
return {
|
userName: "",
|
softUKey: new SoftUKey(SoftKey3W)
|
}
|
},
|
methods: {
|
confirmBindUser() {
|
let userName = this.userName.trim();
|
let id = this.id.trim();
|
if(!userName) {
|
this.$layer.msg("用户名不能为空");
|
return;
|
}
|
if(!id) {
|
this.$layer.msg("uKey的信息不能为空");
|
return;
|
}
|
this.$confirm('确定绑定'+this.userName,'系统提示', {
|
type: 'info',
|
}).then(()=>{
|
this.checkUser(userName, id);
|
}).catch(error=>{})
|
},
|
/**
|
* 校验用户是否已经绑定用户
|
* @param name 用户名
|
* @param id ukey的信息
|
*/
|
checkUser(name, id) {
|
let loading = this.$layer.loading();
|
this.$apis.uKey.getUKeyByUName(name).then(res=>{
|
let rs = JSON.parse(res.data.result);
|
if(rs.code == 1) {
|
this.$layer.msg(name+"已经绑定ukey");
|
// 关闭等待框
|
this.$layer.close(loading);
|
}else if(rs.code == -1){
|
this.$layer.msg(name+"用户不存在,请检查输入的用户名");
|
// 关闭等待框
|
this.$layer.close(loading);
|
}else {
|
this.softUKey.setUserName(name, this.setUserNameRs);
|
// 关闭等待框
|
this.$layer.close(loading);
|
|
}
|
}).catch(error=>{
|
// 关闭等待框
|
this.$layer.close(loading);
|
console.log(error);
|
});
|
},
|
setUserNameRs(result) {
|
let name = result.userName;
|
let id = this.id.trim();
|
let publicX = result.PubKeyX;
|
let publicY = result.PubKeyY;
|
let loading = this.$layer.loading();
|
this.bindUkey(name, id, publicX, publicY, loading);
|
},
|
/**
|
* 绑定用户
|
* @param name 用户名
|
* @param id ukey的信息
|
* @param loading 加载等待框
|
*/
|
bindUkey(name, id, publicX, publicY, loading) {
|
if(!loading) {
|
loading = this.$layer.loading();
|
}
|
this.$apis.uKey.bindUKey(name, id, publicX, publicY).then(res=>{
|
let rs = JSON.parse(res.data.result);
|
if(rs.code == 1) {
|
this.$layer.msg('绑定成功');
|
this.$emit('next');
|
}else {
|
this.$layer.msg('绑定失败');
|
}
|
// 关闭等待框
|
this.$layer.close(loading);
|
}).catch(error=>{
|
// 关闭等待框
|
this.$layer.close(loading);
|
console.log(error);
|
});
|
}
|
},
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|