|
|
<!DOCTYPE html>
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
<title>绑定账户</title>
|
|
|
<link href="/dsssoserver/css/binduser.css" rel="stylesheet" type="text/css">
|
|
|
</head>
|
|
|
<body>
|
|
|
<section id="getintouch">
|
|
|
<div class="container" style="border-bottom: 0;">
|
|
|
<h1>
|
|
|
<span>绑定账户</span>
|
|
|
</h1>
|
|
|
</div>
|
|
|
<div class="container">
|
|
|
<form class="contact">
|
|
|
<div class="row clearfix">
|
|
|
<div class="lbl">
|
|
|
<label>用户名:</label>
|
|
|
</div>
|
|
|
<div class="ctrl">
|
|
|
<input type="text" id="usernameTxt" value="sys1" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="row clearfix">
|
|
|
<div class="lbl">
|
|
|
<label>密   码:</label>
|
|
|
</div>
|
|
|
<div class="ctrl">
|
|
|
<input type="password" id="passwordTxt" value="123456" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div id="errInfo" style="color:#F00;font-size:12px"></div>
|
|
|
<div class="row clearfix">
|
|
|
<div class="span10 offset2">
|
|
|
<input type="button" id="bind" class="submit" value="绑 定">
|
|
|
</div>
|
|
|
</div>
|
|
|
</form>
|
|
|
</div>
|
|
|
</section>
|
|
|
</body>
|
|
|
<script src="/dsssoserver/js/jquery-3.6.0.min.js" type="text/javascript"></script>
|
|
|
<script src="/dsssoserver/js/aes.js" type="text/javascript"></script>
|
|
|
<script src="/dsssoserver/js/base64.js" type="text/javascript"></script>
|
|
|
<script type="text/javascript">
|
|
|
$(function() {
|
|
|
var openId = Base64.decode(getUrlParam("open_id"));
|
|
|
var typeId = getUrlParam("type_id");
|
|
|
|
|
|
|
|
|
|
|
|
$("#bind").click(function() {
|
|
|
|
|
|
var userName = $("#usernameTxt").val();
|
|
|
var passWord = $("#passwordTxt").val();
|
|
|
var sessionId;
|
|
|
var personId;
|
|
|
|
|
|
var personInfo = getUserInfo(userName, passWord, typeId);
|
|
|
if (personInfo.success) {
|
|
|
sessionId = personInfo.sessionId;
|
|
|
personId = personInfo.personId;
|
|
|
} else {
|
|
|
$("#errInfo").html(personInfo.msg);
|
|
|
return
|
|
|
}
|
|
|
|
|
|
var bindInfo = bindUser(personId, openId, typeId);
|
|
|
if (bindInfo.success) {
|
|
|
window.close();
|
|
|
} else {
|
|
|
$("#errInfo").html("绑定异常!");
|
|
|
return;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据用户名密码获取用户信息
|
|
|
function getUserInfo(userName, passWord, typeId) {
|
|
|
var personInfo;
|
|
|
$.ajax({
|
|
|
type : "GET",
|
|
|
dataType : "json",
|
|
|
url : "/dsssoserver/third/getUserInfoByUserNamePwd",
|
|
|
data : {
|
|
|
"userName" : userName,
|
|
|
"passWord" : aesEncrypt(passWord),
|
|
|
"typeId" : typeId
|
|
|
},
|
|
|
async : false,
|
|
|
success : function(result) {
|
|
|
personInfo = result;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return personInfo;
|
|
|
}
|
|
|
|
|
|
//进行绑定
|
|
|
function bindUser(personId, openId, typeId) {
|
|
|
var bindInfo;
|
|
|
$.ajax({
|
|
|
type : "POST",
|
|
|
dataType : "json",
|
|
|
url : "/dsssoserver/third/bindUser",
|
|
|
data : {
|
|
|
"personId" : aesEncrypt(personId),
|
|
|
"openId" : openId,
|
|
|
"typeId" : typeId
|
|
|
},
|
|
|
async : false,
|
|
|
success : function(result) {
|
|
|
bindInfo = result;
|
|
|
}
|
|
|
});
|
|
|
return bindInfo;
|
|
|
}
|
|
|
|
|
|
//aes加密
|
|
|
function aesEncrypt(content) {
|
|
|
var srcs = CryptoJS.enc.Utf8.parse(content);
|
|
|
var encrypted = CryptoJS.AES.encrypt(srcs, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
|
|
|
return encrypted.toString();
|
|
|
}
|
|
|
function getUrlParam(name) {
|
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
|
|
var r = window.location.search.substr(1).match(reg);
|
|
|
if (r != null)
|
|
|
return unescape(r[2]);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
</html> |