123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- $(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 = '<li><a href="/web-back/view/frame/frame.html" target="_blank">' + name + '</a><span></span></li>';
- $('.nav-first-right ul').append(dom)
- } else if (data.success === "false" || !data.loginUser.name) {
- var dom = '<li><a href="/web-back/view/register/register.html" target="_blank">注册</a><span></span></li><li><a href="/web-back/login_back.html" target="_blank" style="color:#e22">登录</a></li>';
- $('.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();
- })
|