<div class="login-box">
<div id="loginBox">
</div>
</div>
<script type="text/javascript">
var userToken;
$(function () {
$.ajax({
url: "http://域名/e/GetUserToken/",
type: "GET",
xhrFields: { withCredentials: true },
dataType: "json", //指定服务器返回的数据类型
success: function (data) {
if (data != "") {
var redirectUrl = encodeURIComponent(location.href);
var loginedHtml = '<a class="denglu" href="//域名/?redirectUrl=' + redirectUrl + '" target="_blank">登录</a><a class="zhuce" href="//域名/Reg/?redirectUrl=' + redirectUrl + '" target="_blank">注册</a>';
userToken = data.UserToken;
var currentUser = data.CurrentUser;
if (isNullOrEmpty(userToken) || isNullOrEmpty(currentUser)) {
$("#loginBox").html(loginedHtml);
return;
}
var nickName = data.NickName;
if (isNullOrEmpty(nickName)) {
nickName = currentUser.UserName;
}
nickName = nickName.left(10);
loginedHtml = '<a href="http://域名/" class="denglu" title="进入会员中心" target="_blank">您好,' + nickName + '</a>';
$("#loginBox").html(loginedHtml);
}
}
});
});
</script>
运行的以后的结果没任何显示
-
-
微信截图_20210110203558.png
(, 下载次数:0)
(2021/1/10 20:36:46 上传)