|
@@ -0,0 +1,123 @@
|
|
|
+/**
|
|
|
+ * 系统导航也
|
|
|
+ *
|
|
|
+ * @author zhoutl
|
|
|
+ */
|
|
|
+/** 页面初始化 */
|
|
|
+$(function () {
|
|
|
+ adjustBlock();
|
|
|
+ getPermission();
|
|
|
+});
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+function getPermission() {
|
|
|
+ $.get(basePath + "/menu/topMenus", {}, function (result) {
|
|
|
+ if(result && result.length > 0) {
|
|
|
+ for(var i=0; i <result.length;i++) {
|
|
|
+ var obj = result[i];
|
|
|
+ //console.info(obj.attributes.url);
|
|
|
+ var img = $("#"+obj.attributes.code).find("img")[0];
|
|
|
+ $(img).css('cursor', "pointer");
|
|
|
+ $(img).attr('src', basePath + "/" +obj.attributes.icon2);
|
|
|
+ $(img).click({top: obj}, function(event){
|
|
|
+ var obj1 = event.data.top;
|
|
|
+ window.open(basePath+obj1.attributes.url);
|
|
|
+ });
|
|
|
+ // 获取二级菜单
|
|
|
+ getMenus(obj.id, obj.attributes.code);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 'json');
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * 增加formatString功能
|
|
|
+ *
|
|
|
+ * 使用方法:$.formatString('字符串{0}字符串{1}字符串','第一个变量','第二个变量');
|
|
|
+ *
|
|
|
+ * @returns 格式化后的字符串
|
|
|
+ */
|
|
|
+$.formatString = function (str) {
|
|
|
+ for (var i = 0; i < arguments.length - 1; i++) {
|
|
|
+ str = str.replace("{" + i + "}", arguments[i + 1]);
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取二级菜单
|
|
|
+ */
|
|
|
+function getMenus(id, code) {
|
|
|
+ var lineStr = '<div class="h_linediv"><img src="' + basePath
|
|
|
+ +'/static/xt/images/home/line.png" class="h_line"></div>';
|
|
|
+ var menuStr = '<div class="h_menudiv" onclick="openSubPage(\'{0}\',\'{1}\',\'{2}\')" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)">'
|
|
|
+ + '<div class="infoimg"><img src="'+basePath+'/{3}" class="h_menuicon"></div>'
|
|
|
+ + '<div class="info">{4}</div></div>';
|
|
|
+ $.get(basePath + "/menu/submenu/"+id, {}, function (result) {
|
|
|
+ if(result && result.length > 0) {
|
|
|
+ var menuStrTotal = "";
|
|
|
+ for(var i=0; i <result.length;i++) {
|
|
|
+ var obj = result[i];
|
|
|
+ if(obj.attributes.code == "air" || obj.attributes.code == "waterway"
|
|
|
+ || obj.attributes.code == "road" || obj.attributes.code == "railway"
|
|
|
+ || obj.attributes.code == "command") {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ menuStrTotal += $.formatString(menuStr,
|
|
|
+ obj.attributes.code,obj.attributes.url,code,
|
|
|
+ obj.attributes.icon2, obj.text);
|
|
|
+ menuStrTotal += lineStr;
|
|
|
+ }
|
|
|
+ if(menuStrTotal.length > 0) {
|
|
|
+ $("#"+code).append(lineStr).append(menuStrTotal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 'json');
|
|
|
+}
|
|
|
+
|
|
|
+function openSubPage(code, url, pcode) {
|
|
|
+ if(code == "skyView") {
|
|
|
+ $("#aLink").attr("href", url);
|
|
|
+ $("#spanId").click();
|
|
|
+ } else if(code == "cxw") {
|
|
|
+ window.open(url);
|
|
|
+ } else if(code == "hsais") {
|
|
|
+ window.open(url);
|
|
|
+ } else if(code == "12306") {
|
|
|
+ window.open(url);
|
|
|
+ } else if(code == "chat") {
|
|
|
+ $("#aLink").attr("href", url);
|
|
|
+ $("#spanId").click();
|
|
|
+ } else {
|
|
|
+ window.open(basePath + url);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function adjustBlock() {
|
|
|
+ var topHeight = 130;
|
|
|
+ // 调整高度和宽度
|
|
|
+ var height = $(document).height() - topHeight;
|
|
|
+ var width = $(document).width();
|
|
|
+ $(".h_block_road").css("margin-top","100px");
|
|
|
+ $(".h_block_air").css("margin-top","50px");
|
|
|
+ $(".h_block_command").css("margin-top","25px");
|
|
|
+ $(".h_block_waterway").css("margin-top","50px");
|
|
|
+ $(".h_block_railway").css("margin-top","100px");
|
|
|
+};
|
|
|
+
|
|
|
+/*function aa() {
|
|
|
+ var url = basePath + "/index";
|
|
|
+ url += "?type=" + "air";
|
|
|
+ window.location.href=url;
|
|
|
+};*/
|
|
|
+
|
|
|
+function menuMouseOver(obj) {
|
|
|
+ $(obj).addClass("h_menudivmouse");
|
|
|
+};
|
|
|
+
|
|
|
+function menuMouseOut(obj) {
|
|
|
+ $(obj).removeClass("h_menudivmouse");
|
|
|
+};
|