This commit is contained in:
parent
16ac159063
commit
0bb38e7c92
|
|
@ -104,6 +104,8 @@
|
||||||
$('#verifyCode').val('')
|
$('#verifyCode').val('')
|
||||||
if(data && data.code){
|
if(data && data.code){
|
||||||
if(data.code=='200'){
|
if(data.code=='200'){
|
||||||
|
localStorage.setItem("public_token",data.data.access_token);
|
||||||
|
localStorage.setItem("auth_type",data.data.user.dataType)
|
||||||
//登录成功
|
//登录成功
|
||||||
window.location.href="home.html";
|
window.location.href="home.html";
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,16 @@ let content_path="smz_screen"
|
||||||
// var dataUrl ="http://140.210.195.210:1917/gzrmw/";//部署
|
// var dataUrl ="http://140.210.195.210:1917/gzrmw/";//部署
|
||||||
// var dataUrl ="http://140.210.195.210:1921/gzrmw/";//CS部署
|
// var dataUrl ="http://140.210.195.210:1921/gzrmw/";//CS部署
|
||||||
|
|
||||||
var token=localStorage.getItem('token');
|
var token=localStorage.getItem('smzweb-token');
|
||||||
var companyId=localStorage.getItem('companyId');
|
var companyId=localStorage.getItem('companyId');
|
||||||
$(function() {
|
$(function() {
|
||||||
|
debugger
|
||||||
// 全局配置所有AJAX请求
|
// 全局配置所有AJAX请求
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
// 对所有类型的请求(GET/POST/PUT/DELETE等)生效
|
// 对所有类型的请求(GET/POST/PUT/DELETE等)生效
|
||||||
beforeSend: function(xhr) {
|
beforeSend: function(xhr) {
|
||||||
// 从本地存储获取Token
|
// 从本地存储获取Token
|
||||||
const token = localStorage.getItem('token') || sessionStorage.getItem('token');
|
const token = localStorage.getItem('smzweb-token');
|
||||||
if (token) {
|
if (token) {
|
||||||
// 为所有请求添加Token头
|
// 为所有请求添加Token头
|
||||||
xhr.setRequestHeader('x-auth-token', token);
|
xhr.setRequestHeader('x-auth-token', token);
|
||||||
|
|
@ -26,9 +26,9 @@ $(function() {
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
if (xhr.status === 401) {
|
if (xhr.status === 401) {
|
||||||
//Token无效或过期,跳转登录页
|
//Token无效或过期,跳转登录页
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('smzweb-token');
|
||||||
sessionStorage.removeItem('token');
|
sessionStorage.removeItem('smzweb-token');
|
||||||
window.location.href =contant_path+ '/login.html';
|
window.location.href="../../../login.html";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -38,8 +38,7 @@ $(function() {
|
||||||
headHTML += '<link rel="icon" href="../../img/favicon.ico" type="image/x-icon"/>';
|
headHTML += '<link rel="icon" href="../../img/favicon.ico" type="image/x-icon"/>';
|
||||||
document.getElementsByTagName('head')[0].innerHTML = headHTML;
|
document.getElementsByTagName('head')[0].innerHTML = headHTML;
|
||||||
if(token=="" || token==null){
|
if(token=="" || token==null){
|
||||||
window.location.href =contant_path+"/login.html";//线上
|
// window.location.href="../../../login.html";
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
function isNull(str) {
|
function isNull(str) {
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ function getAgeStructureList(){
|
||||||
// 手动添加请求头
|
// 手动添加请求头
|
||||||
beforeSend: function(xhr) {
|
beforeSend: function(xhr) {
|
||||||
// 从本地存储获取token(确保登录后已保存)
|
// 从本地存储获取token(确保登录后已保存)
|
||||||
const token = localStorage.getItem('token') || sessionStorage.getItem('token');
|
const token = localStorage.getItem('smzweb-token') || sessionStorage.getItem('smzweb-token');
|
||||||
if (token) {
|
if (token) {
|
||||||
xhr.setRequestHeader('x-auth-token', token); // 与后端配置的头名一致
|
xhr.setRequestHeader('x-auth-token', token); // 与后端配置的头名一致
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ function login() {
|
||||||
} else {
|
} else {
|
||||||
var token = data.user.token;
|
var token = data.user.token;
|
||||||
var companyId = data.user.companyId;
|
var companyId = data.user.companyId;
|
||||||
localStorage.setItem('token', token);
|
localStorage.setItem('smzweb-token', token);
|
||||||
localStorage.setItem('companyId', companyId);
|
localStorage.setItem('companyId', companyId);
|
||||||
localStorage.setItem('remeberName', jzname);
|
localStorage.setItem('remeberName', jzname);
|
||||||
localStorage.setItem('userName', uName);
|
localStorage.setItem('userName', uName);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue