jjsp_web/bns/js/login/login.js

71 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 老首页
*/
layui.use(['layer', 'form', 'element'], function(){
form=layui.form;
})
document.onkeydown = function (e) { // 回车提交表单
// 兼容FF和IE和Opera
var theEvent = window.event || e;
var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
if (code == 13) {
login();
}
}
function login(){
//公钥加密
var userName=$("#userName").val();
var password=$("#password").val();
if(userName==null || userName ==''){
layer.msg('请输入用户名', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
return ;
}
if(password==null || password ==''){
layer.msg('请输入密码', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
return ;
}
$.ajax({
url: dataUrl + 'auth/login',
data: {
username:userName,//加密处理
password:password//加密处理
},
async : true,
method:"POST",
success : function(data) {
var code=data.code;
if(code=='200'){
localStorage.setItem("passWay","to-2");
var token=data.data.access_token;
localStorage.setItem("tokens",token);
let jm=sm2Encrypt(data.data.us);
localStorage.setItem("us",jm);
localStorage.setItem("html_type",1);
window.location.href="bns/html/home/home.html";
}else{
layer.msg(data.msg, {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
},error(event, xhr, settings, error){
console.log("网络异常")
}
})
}