常见的在页面登录过后会获得一个token值然后页面跳转时传给下一个页面

sessionStorage.setItem("token",result.token);//传输token

一班我们再建一个公共的文件来放置

var host = window.location.protocol + "//" + window.location.host;//获得页面ip和端口号
var token = "";
var t = sessionStorage.getItem("token");接收token
if (t != null) {
token = t;
}

别的页面

$.ajax({
type: "post",
url: host + "/dcms/api/v1/admin/login",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
"account": accounts,
"passwd": passwd
}),
success: function (result) {
//console.log(result.token);
sessionStorage.setItem("token",result.token);//传值给下一个页面
if (result.adminType == 1) {
window.location.href = "logadmin/index.html";
}
if (result.adminType == 2) {
window.location.href = "systemadmin/index.html";
}
if (result.adminType == 3) {
window.location.href = "secadmin/index.html";
}
if (result.code != 0) {
//"账号或者密码错误,请检查后重新登录!"
$(".content").text(result.msg);
}

},
error: function (result) {
showGlobleTip("服务器异常,请联系管理员");
}
});

最新文章

  1. MyCat源码分析系列之——BufferPool与缓存机制
  2. google protobuf安装与使用
  3. 服务器使用FTP命令行 无法传送文件 卡在150 Opening data channel for file transfer
  4. 一个"如何使用示波器安全测试接市电电路板"的问题
  5. html中button自动提交表单?
  6. PHP生成迅雷、快车、旋风等软件的下载链接代码实例
  7. jQuery源码分析之=>jQuery的定义
  8. implement "slam_karto" package in Stage simulation
  9. 打包python脚本为exe可执行文件-pyinstaller和cx_freeze示例
  10. linux的fork函数
  11. git操作回顾:
  12. ecshop模板如何修改详细图解
  13. 在msvc中使用Boost.Spirit.X3
  14. css 相关
  15. centos7.2部署最新ELK 5.3
  16. Archive for required library:xxxxx/spring-beans-3.2.4.RELEASE.jar in project XXXXX cannot be read or is not a valid ZIP file
  17. mysql基础之yum安装mysql5.7.18
  18. Markdown文本测试
  19. leetcode算法:Distribute Candies
  20. jQuery实用工具集

热门文章

  1. sleep(0)、usleep(0)与sched_yield() 调度
  2. docker 入门2 - 容器 【翻译】
  3. hdu 1502 大数dp
  4. 4-MySQL DBA笔记-开发进阶
  5. react用高阶组件实现路由守卫
  6. datagrid如何获取选中行的索引
  7. LLVM新建全局变量
  8. 人工智能_4_k近邻_贝叶斯_模型评估
  9. Delphi 线程的同步
  10. 4.1. Scrapy配置安装