b79c5e97 by 任超

style:登录

1 parent 32cf54b1
......@@ -38,7 +38,7 @@ document.writeln(" <li class='personalCenter'>");
document.writeln(" <a href=\'"+localhostPaht+"/staticViews/grzx.html\'>个人中心</a>");
document.writeln(" </li>");
document.writeln(" <li>");
document.writeln(" <p class='PersonLogin'>登录</p>");
document.writeln(" <p class='loginButton PersonLogin'>登录</p>");
document.writeln(" </li>");
document.writeln(" <li>");
document.writeln(" <p id='cancellation'>注销</p>");
......
......@@ -42,12 +42,21 @@ $(document).on('click', '#cancellation', function () {
btn: ['是', '否'] //按钮
}, function () {
delCookie();
$('.loginButton').addClass('PersonLogin')
window.open('' + localhostPaht + '/index.html', '_self')
}, function () {
layer.msg('已取消');
});
})
});
$(function () {
if (getCookie('myCookie').username) {
$('.loginButton').html(getCookie('myCookie').username);
$('.loginButton').removeClass('PersonLogin')
$('.personalCenter').addClass('show');
}
})
function delCookie() {
var keys = document.cookie.match(/[^ =;]+(?==)/g)
if (keys) {
......@@ -59,28 +68,6 @@ function delCookie() {
}
}
$(function () {
$('.PersonLogin').html(getCookie('myCookie').username)
if (getCookie('myCookie').username) {
$('.personalCenter').addClass('show');
}
var _beforeUnload_time = 0, _gap_time = 0;
var is_fireFox = navigator.userAgent.indexOf("Firefox") > -1;//是否是火狐浏览器
window.onunload = function () {
_gap_time = new Date().getTime() - _beforeUnload_time;
if (_gap_time <= 5) {
delCookie();
} else {//浏览器刷新
}
}
window.onbeforeunload = function () {
_beforeUnload_time = new Date().getTime();
if (is_fireFox) {//火狐关闭执行
delCookie();
}
};
})
// 点击注册的时候
$(document).on('click', '#registerButton', function () {
window.open('' + localhostPaht + '/staticViews/register.html', '_self')
......@@ -97,8 +84,9 @@ function clicklogin(data) {
success: function (result) {//返回数据根据结果进行相应的处理
if (result.code == 200 && result.data !== null) {
setCookie('myCookie', result.data, 60);
$('.loginButton').removeClass('PersonLogin')
$('.personalCenter').addClass('show');
$('.PersonLogin').html(getCookie('myCookie').username);
$('.loginButton').html(getCookie('myCookie').username);
layer.closeAll();
} else if (result.code == 210) {
layer.msg(result.message);
......