style:登录
Showing
2 changed files
with
12 additions
and
24 deletions
... | @@ -38,7 +38,7 @@ document.writeln(" <li class='personalCenter'>"); | ... | @@ -38,7 +38,7 @@ document.writeln(" <li class='personalCenter'>"); |
38 | document.writeln(" <a href=\'"+localhostPaht+"/staticViews/grzx.html\'>个人中心</a>"); | 38 | document.writeln(" <a href=\'"+localhostPaht+"/staticViews/grzx.html\'>个人中心</a>"); |
39 | document.writeln(" </li>"); | 39 | document.writeln(" </li>"); |
40 | document.writeln(" <li>"); | 40 | document.writeln(" <li>"); |
41 | document.writeln(" <p class='PersonLogin'>登录</p>"); | 41 | document.writeln(" <p class='loginButton PersonLogin'>登录</p>"); |
42 | document.writeln(" </li>"); | 42 | document.writeln(" </li>"); |
43 | document.writeln(" <li>"); | 43 | document.writeln(" <li>"); |
44 | document.writeln(" <p id='cancellation'>注销</p>"); | 44 | document.writeln(" <p id='cancellation'>注销</p>"); | ... | ... |
... | @@ -42,12 +42,21 @@ $(document).on('click', '#cancellation', function () { | ... | @@ -42,12 +42,21 @@ $(document).on('click', '#cancellation', function () { |
42 | btn: ['是', '否'] //按钮 | 42 | btn: ['是', '否'] //按钮 |
43 | }, function () { | 43 | }, function () { |
44 | delCookie(); | 44 | delCookie(); |
45 | $('.loginButton').addClass('PersonLogin') | ||
45 | window.open('' + localhostPaht + '/index.html', '_self') | 46 | window.open('' + localhostPaht + '/index.html', '_self') |
46 | }, function () { | 47 | }, function () { |
47 | layer.msg('已取消'); | 48 | layer.msg('已取消'); |
48 | }); | 49 | }); |
49 | }) | 50 | }) |
50 | }); | 51 | }); |
52 | |||
53 | $(function () { | ||
54 | if (getCookie('myCookie').username) { | ||
55 | $('.loginButton').html(getCookie('myCookie').username); | ||
56 | $('.loginButton').removeClass('PersonLogin') | ||
57 | $('.personalCenter').addClass('show'); | ||
58 | } | ||
59 | }) | ||
51 | function delCookie() { | 60 | function delCookie() { |
52 | var keys = document.cookie.match(/[^ =;]+(?==)/g) | 61 | var keys = document.cookie.match(/[^ =;]+(?==)/g) |
53 | if (keys) { | 62 | if (keys) { |
... | @@ -59,28 +68,6 @@ function delCookie() { | ... | @@ -59,28 +68,6 @@ function delCookie() { |
59 | } | 68 | } |
60 | } | 69 | } |
61 | 70 | ||
62 | |||
63 | $(function () { | ||
64 | $('.PersonLogin').html(getCookie('myCookie').username) | ||
65 | if (getCookie('myCookie').username) { | ||
66 | $('.personalCenter').addClass('show'); | ||
67 | } | ||
68 | var _beforeUnload_time = 0, _gap_time = 0; | ||
69 | var is_fireFox = navigator.userAgent.indexOf("Firefox") > -1;//是否是火狐浏览器 | ||
70 | window.onunload = function () { | ||
71 | _gap_time = new Date().getTime() - _beforeUnload_time; | ||
72 | if (_gap_time <= 5) { | ||
73 | delCookie(); | ||
74 | } else {//浏览器刷新 | ||
75 | } | ||
76 | } | ||
77 | window.onbeforeunload = function () { | ||
78 | _beforeUnload_time = new Date().getTime(); | ||
79 | if (is_fireFox) {//火狐关闭执行 | ||
80 | delCookie(); | ||
81 | } | ||
82 | }; | ||
83 | }) | ||
84 | // 点击注册的时候 | 71 | // 点击注册的时候 |
85 | $(document).on('click', '#registerButton', function () { | 72 | $(document).on('click', '#registerButton', function () { |
86 | window.open('' + localhostPaht + '/staticViews/register.html', '_self') | 73 | window.open('' + localhostPaht + '/staticViews/register.html', '_self') |
... | @@ -97,8 +84,9 @@ function clicklogin(data) { | ... | @@ -97,8 +84,9 @@ function clicklogin(data) { |
97 | success: function (result) {//返回数据根据结果进行相应的处理 | 84 | success: function (result) {//返回数据根据结果进行相应的处理 |
98 | if (result.code == 200 && result.data !== null) { | 85 | if (result.code == 200 && result.data !== null) { |
99 | setCookie('myCookie', result.data, 60); | 86 | setCookie('myCookie', result.data, 60); |
87 | $('.loginButton').removeClass('PersonLogin') | ||
100 | $('.personalCenter').addClass('show'); | 88 | $('.personalCenter').addClass('show'); |
101 | $('.PersonLogin').html(getCookie('myCookie').username); | 89 | $('.loginButton').html(getCookie('myCookie').username); |
102 | layer.closeAll(); | 90 | layer.closeAll(); |
103 | } else if (result.code == 210) { | 91 | } else if (result.code == 210) { |
104 | layer.msg(result.message); | 92 | layer.msg(result.message); | ... | ... |
-
Please register or sign in to post a comment