top_footer_1.2.js 8.04 KB
$(function () {
    var nav = '<div class="responsive clearfix"><div class="left">欢迎来到地利批发! 请<a class="lay-in" href="#">登录</a> | <a href="#">免费注册</a></div><ul class="right"><li><a href="http://user.nong12.com/account/security.html"><span>我的地利</span></a></li><li class="more"><a href="http://user.nong12.com/"><span>采购中心 </span></a><span class="icon-more"></span><div class="mroe-list"><div class="list-a"><a href="http://user.nong12.com/purchase/order.html">已买到的商品</a><a href="http://user.nong12.com/purchase/agencybuy/list.html">采购服务</a><a href="http://user.nong12.com/purchase/agencybuy/write.html">申请代购</a><a href="http://user.nong12.com/purchase/favorite/product.html">我的收藏</a></div></div></li><li class="more"><a href="http://user.nong12.com/seller/shop/setting_shop.html"><span>销售中心 </span></a><span class="icon-more"></span><div class="mroe-list"><div class="list-a"><a href="http://user.nong12.com/seller/shop/setting_shop.html">我的店铺</a><a href="http://user.nong12.com/seller/product/onsale.html">出售中商品</a><a href="http://user.nong12.com/seller/sale/list.html">销售服务</a><a href="http://user.nong12.com/seller/sale/write.html">申请代销</a></div></div></li><li><a href="http://www.nong12.com/purchase_list.html"><span>进货单</span><span class="num cart-num">(0)</span></a></li><li><a href="javascript:void(0)" onclick="IM.openWindow(\'地利客服\', \'\', \'\', \'\' , \'1\');"><span>客服服务</span></a></li><li><a href="http://www.nong12.com/helpcenter.html"><span>帮助中心</span></a></li></ul></div>';
    var footer = '<div class="bg-F9"><div class="footer-view clearfix"><div class="left"><ul id="footer_cms"></ul></div><div class="right"><span class="icon-shield"></span><ul class="clearfix"><li><span class="icon-f-phone"></span><p>服务热线:<span class="text-phone">0451-86668574</span></p></li><li><span class="icon-f-customerservice"></span><p>服务时间:<span class="text-time">上午8:00 - 下午16:00</span></p></li><li><span class="icon-f-im"></span><a class="dili-im" href="javascript:void(0)" onclick="IM.openWindow(\'地利客服\', \'\', \'\', \'\' , \'1\');"><i></i>联系我们</a></li></ul></div></div></div><div class="footer-end"><p><a href="http://www.nong12.com/helpcenter/articles.html?categoryId=3&amp;articleId=9">关于我们</a> |<a href="http://www.nong12.com/helpcenter/articles.html?categoryId=3&amp;articleId=10">联系我们</a> |<a href="http://www.nong12.com/helpcenter/articles.html?categoryId=3&amp;articleId=11">人才招聘</a> |<a href="http://www.nong12.com/helpcenter/articles.html?categoryId=19&amp;articleId=32">地利服务</a> |<a href="http://www.nong12.com/helpcenter.html">帮助中心</a></p><p class="col-999"> Copyright © 2013-2015 nong12.com,All Rights Reserved 陕ICP备14002958号</p><p class="col-999">版权所有 地利网络农业有限公司</p></div>';
    $('.pnr-top .nav').html(nav);
    $('.footer').html(footer);

    window.loginInfo = true;
    //渲染hello头
    jQuery.ajax({
        type: "GET",
        url: "https://passport.nong12.com/uc/ws/callHelloJSONP",
        dataType: "jsonp",
        cache: false,
        success: function (data) {
            if (data) {
                if (data.isLogin) {
                    $(".responsive .left").remove();
                    $(".responsive .right").before("<div class='left'><a href='http://user.nong12.com/account/security.html' target='_blank'><span id='uname'>" + data.userName + "</span></a>&nbsp;欢迎来到地利批发! <a href='https://passport.nong12.com/uc/loginService?ltype=logout'>退出</a></div>");

                    $("#right-login .state-success").show();
                    $("#userName").html(data.userName);

                    if(window.isRight){
                    	 jQuery.ajax({
                             type: "GET",
                             url: "http://user.nong12.com/api/userservice/getUserName.do",
                             dataType: "jsonp",
                             cache: false,
                             success: function (data) {
                                 $("#my-face").attr("src", data.face);
                             }
                         });
                    	IM.notification(function (num) {
                    		if (parseInt(num) > 0) {
                    			$('#im-num').html(num)
                    			$('#im-num').show();
                    			$(".ui-im").show();
                    		}
                    	});
                    	window.loginInfo = true;
                    }else{
                    	 $(".responsive .left").append('<a class="h-user-msg" href="javascript:void(0)" id="notify"></a>');
                    	 IM.notification($("#notify"));
                    }
                } else {
                    $(".responsive .left a").first().attr("href", DiliPath.loginPath + "?ReturnUrl=" + window.location.href);
                    $(".responsive .left a").last().attr("href", DiliPath.registPath);
                    window.loginInfo = false;
                }
            }
        },
        error: function () {
            window.loginInfo = false;
            return false;
        }
    });

    $("#my-info").hover(function () {
        if (!window.loginInfo) {
            window.loginInfo = true;
            PassportPopupLogin.settings.callbackFn = function () {
                window.location.reload();
            };
            PassportPopupLogin.init();
            if (window.location.href.indexOf("error.html") < 0) {
                $("#right-login").html('<div class="triangle"></div><div class="f-hover-view"></div><iframe frameborder="0" scrolling="no" class="login-frame" src="https://passport.nong12.com/uc/newPopup/login.aspx?referUrl=http://www.nong12.com"></iframe>');
            }
        }
    }, function () {
    });

    //渲染footer
    jQuery.ajax({
        type: "GET",
        url: DiliPath.homePath + "common/footerJson.html",
        dataType: "jsonp",
        jsonp: "callFn",
        jsonpCallback: 'success_jsonpCallback1' + (new Date()).getTime(),
        success: function (data) {
            var html = [];
            var iconArr = ["icon-we", "icon-aftersales", "icon-shopping", "icon-identity", "icon-novice"];
            for (var i = 0; i < data.length; i++) {
                var showIcon = data.length <= iconArr.length ? iconArr[i] : iconArr[0];
                html.push("<li><span class='" + showIcon + "'></span><p>" + data[i].title + "</p><div class='f-list'>");
                var vc = eval(data[i].extendsOne);
                for (var j = 0; j < vc.length; j++) {
                    if (j == vc.length - 1) {
                        html.push("<a href='" + vc[j].link + "'>" + vc[j].text + "</a></div></li>");
                    } else {
                        html.push("<a href='" + vc[j].link + "'>" + vc[j].text + "</a></div>");
                    }
                }
            }
            $("#footer_cms").html(html.join(""));
        }
    });

    if ($("head").find("script[src*='jquery.lazyload']").size() > 0) {
        $("body").find("img").each(function () {
            $(this).lazyload({
                effect: "fadeIn",
                skip_invisible: false
            });
        });
    }
});

function replaceAll(str, sptr, sptr1) {
    while (str.indexOf(sptr) >= 0) {
        str = str.replace(sptr, sptr1);
    }
    return str;
}

var otherTools = {
    /**
     * im
     * @param sellerType
     * @param sellerName
     */
    imConnection: function (sellerType, sellerName) {
        var type = 2;//2默认客服
        var name = '地利客服';
        //第3方
        if (sellerType == 30) {
            type = 0;
            name = sellerName;
        }

        var timestamp = (new Date()).valueOf();
        var ht = (screen.height - 500) / 2;
        var wt = (screen.width - 800) / 2;
        var url = 'http://chat.nong12.com/launch/launch.action?uid=' + name + '&type=' + type + '&_t=' + timestamp;
        var param = 'height=555,width=800,resizable=yes,top=' + ht + ',left=' + wt;
        window.open(url, name, param);
    }
};