$(function() {
// 判断用户现在使用的是什么平台
$.ajax({
url: getServerHttp() + '/getLoginUser',
type: 'post',
dataType: 'json',
success: function(data) {
var data = ajaxDataParames(data);
if (data.success === "true" && data.loginUser.name) {
var name = data.loginUser.name ? data.loginUser.name : '游客';
var dom = '
' + name + '';
$('.nav-first-right ul').append(dom)
} else if (data.success === "false" || !data.loginUser.name) {
var dom = '注册登录';
$('.nav-first-right ul').append(dom)
}
},
error: function() {
console.log('请求错误')
}
});
//功能
$.fn.extend({
//顶部浮动
topNavPosition: function() {
var _this = this;
var _father = _this.parent();
var _last = _this.find(".header-last-box");
var _animate = true;
$(window).scroll(function() {
if ($(window).scrollTop() > 35 && _animate == true) {
_father.animate({
height: "60px"
});
_this.css({
"box-shadow": "1px 1px 30px #999"
})
_this.animate({
top: "-115px"
});
_last.animate({
height: "60px"
});
_animate = false;
}
if ($(window).scrollTop() == 0) {
_father.animate({
height: "195px"
});
_this.css({
"box-shadow": "0px 0px 0px #999"
})
_this.animate({
top: "0"
}, 300);
_last.animate({
height: "80px"
});
_animate = true;
}
})
},
//顶部下拉菜单
topDropDownMwnu: function() {
$(this).hover(function() {
var _thisID = $(this).attr('id');
$('.drop-down-menu').css({
display: 'block'
});
$('.' + _thisID).css({
display: 'block'
}).siblings().css({
display: 'none'
})
}, function() {
$('.drop-down-menu').css({
display: 'none'
});
});
$('.drop-down-menu').hover(function() {
$('.drop-down-menu').css({
display: 'block'
})
}, function() {
$('.drop-down-menu').css({
display: 'none'
})
});
},
topSelectStyle: function() {
var navSelect = $('.header-content-center li');
var selectIndex = $(this).attr("data-selectIndex");
for (var i = 0; i < navSelect.length; i++) {
$(navSelect[selectIndex]).find('a').css({
'color': '#0cb46a'
}).find('span').css({
'display': 'block'
})
}
}
});
function topFun() {
$('.header-nav-content-box').topNavPosition();
$('.drop-down-but').topDropDownMwnu();
$('.header').topSelectStyle();
}
topFun();
})