mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-24 05:46:03 +08:00
优化菜单
This commit is contained in:
parent
1158485354
commit
6c5485d221
@ -1,68 +0,0 @@
|
||||
<nav id="nav" class="navbar navbar-static-top white-bg" role="navigation" style="margin-bottom: 0">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
|
||||
<form role="search" class="navbar-form-custom" action="search_results.html">
|
||||
<div class="form-group">
|
||||
<!--<input type="text" placeholder="Search for something..." class="form-control" name="top-search" id="top-search">-->
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<ul class="nav navbar-top-links navbar-right">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle"
|
||||
data-toggle="dropdown"
|
||||
href="#"
|
||||
role="button"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
{{navCommunityInfo._currentCommunity.name}}
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu" >
|
||||
<a class="dropdown-item" v-for="currentCommunity in navCommunityInfo.communityInfos" v-on:click="changeCommunity(currentCommunity)">{{currentCommunity.name}}</a>
|
||||
<a href="/admin.html#/enterCommunity" class="dropdown-item text-center">
|
||||
<strong>入驻小区</strong>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<li style="padding: 20px">
|
||||
<span class="m-r-sm text-muted welcome-message">欢迎访问HC小区管理系统,{{userName}}!</span>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
|
||||
<i class="fa fa-bell"></i> <span class="label label-primary">{{nav.total}}</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-alerts">
|
||||
<li v-for="notice in nav.notices">
|
||||
<a v-on:click="_noticeDetail(notice)" class="dropdown-item">
|
||||
<div>
|
||||
<i class="fa fa-envelope fa-fw"></i> {{notice.title}}
|
||||
<span class="float-right text-muted small">{{notice.createTime}}</span>
|
||||
</div>
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<div class="text-center link-block">
|
||||
<a v-bind:href="nav.moreNoticeUrl" class="dropdown-item">
|
||||
<strong>查看全部消息</strong>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<a v-on:click="logout()">
|
||||
<i class="fa fa-sign-out"></i> 退出
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
@ -1,188 +0,0 @@
|
||||
/**
|
||||
导航栏
|
||||
**/
|
||||
(function (vc) {
|
||||
var vm = new Vue({
|
||||
el: '#nav',
|
||||
data: {
|
||||
nav: {
|
||||
moreNoticeUrl: '/admin.html#/noticeManage',
|
||||
notices: [],
|
||||
total: 0
|
||||
},
|
||||
logo: '',
|
||||
userName: "",
|
||||
navCommunityInfo: {
|
||||
_currentCommunity: {},
|
||||
communityInfos: []
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
this._initSysInfo();
|
||||
this.getNavCommunity();
|
||||
this.getNavData();
|
||||
//this.getUserInfo();
|
||||
},
|
||||
methods: {
|
||||
_initSysInfo: function () {
|
||||
var sysInfo = vc.getData("_sysInfo");
|
||||
if (sysInfo == null) {
|
||||
this.logo = "HC";
|
||||
return;
|
||||
}
|
||||
this.logo = sysInfo.logo;
|
||||
},
|
||||
getNavData: function () {
|
||||
|
||||
var param = {
|
||||
params: {
|
||||
page: 1,
|
||||
row: 3,
|
||||
communityId: vc.getCurrentCommunity().communityId
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//发送get请求
|
||||
vc.http.get('nav',
|
||||
'getNavData',
|
||||
param,
|
||||
function (json) {
|
||||
var _noticeObj = JSON.parse(json);
|
||||
vm.nav.notices = _noticeObj.msgs;
|
||||
vm.nav.total = _noticeObj.total;
|
||||
}, function () {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
logout: function () {
|
||||
var param = {
|
||||
msg: 123
|
||||
};
|
||||
//发送get请求
|
||||
vc.http.post('nav',
|
||||
'logout',
|
||||
JSON.stringify(param),
|
||||
{
|
||||
emulateJSON: true
|
||||
},
|
||||
function (json, res) {
|
||||
if (res.status == 200) {
|
||||
vc.jumpToPage("/user.html#/login");
|
||||
return;
|
||||
}
|
||||
}, function () {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
},
|
||||
getUserInfo: function () {
|
||||
// var _userInfo = vc.getData("_userInfo");
|
||||
// //浏览器缓存中能获取到
|
||||
// if(_userInfo != null && _userInfo != undefined){
|
||||
// vm.userName = _userInfo.name;
|
||||
// return ;
|
||||
// }
|
||||
//获取用户名
|
||||
var param = {
|
||||
msg: '123',
|
||||
};
|
||||
|
||||
//发送get请求
|
||||
vc.http.get('nav',
|
||||
'getUserInfo',
|
||||
param,
|
||||
function (json, res) {
|
||||
if (res.status == 200) {
|
||||
var tmpUserInfo = JSON.parse(json);
|
||||
console.log(vm, tmpUserInfo);
|
||||
vm.userName = tmpUserInfo.name;
|
||||
// vc.saveData("_userInfo",tmpUserInfo);
|
||||
}
|
||||
}, function () {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
},
|
||||
getNavCommunity: function () {
|
||||
var _tmpCurrentCommunity = vc.getCurrentCommunity();
|
||||
//浏览器缓存中能获取到
|
||||
if (_tmpCurrentCommunity != null && _tmpCurrentCommunity != undefined) {
|
||||
this.navCommunityInfo._currentCommunity = _tmpCurrentCommunity;
|
||||
this.navCommunityInfo.communityInfos = vc.getCommunitys();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//说明缓存中没有数据
|
||||
//发送get请求
|
||||
/**
|
||||
[{community:"123123",name:"测试1小区"},{community:"223123",name:"测试2小区"}]
|
||||
**/
|
||||
var param = {
|
||||
params:{
|
||||
_uid:'123mlkdinkldldijdhuudjdjkkd'
|
||||
}
|
||||
};
|
||||
vc.http.get('nav',
|
||||
'getCommunitys',
|
||||
param,
|
||||
function (json, res) {
|
||||
if (res.status == 200) {
|
||||
vm.navCommunityInfo.communityInfos = JSON.parse(json).communitys;
|
||||
|
||||
if (vm.navCommunityInfo.communityInfos == null || vm.navCommunityInfo.communityInfos.length == 0) {
|
||||
vm.navCommunityInfo._currentCommunity = {
|
||||
name: "还没有入驻小区"
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
vm.navCommunityInfo._currentCommunity = vm.navCommunityInfo.communityInfos[0];
|
||||
vc.setCurrentCommunity(vm.navCommunityInfo._currentCommunity);
|
||||
vc.setCommunitys(vm.navCommunityInfo.communityInfos);
|
||||
|
||||
//对首页做特殊处理,因为首页在加载数据时还没有小区信息 会报错
|
||||
if (vm.navCommunityInfo.communityInfos != null && vm.navCommunityInfo.communityInfos.length > 0) {
|
||||
vc.emit("indexContext", "_queryIndexContextData", {});
|
||||
vc.emit("indexArrears", "_listArrearsData", {});
|
||||
}
|
||||
|
||||
}
|
||||
}, function () {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
changeCommunity: function (_community) {
|
||||
vc.setCurrentCommunity(_community);
|
||||
vm.navCommunityInfo._currentCommunity = _community;
|
||||
//中心加载当前页
|
||||
location.reload();
|
||||
},
|
||||
_noticeDetail: function (_msg) {
|
||||
//console.log(_notice.noticeId);
|
||||
//vc.jumpToPage("/admin.html#/noticeDetail?noticeId="+_notice.noticeId);
|
||||
|
||||
//标记为消息已读
|
||||
vc.http.post('nav',
|
||||
'readMsg',
|
||||
JSON.stringify(_msg),
|
||||
function (json, res) {
|
||||
if (res.status == 200) {
|
||||
vc.jumpToPage(_msg.url);
|
||||
}
|
||||
}, function () {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vm.getUserInfo();
|
||||
|
||||
})(window.vc);
|
||||
@ -1,6 +1,6 @@
|
||||
<nav id="nav" class="navbar navbar-static-top white-bg" role="navigation" style="margin-bottom: 0">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
|
||||
<a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="javascript:void(0)" @click="_doMenu()"><i class="fa fa-bars"></i> </a>
|
||||
</div>
|
||||
<ul class="nav navbar-top-links navbar-right">
|
||||
<li class="nav-item dropdown">
|
||||
|
||||
@ -179,6 +179,17 @@
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
},
|
||||
_doMenu:function(){
|
||||
let body = document.getElementsByTagName("body")[0];
|
||||
|
||||
let className = body.className;
|
||||
|
||||
if(className.indexOf("mini-navbar") != -1){
|
||||
body.className = className.replace("mini-navbar"/g,"");
|
||||
return ;
|
||||
}
|
||||
body.className = className + "mini-navbar";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user