头部信息

require([‘jquery’, ‘cookies’, ‘common/alertLogin’, ‘common/ficfn’, ‘urlUtil’, ‘common/utils/request’], function($, cookies, alertLogin, ficfn, urlUtil, loadAjax) {
/阻止内部元素的鼠标滚动事件冒泡/
$.fn.preventScroll = function () {
var _this = this.get(0);
if (typeof _this.onmousewheel === “undefined”) {
_this.addEventListener(‘DOMMouseScroll’, function (e) {
_this.scrollTop += e.detail > 0 ? 60 : -60;
e.preventDefault();
}, false);
} else if(typeof _this.onmousewheel === “object”){
_this.onmousewheel = function (e) {
e = e || window.event;
_this.scrollTop += e.wheelDelta > 0 ? -60 : 60;
e.preventDefault ? e.preventDefault() : e.returnValue = false;
};
}
return this;
};
/**END/
$.fn.loadHeader = function(options) {
var defaults = {
loadUrl: ‘/trans/page/base/top-header.html?t’ + (new Date()).getTime()
};
var settings = $.extend({}, defaults, options);
var topHeader = new TopHeader(settings);
topHeader.init();
createLink();
}
var TopHeader = function(settings) {
function init() {
$("#topHeader").load(settings.loadUrl, function() {
bindEvents();
loadNav();
});
}

	function loadNav() {
		var tabmodule = urlUtil.getParameter("tabmodule");
		var pathName = window.location.pathname;
		var NEED_SUBHEADER_ARR = ['trans', 'fof', 'bill'];
		if(NEED_SUBHEADER_ARR.indexOf(pathName.split('/')[1]) > -1 || pathName.indexOf('/insuranceStreet/') > -1) {
			$('.sub_header').show();
		}
		var timer = setInterval(function() {
			if(cookies.get('username')) {
				clearInterval(timer);
				$('#topUserName').html(cookies.get('username'));
				$('#toplogin, #topRegister').hide();
				$('#toploginOut, #toplogined').show();
				/**金融MALL,且已开店,且是管理员或者店铺运营人员,展示商家后台下拉选项**/
				pathName.indexOf('/web/') > -1 && queryShopExist();
			}
		}, 500)
		if (pathName.indexOf('/trans/') > -1 && pathName.indexOf('/lobby/') > -1) {
			$('#toplobbyAcct').show();
			$('.sub_header').addClass('lobby_sub_header');
			if (tabmodule === 'quotation') {//报价大厅头
				$('#toplobbyAcct a').html('报价大厅账户管理');
				$('.header_nav li').removeClass('current');
				$('.header_nav li.quotation').addClass('current');
			} else {//产品大厅头
				$('#toplobbyAcct a').html('产品大厅账户管理');
				$('.header_nav li').removeClass('current');
				$('.header_nav li.product').addClass('current');
			}
		}
		if (pathName.indexOf('/fof/') > -1) {//fof定位到产品大厅高亮
			$('.sub_header').addClass('lobby_sub_header');
			$('.header_nav li').removeClass('current');
			$('.header_nav li.product').addClass('current');
		}
		if (pathName.indexOf('/insuranceStreet/') > -1) {//金融MALL首页定位到金融MALL高亮
			$('.header_nav li').removeClass('current');
			$('.header_nav li.mall').addClass('current');
		}
		if (pathName.indexOf('/web/') > -1 && pathName.indexOf('/insuranceStreet/') == -1) {//金融MALL的显示“金融MALL首页”
			$('#topmall').show();
		}
	}

	function bindEvents() {
		$('#toplogin').on('click', function () {
			alertLogin();
			// window.location =  window.ssoOprUrl.loginUrl; 
		});
		$('#toploginOut').on('click', function () {
			loginout();
		});
		$('#topSearchBtn').on('click', function () {
			var searchInput = $("#topSearchInput").val();
			window.location = window.yztDomain + "/portal/searchresult?keyWords=" + searchInput;
		}).on('mouseenter', function () {
			$('#topSearchInput').css('width', '245px');
		});
		$('#topSearchInput').hover(function () {
			$(this).css('width', '245px');
		}, function () {
			!$(this).val().trim() && $(this).css('width', '94px');
		}).focus(function () {
			$(this).css('width', '245px');
		}).blur(function () {
			$(this).css('width', '94px');
		});
		$('#topRegister').on('click', function () {
			window.location = window.ssoOprUrl.registerUrl;
		});
		/**左侧导航锁屏滚动**/
		$('#topHeader .menu-group').preventScroll();
		$('#topHeader .submenu-group').each(function(k,el){
			$(el).preventScroll();
		});
	}

	return {
		init: init
	};
}

function loginout() {
	loadAjax({
		url: "/user/logout",
		needCache: false,
		success: function(result) {
			if(result && result.rtnCode == "000") {
				location.href = ssoOprUrl.logoutUrl
			}
		}
	})
}

function createLink() {
	var cssURL = '/trans/css/base/top-header.css',
		linkTag = $('<link href="' + cssURL + '" rel="stylesheet" type="text/css"/>');
	$($('head')[0]).append(linkTag);
}

function queryShopExist() {
	loadAjax({
		url: "/yztShop/queryShopExist",
		data: JSON.stringify({}),
		needCache: false,
		contentType: "application/x-www-form-urlencoded;charset=utf-8",
		success: function (res) {
			if (res.data && res.data == "1") {
				var userroles = cookies.get('userRoles');
				var	isMonitor = userroles.indexOf('monitor') >= 0 ? true : false;
				if (cookies.get("yztType") == "0" || isMonitor) {
					$('#topmallAcct').show();
				}
			}
		}
	});
}

$('body').loadHeader();

if(typeof define === "function" && define.amd) {
	define("topHeader", [], function() {});
}

})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值