$(function () {
    
    //分享配置
    window._bd_share_config = {
        "common": {
            "bdSnsKey": {},
            "bdText": "",
            "bdMini": "1",
            "bdMiniList": false,
            "bdPic": "",
            "bdStyle": "2",
            "bdSize": "16"
        },
        "share": {"bdSize": 16}
    };
    with (document)0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'static/js/share.js' + ~(-new Date() / 36e5)];

    $('.share').click(function () {
        $('.share-div').slideToggle();
    });

    //返回顶部
    $('.back-top').click(function () {
        var _twoPage = $('.header').offset().top;
        $("html,body").animate({ "scrollTop": _twoPage },1000);
    });
    //底部弹窗
    $('.get-mid,.get-right').hide(800);
    $('.get-close').click(function () {
        $('.getOffer').addClass('active').animate({ "width": "250 "},800);
        $('.get-mid,.get-right').hide(800);
    });
    $('.get-show').click(function () {
        $('.getOffer').animate({"width": "100%" },800).removeClass('active');
        $('.get-mid,.get-right').show(400);

    });
  $(".small-obtain").click(function(){
    $(".big-obtain").css("display","block")
    $(".small-obtain").css("display", "none")
  })
  $(".img-close img").click(function () {
    $(".big-obtain").css("display", "none")
    $(".small-obtain").css("display", "flex")
  })

//侧边栏
    $('.side-ul2-li').hover(
        function () {
            $(this).addClass('active').siblings().removeClass('active');
        },
        function () {
            $(this).removeClass('active');
        }
    );
    $(".right-lists .right-list").each(function (index, val) {
      $(".right-lists .right-list").eq(index).mouseenter(function () {
         $(".right-lists .right-list").eq(index).addClass("right-list-active");
          $(".right-lists .right-list .img").eq(index).css("display","block");
           $(".right-lists .right-list .img1").eq(index).css("display", "none");
      })
      $(".right-lists .right-list").eq(index).mouseleave(function () {
        $(".right-lists .right-list").eq(index).removeClass("right-list-active");
        $(".right-lists .right-list .img").eq(index).css("display", "none");
        $(".right-lists .right-list .img1").eq(index).css("display", "block");
      })
    })



//获取报价验证
    $('#getBtn').click(function () {
        check();
    });
    $('.get-input-line input').blur(function () {
        $('.get-input-line').removeClass('active');
        $('.tip').removeClass('active');
    });
    var flag = 'false';
    $(document).keyup(function (e) {
        var keycode = e.which || e.keyCode;
        if (keycode == 13 && flag) {
            check();
        }
    });
    $('.get-input-line input').focus(function () {
        $('get-input-line').removeClass('active');
        $('.tip').removeClass('active');
    });
    function check() {
        var area = $('#area').val();
        var name = $('#name').val();
        var space = $('#space').val();
        var phone = $('#phone').val();
        if(area == ''){
            $('#area').parent().addClass('active').find('input').focus();
            $('#area').parent().find('.tip').addClass('active').html('请输入所在区域');
            return false;
        }
        if(name == ''){
            $('#name').parent().addClass('active').find('input').focus();
            $('#name').parent().find('.tip').addClass('active').html('请输入您的姓名');
            return false;
        }
        if(space == ''){
            $('#space').parent().addClass('active').find('input').focus();
            $('#space').parent().find('.tip').addClass('active').html('请输入空间面积');
            return false;
        }else if(! /^[0-9]+$/.test(space)){
            $('#space').parent().addClass('active').find('input').focus();
            $('#space').parent().find('.tip').addClass('active').html('请输入数字');
            return false;
        }
        if(phone == ''){
            $('#phone').parent().addClass('active').find('input').focus();
            $('#phone').parent().find('.tip').addClass('active').html('请输入您的联系方式');
            return false;
        }else{
            if (phone.substring(0, 1) == 1 && !/^1[34578]\d{9}$/.test(phone)){
                $('#phone').parent().addClass('active').find('input').focus();
                $('#phone').parent().find('.tip').addClass('active').html('您的联系方式格式错误');
                return false;
            }else if(!/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/.test(phone)){
                $('#phone').parent().addClass('active').find('input').focus();
                $('#phone').parent().find('.tip').addClass('active').html('您的联系方式格式错误');
                return false;
            }
            $.ajax({
                type: "POST",
                url: "/api/cn/obtainoffer/message",
                data: { "area": area, "name": name, "space": space, "phone": phone },
                datatype: "jsonp",
                success: function (data) {
                    if (data.errcode == 0) {
                        // 提交成功
                        flag = 'true';
                        alert("提交成功");
                        flag = 'false';
                        $('#area').val("");
                        $('#name').val("");
                        $('#space').val("");
                        $('#phone').val("");
                        $('.evaluate').fadeOut();
                        $('.evaluate-success').fadeIn();
                        setTimeout(function() {
                                $('.evaluate-success').fadeOut();
                                $('.evaluate-mask').fadeOut();
                            },
                            2000);
                    } else {
                        alert(data.errmsg);
                    }
                }
            });
        }
       
        //alert('yes');
    }
     //$('.submit').click(function () {
     //  submit();
     //});
    function submit(){
      var area = $('.area').val();
      var username = $('.username').val();
      var city = $('.city').val();
      var mobile = $('.mobile').val();
      if (city == null || city == undefined || city == '') {
        alert("请输入城市")
        return false;
      }
      if (area == null || area == undefined || area == '') {
        alert("请输入面积")
        return false;
      } else if (!/^[0-9]+$/.test(area)) {
        alert("请输入数字")
        return false;
      }
      if (username == null || username == undefined || username == '') {
        alert("请输入姓名")
        return false;
      }
     
      if (mobile == null || mobile == undefined||mobile=='' ) {
        alert("请输入手机号")
        return false;
      } else {
        if (mobile.substring(0, 1) == 1 && !/^1[34578]\d{9}$/.test(mobile)) {
          alert("请输入正确的手机号")
          return false;
        } else if (!/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/.test(mobile)) {
          alert("请输入正确的手机号")
          return false;
        }
      }
    }


    //百度商桥
    $('.online-li,.right-now-click').click(function () {
        right_now()
    });
    function right_now() {
        window.open('http://p.qiao.baidu.com/cps/chat?siteId=11292512&userId=3473071');
    }

    //百度统计
    var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?bdfebf59039449f3da75e81e447060df"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();


});

(function(){
    var src = (document.location.protocol == "http:") ? "static/js/11.0.11.js":"static/js/11.0.1.js";
    document.write('<script src="' + src + '" id="sozz"><\/script>');
})();






