Ai
0 Star 1 Fork 0

小菜鸟/heima_vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
header.html 4.98 KB
一键复制 编辑 原始数据 按行查看 历史
小菜鸟 提交于 2020-04-10 21:08 +08:00 . 提交前端文件
<!--
时间:2018-07-29
描述:菜单栏
-->
<script>
function logout(){
// 发请求 告诉服务器销毁session完事了
alert("退出登录");
$.ajax({
type:"post",
url:"http://api.shop.com:8080/user?md=logout",
xhrFields: {
withCredentials: true
},
success:function(){
//不会失败 肯定ok
//重新刷新页面
location.reload();
}
});
// HM.ajax("/user?func=logout",null,function(response){
// //直接由字符串转换好对象可以直接使用
// //不会失败 肯定ok
// //重新刷新页面
// location.reload();
// });
}
// jquery入口函数
$(function(){
//询问服务器 我是否处于登录状态
$.ajax({
type:"post",
url:"http://api.shop.com:8080/user?md=myname",
xhrFields: {
withCredentials: true
},
success:function(response){
var responseObj=eval("("+response+")");
//判断 到底返回你名字没有
if(responseObj.code==1){
var nickName=responseObj.data;
//处理显示位置 清空元素
$("#login-menu").empty();
// 拼接元素
var html='<li>'+nickName+'欢迎你!</li>';
// 退出登录绑定点击事件
html+='<li><a href="javascript:;" onclick="logout()">退出登录</a></li>';
html+='<li><a href="http://shop.com:5500/view/cart/list.html">购物车</a></li>';
html+='<li><a href="http://shop.com:5500/view/order/list.html">我的订单</a></li>';
$("#login-menu").html(html);
}else{
//do nothing....
//alert("暂未登录!");
}
}
});
// HM.ajax("/user?func=myname",null,function(response){
// if(response.code==1){
// var nickName=response.data;
// //处理显示位置
// $("#login-menu").empty();
// var html='<li>'+nickName+'欢迎您</li>';
// html+='<li><a href="javascript:;" onclick="logout()">退出登录</a></li>';
// html+='<li><a href="http://shop.com:5500/view/cart/list.html">购物车</a></li>';
// html+='<li><a href="http://shop.com:5500/view/order/list.html">我的订单</a></li>';
// $("#login-menu").html(html);
// }else{
// //do nothing....
// //alert("暂未登录!");
// }
// })
// 查询加载分类信息
$.ajax({
type:"post",
url:"http://api.shop.com:8080/category?md=findAll",
// xhrFields: {
// withCredentials: true
// },
success:function(response){
// alert(response);
// 字符串转对象
var category=eval("("+response+")");
// var responseObj = response;
// console.log(category);
//判断 到底返回你名字没有
if(category.code==1){
var lists=category.data;
// console.log(lists);
// alert(list);
// //处理显示位置 清空元素
var html="";
// 遍历数组
for (cate of lists) {
var cname=cate.cname;
var cid=cate.cid;
//拼接标签
//<li><a href="#">电脑办公</a></li>
html+='<li><a href="http://shop.com:5500/view/product/list.html?cid='+cid+'">'+cname+'</a></li>';
}
// 追加字符串
$("#cate_list").html(html);
}
}
});
})
</script>
<div class="container-fluid">
<div class="col-md-4">
<img src="http://shop.com:5500/resources/img/logo.png" />
</div>
<div class="col-md-5">
<img src="http://shop.com:5500/resources/img/header.png" />
</div>
<div class="col-md-3" style="padding-top:20px">
<ol class="list-inline" id="login-menu">
<li><a href="http://shop.com:5500/login.html">登录</a></li>
<li><a href="http://shop.com:5500/register.html">注册</a></li>
<li><a href="http://shop.com:5500/view/cart/list.html">购物车</a></li>
<li><a href="http://shop.com:5500/view/cart/list.html">我的订单</a></li>
</ol>
</div>
</div>
<!--
时间:2018-07-29
描述:导航条
-->
<div class="container-fluid">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://shop.com:5500/index.html">首页</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<!-- 循环 填入分类情况 -->
<ul class="nav navbar-nav" id="cate_list" id="ul-nav">
</ul>
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</div>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/upy/heima_vue.git
git@gitee.com:upy/heima_vue.git
upy
heima_vue
heima_vue
master

搜索帮助