清空token
This commit is contained in:
@@ -77,6 +77,7 @@ $("#login_btn").on("click", function () {
|
||||
// 用户登录成功的TOKEN
|
||||
var data = resData.data;
|
||||
localStorage.setItem("user_token", data.token);
|
||||
localStorage.setItem("user_token_add_time", new Date().getTime());
|
||||
$.toast(resData.message);
|
||||
if (data.firstLogin) {
|
||||
// 显示设置密码页面
|
||||
|
||||
@@ -85,6 +85,7 @@ function login(openid, unionid, accessToken, nickname, headImg, loginFrom, uri)
|
||||
})
|
||||
}else{
|
||||
localStorage.setItem("user_token", resData.data);
|
||||
localStorage.setItem("user_token_add_time", new Date().getTime());
|
||||
back();
|
||||
}
|
||||
}else{
|
||||
|
||||
@@ -39,6 +39,16 @@
|
||||
<script src="js/common.js"></script>
|
||||
<script src="js/push-common.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
// 清空过期的Token
|
||||
var token_add_time = localStorage.getItem("user_token_add_time");
|
||||
var current_time = new Date().getTime();
|
||||
var nTime = current_time - token_add_time;
|
||||
var day = Math.floor(nTime/86400000);
|
||||
if (day >= 25) {
|
||||
localStorage.removeItem("user_token");
|
||||
localStorage.removeItem("user_token_add_time");
|
||||
}
|
||||
|
||||
document.getElementById("quotations").setAttribute("href", BASE_PATH + '/quotations/index');
|
||||
//document.getElementById("selfInfo").setAttribute("href", BASE_PATH + '/selfInfo/index');
|
||||
//mui初始化
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
Vue.component('my-component', {
|
||||
props: ['title'],
|
||||
template: `
|
||||
<div class="head">
|
||||
<h1 @click="show">ddd{{message}}</h1>
|
||||
<h1 @click="show">{{title}}ddd{{message}}</h1>
|
||||
</div>
|
||||
`,
|
||||
data: function(){
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="example">
|
||||
<my-component></my-component>
|
||||
<my-component title="yjh"></my-component>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="../../js/vue.js" ></script>
|
||||
|
||||
@@ -196,6 +196,7 @@ var vue = new Vue({
|
||||
if (resData.status) {
|
||||
$.toast(resData.message);
|
||||
localStorage.setItem("user_token", resData.data);
|
||||
localStorage.setItem("user_token_add_time", new Date().getTime());
|
||||
back();
|
||||
} else {
|
||||
$.toast(resData.message);
|
||||
|
||||
@@ -131,6 +131,7 @@ new Vue({
|
||||
// 用户登录成功的TOKEN
|
||||
var token = resData.data;
|
||||
localStorage.setItem("user_token", token);
|
||||
localStorage.setItem("user_token_add_time", new Date().getTime());
|
||||
$.toast(resData.message);
|
||||
back();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user