<!doctype html>
<html>
<head>
    <title>{{#equal param.isHelper 1}}购车小秘{{else}}我要贷款{{/equal}}</title>
    <meta charset="utf-8">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="Author" content="wenqing_gz huangrongtao_gz"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <!-- uc强制竖屏 -->
    <meta name="screen-orientation" content="portrait">
    <!-- QQ强制竖屏 -->
    <meta name="x5-orientation" content="portrait">
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no">
    <!--忽略数字自动识别为电话号码-->
    <meta name="format-detection" content="telephone=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <link href="http://js.3conline.com/pcauto/2015/chedaiwap/css/loan2.css" rel="stylesheet" type="text/css" />
</head>
<body class="bg-white">
<!--栏目计数器-->
<script>document.body.insertBefore(document.createElement("script"),document.body.firstChild).src="http://count.pcauto.com.cn/count.php?channel=8474&screen="+screen.width+"*"+screen.height+"&refer="+encodeURIComponent(document.referrer)+"&anticache="+new Date().getTime()+"&url="+encodeURIComponent(location.href)+"&from=cms";</script>
<div class="g-doc" id="JimgLoad">
    <!--头部-->
    <script src="http://www.pcauto.com.cn/global/wap/header_js/" charset="utf-8" class=" defer"></script>
    <!--/头部-->
    <div class="header-bg">
        <a  {{#equal param.isHelper 1}}href="http://{{{@root.host}}}/{{#equal param.browser 'wx'}}wx/{{/equal}}" {{else}} onclick="history.back(-1)"{{/equal}} class="header-back" title=""></a>
        <div class="header-title">
            <span class="header-title-nav">

                {{#equal param.isHelper 1}}
                <a href="http://{{{@root.host}}}/">首页</a>>
                购车小秘{{else}}
                <a href="http://{{{@root.host}}}/choose/r{{param.rid}}/sg{{param.serialId}}/{{#equal param.browser 'wx'}}wx/{{/equal}}f{{{@root.flow}}}/">产品列表</a>>
                <a href="http://{{{@root.host}}}/choose/r{{param.rid}}/sg{{param.serialId}}-m{{param.modelId}}/{{#equal param.browser 'wx'}}wx/{{/equal}}f{{{@root.flow}}}/">产品详情</a>>
                 我要贷款{{/equal}}</span>
        </div>
    </div>
    {{#equal param.isHelper 0}}
    <div id="Jform">
        <ul class="m-time bg-white">
            <li class="m-plst-c">
                <div class="selectX" id="JselectX">
                    <div class="item-wrap" id="JitemWrap">
                        <div class="item item1">
                            <a class="tit">
                                <span class="mark"><div class="m-plst-txt">您的购车时间:</div><i>一个月内</i></span>
                                <span class="icon"></span>

                            </a>
                        </div>
                    </div>
                    <div class="pop-wrap" id="JpopWrap">
                        <div class="select-wrap" id="Jselect1">
                            <input type="hidden" name="" value="30" id="gcTime">
                            <div class="selectConA">
                                <i><a href="javascript:;" data-value="7">一周内</a></i>
                                <i class="cur"><a href="javascript:;"  data-value="30">一个月内</a></i>
                                <i ><a href="javascript:;"  data-value="90">三个月内</a></i>
                                <i><a href="javascript:;"  data-value="180">六个月内</a></i>
                                <i><a href="javascript:;"  data-value="200">六个月以上</a></i>
                            </div>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
        <div class="m-section m-form">
            <div class="u-txt"><input type="text" placeholder="请输入您的称呼（如夏先生）" id="chenghu"><i class="tred"></i></div>
            <div class="u-txt"><input type="text" placeholder="请输入手机号" id="telephone"><i class="tred"></i></div>
             <div class="u-txt-wrap">
                <div class="u-txt u-txt-1">
                    <input type="text" placeholder="请输入验证码" id="checkCode">
                    <i class="tred"></i>
                </div>
                <a href="javascript:;" class="u-btn-1" id="yzm">免费获取短信验证码</a>
            </div>
            <a href="javascript:void(0)" class="u-btn" id="u-btn">提交</a>

        </div>
    </div>
    {{/equal}}
    <div class="m-ques" style="{{#equal param.isHelper 1}}display:block;{{/equal}}">
        <div class="m-progressbar">
            <i></i>
            <i></i>
            <i></i>
            <i></i>
            <i></i>
            <i></i>
            <i></i>
        </div>
        <div class="m-wrap">
            <div class="m-content" id="slider">
                <div class="swipe-wrap">
                    <!--年龄-->
                    <div class="m-item" >
                        <div class="m-cont">
                            <div class="m-th">(<i>1</i>/7)申请人年龄：</div>
                            <ul class="m-age">
                                <li><em class="u-icon ageicon01"></em><em class="u-info" data-em="1">18-23岁</em></li>
                                <li><em class="u-icon ageicon02"></em><em class="u-info" data-em="2">24-29岁</em></li>
                                <li><em class="u-icon ageicon03"></em><em class="u-info"  data-em="3">30-39岁</em></li>
                                <li><em class="u-icon ageicon04"></em><em class="u-info" data-em="4">40-55岁</em></li>
                                <li><em class="u-icon ageicon05"></em><em class="u-info" data-em="5">56-65岁</em></li>
                            </ul>
                            <input type="hidden" id="Jage"/>
                        </div>
                    </div>
                    <!--学历-->
                    <div class="m-item" >
                        <div class="m-head" onclick="arrowclick(this,1)"><em class="m-arrow" ></em></div>
                        <div class="m-cont">
                            <div class="m-th">(<i>2</i>/7)学历：</div>
                            <ul class="m-edu">
                                <li><em class="u-icon eduicon01"></em><em class="u-info" data-em="6">中专</em></li>
                                <li><em class="u-icon eduicon02"></em><em class="u-info" data-em="7">大专</em></li>
                                <li><em class="u-icon eduicon03"></em><em class="u-info" data-em="8">本科</em></li>
                                <li><em class="u-icon eduicon04"></em><em class="u-info" data-em="9">硕士</em></li>
                                <li><em class="u-icon eduicon05"></em><em class="u-info" data-em="10">博士及以上</em></li>
                                <li><em class="u-icon eduicon06"></em><em class="u-info" data-em="11">其他</em></li>
                            </ul>
                            <input type="hidden" id="Jedu"/>
                        </div>
                    </div>
                    <!--婚姻-->
                    <div class="m-item" >
                        <div class="m-head" onclick="arrowclick(this,2)"><em class="m-arrow" ></em></div>
                        <div class="m-cont">
                            <div class="m-th">(<i>3</i>/7)婚姻状况：</div>
                            <ul class="m-marry">
                                <li><em class="u-icon marry01"></em><em class="u-info" data-em="12" >结婚</em></li>
                                <li><em class="u-icon marry02"></em><em class="u-info" data-em="13">单身</em></li>
                            </ul>
                            <input type="hidden" id="Jmarry"/>
                        </div>
                    </div>
                    <!--住房-->
                    <div class="m-item" >
                        <div class="m-head" onclick="arrowclick(this,3)"><em class="m-arrow" ></em></div>
                        <div class="m-cont">
                            <div class="m-th">(<i>4</i>/7)购车地住房情况：</div>
                            <ul class="m-house">
                                <li><em class="u-icon house01"></em><em class="u-info" data-em="14">租房</em></li>
                                <li><em class="u-icon house02"></em><em class="u-info" data-em="15">住在父母所在公寓</em></li>
                                <li><em class="u-icon house03"></em><em class="u-info" data-em="16">拥有自己房产</em></li>
                                <li><em class="u-icon house04"><b></b></em><em class="u-info" data-em="17">配偶名下有房产</em></li>
                            </ul>
                            <input type="hidden" id="Jhouse"/>
                        </div>
                    </div>
                    <!--工作-->
                    <div class="m-item">
                        <div class="m-head" onclick="arrowclick(this,4)"><em class="m-arrow" ></em></div>
                        <div class="m-cont">
                            <div class="m-th">(<i>5</i>/7)工作信息：</div>
                            <ul class="m-work">
                                <li><em class="u-icon work01"></em><em class="u-info" data-em="20">工薪人士</em></li>
                                <li><em class="u-icon work02"></em><em class="u-info" data-em="21">企业法人代表/股东</em></li>
                                <li><em class="u-icon work03"></em><em class="u-info" data-em="22">个体工商户</em></li>
                                <li><em class="u-icon work04"></em><em class="u-info" data-em="23">自由职业</em></li>
                            </ul>
                            <input type="hidden" id="Jwork"/>
                        </div>
                    </div>
                    <!--信用-->
                    <div class="m-item">
                        <div class="m-head" onclick="arrowclick(this,5)"><em class="m-arrow" ></em></div>
                        <div class="m-cont">
                            <div class="m-th">(<i>6</i>/7)个人信用情况-可多选：</div>
                            <ul class="m-credit">
                                <li><em class="u-icon credit01"></em><em class="u-info" data-em="24">有信用卡</em></li>
                                <li><em class="u-icon credit02"></em><em class="u-info" data-em="25">有房贷或已还完</em></li>
                                <li><em class="u-icon credit03"></em><em class="u-info" data-em="26">有车贷或已还完</em></li>
                                <li><em class="u-icon credit04"></em><em class="u-info" data-em="27">有其他类房贷</em></li>
                                <li><em class="u-icon credit05"></em><em class="u-info" data-em="28">没有以上信用情况</em></li>
                            </ul>
                            <input type="hidden" id="Jcredit"/>
                        </div>
                        <div class="m-btn"><a href="javascript:" class="u-btn u-btna" id="btncredit">下一步</a></div>
                    </div>
                    <!--收入-->
                    <div class="m-item" >
                        <div class="m-head"  onclick="arrowclick(this,6)"><em class="m-arrow"></em></div>
                        <div class="m-cont">
                            <div class="m-th">(<i>7</i>/7)税后年收入：</div>
                            <div class="m-income">
                                <div class="u-txt"><input type="text"  placeholder="示例10000元" id="Jincome"/></div>
                            </div>
                        </div>
                        <div class="m-btn"><a href="javascript:" class="u-btn u-btna" id="btnincome">
                            {{#equal param.isHelper "1"}}下一步{{else}}确认{{/equal}}</a></div>

                    </div>
                    <!--收入-->
                    <div class="m-item" >
                        <div class="m-head" onclick="arrowclick(this,7)"><em class="m-arrow" ></em></div>
                        <div class="m-cont">
                            <div class="m-th">请选择您的意向车型和城市：</div>
                            <div class="m-carncity">
                                <div class="u-txt">
                                    <a  href="javascript:void(0)" onclick="goHelperSelectModel()" class="u-selcar" id="Jcarmode">
                                        <input type="hidden" id="modelId">请选择心仪车型</a>
                                    <a href="javascript:void(0)" onclick="goCitySelect()" class="u-selcity" id="JcarCity">
                                        <input type="hidden" id="cityId">
                                        请选择城市</a>
                                </div>
                            </div>
                        </div>
                        <div class="m-btn">
                            <div class="u-btn u-btnb" id="btnconfirm1">确认</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="m-popbox" id="m-popbox">
    <div class="m-bg"></div>
    <div class="m-pop">
        <div class="m-th">
            <p id="m-poptxt"></p>
        </div>
        <div class="m-tb" id="m-tb" onclick="closePop()">确定</div>
    </div>
</div>
<script src="http://js.3conline.com/wap/2013/common/js/zepto.min.js"></script>
<!--<script src="http://js.3conline.com/pcauto/2015/chedaiwap/js/loan_form.js"  charset="utf-8"></script>-->
<script>
    var param={{{json param}}};
    var isChoosed=param.isChoosed;//已经被选择过了。
    var isHelper=param.isHelper;//购车小秘

    var Cookie = {
        get: function(check_name) {
            check_name = encodeURIComponent(check_name);
            var a_all_cookies = document.cookie.split(';');
            var a_temp_cookie = '';
            var cookie_name = '';
            var cookie_value = '';
            var b_cookie_found = false;
            var i = '';
            var len = a_all_cookies.length;
            for (i = 0; i < len; i++) {
                a_temp_cookie = a_all_cookies[i].split('=');
                cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
                if (cookie_name == check_name) {
                    b_cookie_found = true;
                    if (a_temp_cookie.length > 1) {
                        cookie_value = unescape(decodeURI(a_temp_cookie[1]).replace(/^\s+|\s+$/g, ''));//对url进行解码再进行处理
                    }
                   // return cookie_value;
                  //  break;
                }
                a_temp_cookie = null;
                cookie_name = '';
            }
            if(b_cookie_found){
                return cookie_value;
            }else{
                return null;
            }
        },
        set: function(name, value, expires, path, domain, secure) {
            var today = new Date();
            today.setTime(today.getTime());
            if (expires) {
                expires = expires * 1000 * 60 * 60 * 24;
            }
            var expires_date = new Date(today.getTime() + (expires));
            document.cookie = encodeURIComponent(name) + "=" + value +
                    ((expires) ? ";expires=" + expires_date.toGMTString() : "") +
                    ((path) ? ";path=" + path : "") +
                    ((domain) ? ";domain=" + domain : "") +
                    ((secure) ? ";secure" : "");
        },
        remove: function(name) {
            Cookie.set(name,null, -1, "/", "{{{@root.cookieHost}}}");
        }
    };
    if(isChoosed==1){//处理非
        if(param.isCitySelect==undefined)param.isCitySelect=0;
        if(param.isCitySelect==0&&!Cookie.get("queModel")){
            location.href="http://{{{@root.host}}}/";
        }else if(param.isCitySelect==1){
            if(Cookie.get("isCitySelect")!=param.isCitySelect){
                location.href="http://{{{@root.host}}}/";
            }
        }

    }


    function goCitySelect(){
        Cookie.set("isCitySelect",1,1,"/","{{{@root.cookieHost}}}");
        location.href="http://m.pcauto.com.cn/x/selectcity/jr/?returns=http://{{{@root.host}}}/loan/h1/{{#equal param.browser 'wx'}}wx/{{/equal}}f{{{@root.flow}}}/?isCitySelect=1";
    }
    //跳转到车
    function  goHelperSelectModel(){
        Cookie.set("selectHelperBrand",1,1,"/","{{{@root.cookieHost}}}");
        location.href="http://{{{@root.host}}}/helper/{{#equal param.browser 'wx'}}wx/{{/equal}}f{{{@root.flow}}}/";
    }

    //获取id
    function $$(id) {
        return (typeof id == "object") ? id : document.getElementById(id);
    }
    /*******************弹窗***********************/
    function openPop(str){
        document.getElementById("m-poptxt").innerHTML = str;
        document.getElementById("m-popbox").style.display = "block";
    }
    function closePop(){
        document.getElementById("m-popbox").style.display = "none";
    }
    /*******************弹窗***********************/
    /******************表单输入效果***********************/
    function inputValue(elem,tips){
        var gct = $$(elem);
        //有默认，自动获取先。
        if(gct.parentNode.getElementsByTagName("i")){
            var gcti = gct.parentNode.getElementsByTagName("i");
            var gctin = gcti.length;
            for(var i=0;i<gctin;i++){
                if(gcti[i].className.indexOf("cur")!=-1){
                    gct.value= gcti[i].childNodes[0].getAttribute("data-value");
                }
            }
        }
        if(!gct.value){openPop(tips); return false}
    }

    //显示提示语
    function showTips(obg,str){
        if(obg.parentNode.getElementsByTagName("i").length>0){
            var obi = obg.parentNode.getElementsByTagName("i")[0];
            if(obi.className.indexOf("tred")!=-1){
                obi.style.display = "block";
                obi.innerHTML = str;
            }
        }

    }

    //隐藏tred
    function htred(){
        if(document.querySelectorAll(".tred").length>0){
            var bii = document.querySelectorAll(".tred");
            var bii = document.querySelectorAll(".tred");
            var biin = bii.length;
            for(var i=0;i<biin;i++){
                bii[i].style.display = "none";
            }
        }
    }

    (function(){
        /*
         表单项目
         电话(验证)、称呼(验证)、验证码(验证)、购车时间(验证)、推荐经销商(非验证)
         */
        if(isHelper==1){
            formSub();
        }else {
          //  console.log(Cookie.get("initialRequest")+"===>{{{staticUrl}}}")
            if(Cookie.get("initialRequest")=="{{{staticUrl}}}") {
                if (Cookie.get("loanInfo")) {//用户一级订单信息
                    formSub();
                } else {
                    var ubtnD = document.getElementById("u-btn");
                    if (ubtnD) {
                        ubtnD.onclick = function () {
                            //假设全对
                            var isOk = true;
                            //隐藏tred
                            htred();
                            var tel = document.getElementById("telephone");
                            if (tel) {
                                if (!tel.value) {
                                    showTips(tel, "请输入手机号");
                                    isOk = false;
                                }
                                if (!(/^1[3|4|5|8][0-9]\d{8}$/.test(tel.value))) {
                                    showTips(tel, "请输入正确的手机号");
                                    isOk = false;
                                }
                            }
                            var chenghuD = document.getElementById("chenghu");
                            if (chenghuD) {
                                var value1 = chenghuD.value.replace(/^\s+|\s+$/g, '');
                                if (!value1) {
                                    showTips(chenghuD, "请输入您的称呼");
                                    isOk = false;
                                }
                                if (chenghuD.value.length > 5) {
                                    showTips(chenghuD, "请填写5位数的称呼");
                                    isOk = false;
                                }
                            }
                            var ckc = document.getElementById("checkCode");
                            if (ckc) {
                                if (!ckc.value) {
                                    showTips(ckc, "请输入验证码");
                                    isOk = false;
                                }

                                //检查 验证码
                                if (checkCode(tel.value, ckc.value)) {
                                    //验证通过
                                } else {
                                    showTips(ckc, "验证码错误，请重试");
                                    isOk = false;
                                }
                            }

                            //购车时间
                            if (document.getElementById("gcTime")) {
                                inputValue("gcTime", "请选择购车时间");
                            }
                            if (isOk == false) {
                                return false;
                            }
                            orderFirst();
                        }
                    }
                }
            }else {
               location.href="http://{{@root.host}}/";//跳转
            }
        }

        //城市初始化
        var locationMap=JSON.parse(Cookie.get("locationWap"));
        var cityId =locationMap.regionCity;
        var cityName = locationMap.city;
        $("#JcarCity").html(cityName.toString().replace("市",""));
        $("#cityId").val(cityId);
        if(isChoosed==1){
            getLoadData();
        }else if(!(param.isChooseBack&&Cookie.get("confirmInfo"))){
            removeCookies();
        }
    })();


    //删除协带信息
    function removeCookies(){
        Cookie.remove("queage");
        Cookie.remove("queedu");
        Cookie.remove("quemarry");
        Cookie.remove("quehouse");
        Cookie.remove("quework");
        Cookie.remove("quecredit");
        Cookie.remove("queincome");
        Cookie.remove("queModel");
    }
    /*************************验证码时间倒计时[ps:如果需要倒计时则加上这段js]********************/
    var gotime=1;
    var f=60;
    function settime(){
        var yzmD= document.getElementById("yzm");
        yzmD.innerHTML=f+"秒后可重新发送";
        if(f<=0){
            yzmD.innerHTML="免费获取短信验证码";
            yzmD.style.color="#fff";
            yzmD.style.fontSize="16px";
            gotime=1;
        }else{
            gotime=0;
            f-=1;
            setTimeout('settime();',1000);
        }
    }
    if(document.getElementById("yzm")) {
        var yzmD=document.getElementById("yzm");
        yzmD.onclick = function () {
            var isOk = true;
            var tel=document.getElementById("telephone");
            var phone =tel.value;
            if (tel){
                if (!tel.value) {
                    showTips(tel, "请输入手机号");
                    isOk = false;
                }
                if (!(/^1[3|4|5|8][0-9]\d{8}$/.test(tel.value))) {
                    showTips(tel, "请输入正确的手机号");
                    isOk = false;
                }
            }
            if (!isOk) return;
            if (gotime == 0) {
                return;
            }
            f = 60;
            yzmD.style.color = "#333";
            yzmD.style.fontSize = "12px";
            var url = "http://{{{@root.host}}}/jrproxy/jr.pcauto.com.cn/interface/outer/mobile/sendCode.jsp?phone=" + tel.value;
            confirmAjax(url, "", function (data) {
                            //data.code==0表发送成功
                            if (data.code == 0) {
                                console.log("发送验证码成功");
                            }
                        });
            settime();
        }
    }
    // 检查 验证码
    function checkCode(phone,checkCode){
        return true;
    }

    // 提交数据
    function formSub(){
        //具体获取表单可以通过这里提交，已经检查过数据了。
        $('#Jform').hide()
        $('.m-ques').show();
        needJsLoad();
    }

    function needJsInit(){
        var age = Cookie.get("queage");
        $(".m-age").find(".u-info").each(function () {
            if ($(this).attr("data-em") == age) {
                $(this).parent().addClass("cur");
            }
        });

        var edu = Cookie.get("queedu");
        $(".m-edu").find(".u-info").each(function () {
            if ($(this).attr("data-em") == edu) {
                $(this).parent().addClass("cur");
            }
        });

        var marry = Cookie.get("quemarry");
        $(".m-marry").find(".u-info").each(function () {
            if ($(this).attr("data-em") == marry) {
                $(this).parent().addClass("cur");
            }
        });
        if(marry==13)$(".m-house .u-icon").eq(3).addClass("disabled");



        var house =Cookie.get("quehouse");
        $(".m-house").find(".u-info").each(function () {
            if ($(this).attr("data-em") == house) {
                $(this).parent().addClass("cur");
            }
        });



        var work = Cookie.get("quework");
        $(".m-work").find(".u-info").each(function () {
            if ($(this).attr("data-em") == work) {
                $(this).parent().addClass("cur");
            }
        });


        var credit = Cookie.get("quecredit");
        if(credit!=null) {
        $(".m-credit").find(".u-info").each(function () {
                var creditArr = credit.split(",");
                for(var i=0;i<creditArr.length;i++) {
                    if ($(this).attr("data-em") == creditArr[i]) {
                        $(this).parent().addClass("cur");
                    }
                }

        });
        }

        var income = Cookie.get("queincome");
        $("#Jincome").val(income);

        var queModel=Cookie.get("queModel");
        if(queModel!=null)
        {
            var queModel=JSON.parse(queModel);
            $("#Jcarmode").html(queModel.modelName);
            $("#modelId").val(queModel.modelId);
        }
        $('.m-progressbar i').addClass("cur");
    }


    function checkNumber(str,flg){//flg用于判断是否是正整数
        var patternT = /^[1-9]\d{0,20}$/g;
        if(flg) patternT = /^[0-9]\d{0,20}$/g;
        var result = new RegExp(patternT);
        return result.test(str);
    }
    function needJsLoad(){
        //切换
           var startSlide=isChoosed==1?7:0;

         if(param.isChooseBack==1&&Cookie.get("confirmInfo")) {
             startSlide=6;
         }



        if(isChoosed==1||startSlide==6) needJsInit();
        if(startSlide==7)$(".m-item").eq(startSlide).siblings().addClass('ftop');
        if(startSlide==6)$(".m-item").slice(0, 6).addClass("ftop");
        var statubars=$('.m-progressbar i');
        var item = $('m-item');
        var tocAge=$('.m-age').find('li');
        var tocEdu=$('.m-edu').find('li');
        var tocMarry=$('.m-marry').find('li');
        var tocHouse=$('.m-house').find('li');
        var tocWork=$('.m-work').find('li');
        var arrow = $('.m-item .m-head').find('em');
        function status(toc,index){
            toc.each(function(k,elem){
                $(this).bind('click',function(){
                    statubars.eq(index).addClass('cur');
                    if(!$(this).children("em").eq(0).hasClass("disabled")) {
                        $(this).addClass('cur').siblings().removeClass('cur');
                        if ($(this).hasClass('cur')) {
                            var pp = $(this).parent().parent().parent();
                            $(this).addClass('cur').siblings().removeClass('cur');
                            if ($(this).hasClass('cur')) {
                                var txt = $(this).children(".u-info").attr("data-em");
                                if (txt == 13) {//特殊处理单身时房子问题
                                    $(".m-house .u-icon").eq(3).addClass("disabled");
                                    if (tocHouse.eq(3).hasClass('cur'))tocHouse.eq(3).removeClass("cur");
                                } else {
                                    $(".m-house .u-icon").eq(3).removeClass("disabled");
                                }

                                if (pp.find(".m-age").length != 0) {
                                    Cookie.set('queage', txt, 1, "/", "{{{@root.cookieHost}}}");
                                }
                                if (pp.find(".m-edu").length != 0) {
                                    Cookie.set('queedu', txt, 1, "/", "{{{@root.cookieHost}}}");
                                }

                                if (pp.find(".m-marry").length != 0) {
                                    Cookie.set('quemarry', txt, 1, "/", "{{{@root.cookieHost}}}");
                                }
                                if (pp.find(".m-house").length != 0) {
                                    Cookie.set('quehouse', txt, 1, "/", "{{{@root.cookieHost}}}");
                                }
                                if (pp.find(".m-work").length != 0) {
                                    Cookie.set('quework', txt, 1, "/", "{{{@root.cookieHost}}}");
                                }

                                if (index == 3 && Cookie.get("quemarry") == 13) {
                                    $(".m-house .u-icon").eq(3).addClass("disabled");
                                    if (tocHouse.eq(3).hasClass('cur'))tocHouse.eq(3).removeClass("cur");
                                }
                            }
                            setTimeout(function () {
                                pp.attr('style', 'margin-top:-430px;display:block;')
                            }, 300)
                        }
                        var kk = Number(index) + 2;
                    }

                });

            })

        }
        status(tocAge,'0')
        status(tocEdu,'1')
        status(tocMarry,'2')
        status(tocHouse,'3')
        status(tocWork,'4')


        var toc=$(".m-credit").find('li');
        toc.each(function(k,elem){
            $(this).bind('click',function(){
                statubars.eq(5).addClass('cur');
                if(k==4){
                    $(this).addClass('cur').siblings().removeClass('cur');
                }else if($(this).hasClass('cur')){
                    toc.eq(4).removeClass('cur')
                    $(this).removeClass('cur');
                }else{
                    toc.eq(4).removeClass('cur')
                    $(this).addClass('cur');
                }
            })
        });
        var btncredit=$('#btncredit');
        var btnconfirm=$('#btnconfirm1');
        var btninconme=$('#btnincome');
        btncredit.bind('click',function(){
            if($(".m-credit .cur").length==0){
                openPop("请先选择")
            }else{
                var txt=$('.m-credit li.cur .u-info');
                var html ="";
                txt.each(function(k,elem){
                    var text=txt.eq(k).attr("data-em");;
                    html += text+',';
                })
                if(html.substr(html.length-1)==",")html=html.substr(0,html.length-1);
                Cookie.set('quecredit',html,1, "/", "{{{@root.cookieHost}}}");
              //  setTimeout(function(){window.mySwipe.slide(6,300)},300)
                var mbox = $(this).parent().parent();
                setTimeout(function(){mbox.attr('style','margin-top:-430px;display:block;')},300)
            }

        })
        btninconme.bind('click',function(){
            var txt=$('#Jincome').val();
            if(txt==""||!checkNumber(txt)){
                openPop("年收入必须为正整数");
            }else{
                Cookie.set('queincome',txt,1, "/", "{{{@root.cookieHost}}}");
                orderSecond();
                if(isHelper==1){
                    var mbox = $(this).parent().parent();
                    Cookie.set("selectHelperBrand",1,1,"/","{{{@root.cookieHost}}}");
                    setTimeout(function(){mbox.attr('style','margin-top:-430px;display:block;')},300);
                }
            }


        });
        btnconfirm.bind('click',function(){
            suc(function(qualification){
                var isOk=true;
                var locationMap=JSON.parse(Cookie.get("locationWap"));
                var cityId =locationMap.regionCity;
                param.regionId=cityId;
                param.qualification=qualification;
                if(isHelper==1) {
                    var cityId = $("#cityId").val();
                    var modelId = $("#modelId").val();
                    var model = JSON.parse(Cookie.get("queModel"));
                    if (model != null) param.modelId = model.modelId;
                    if ($("#JcarCity").html() == "" || $("#Jcarmode").html() == "") {
                        isOk = false;
                    }
                }
                if(isChoosed) {
                    //  orderSecond();//二级订单
                    if(isChoosed==1) {
                        var model=JSON.parse(Cookie.get("queModel"));
                        param.modelId=model.modelId;
                    }
                    $('.m-progressbar i').eq(6).addClass('cur');
                    if(cityId==""||modelId==""){
                        if(modelId==""){
                            openPop("请选择您的心仪车型");
                        }else{
                            openPop("您有题目没完成");
                        }
                      //  window.mySwipe.slide(7,300);
                        isOk=false;
                        return ;
                    }
                }

                if(isOk){
                    Cookie.remove("isCitySelect");//清掉cookie
                    Cookie.set("confirmInfo", encodeURI(JSON.stringify(param)), 1, "/", "{{{@root.cookieHost}}}");
                    location.href = "http://{{{@root.host}}}/goodRecommend/r" + param.rid + "/h1"+
                            "-m"+param.modelId+"/"+getWx()+"f{{{@root.flow}}}/?qua="+JSON.stringify(qualification);
                }

            });

        });
    }



    function arrowclick(elem,index1){
        $(elem).bind('click',function(){
            $(elem).parent().prev().attr('style','margin-top:0;display:block');
            $('.m-progressbar i').eq(index1).removeClass('cur');
            if(index1==4){
                if(Cookie.get("quemarry")==13){
                    $(".m-house .u-icon").eq(3).addClass("disabled");
                }
            }

        })

    }

    //题目完成提交
    function suc(callback){
            askAge=Cookie.get('queage');
            askEdu=Cookie.get('queedu');
            askMarry=Cookie.get('quemarry');
            askHouse=Cookie.get('quehouse');
            askWork=Cookie.get('quework');
            askCredit=Cookie.get('quecredit');
            askIncome=Cookie.get('queincome');
           if(isHelper==1){
                //setTimeout(function(){window.mySwipe.slide(7,300)},300);
               var mbox = $(this).parent().parent();
               setTimeout(function(){mbox.attr('style','margin-top:-430px;display:block;')},300)
            }

            var qualification = {};
            qualification.age = askAge;
            qualification.annualIncome = askIncome;
            qualification.creditSituation = askCredit;
            qualification.education = askEdu;
            qualification.housingSituation = askHouse;
            qualification.maritalStatus = askMarry;
            qualification.profession = askWork;
           callback(qualification);
    }

    /****************一级订单**************/
    function orderFirst(){
       var telephone=$("#telephone").val();
       var chenghu=$("#chenghu").val();
       var gcTime=$("#gcTime").val();
        var checkCode=$("#checkCode").val();
        param.phone=telephone;
        param.name=chenghu;
        param.buyTime=gcTime;
        param.level=1;
        param.regionId=param.rid;
        param.channelType=is_weixinSrc();
        var sendUrl="http://{{{@root.host}}}/jrproxy/jr.pcauto.com.cn/interface/outer/mobile/checkCode.jsp?phone="+telephone+"&code="+checkCode;
        confirmAjax(sendUrl,"",function(data){
            if(data.code==0){
               // if(data.isOrdered==1){
                    var loanInfo={"phone":telephone,"name":chenghu};;
                    Cookie.set('loanInfo',encodeURI(JSON.stringify(loanInfo)),1, "/", "{{{@root.cookieHost}}}");//设置登录cookie
        var url="http://{{{@root.host}}}/jrproxy/jr.pcauto.com.cn/interface/outer/mobile/apply.jsp";
                    var params= {"data": JSON.stringify(param)};
                    //一级订单
                    confirmAjax(url,params,function(data){//返回参数
                        if(data.code==0){
                            param.orderId=data.id;//保存OrderId
                            formSub();//一级资质开始
                        }
                    });
               // }
            }else{
                var ckc = document.getElementById("checkCode");
                showTips(ckc,"验证码错误，请重试");
            }
        });


    }



    /****************二级订单**************/
    /**
     * des:二级订单 ,ps:三级订单在goodRecommend页面
     */
    function orderSecond(){
        suc(function(qualification){
            param.level=2;
            param.qualification=qualification;
            var locationMap=JSON.parse(Cookie.get("locationWap"));
            var cityId =locationMap.regionCity;
            param.regionId=cityId;
            if(isHelper!=1&&!param.phone) {
                param.phone=JSON.parse(Cookie.get("loanInfo")).phone;
            }//得到电话号码
            if(isHelper!=1&&!param.name) {
                param.name=JSON.parse(Cookie.get("loanInfo")).name;
            }
            if(isHelper!=1&&!param.buyTime) {
                param.buyTime=JSON.parse(Cookie.get("loanInfo")).buyTime;
            }
           param.channelType=is_weixinSrc();
            var url="http://{{{@root.host}}}/jrproxy/jr.pcauto.com.cn/interface/outer/mobile/apply.jsp";
            var params= {"data": JSON.stringify(param)};
            if(isHelper!=1) {
                confirmAjax(url,params, function (data) {//返回参数
                    //formSub();//
                    if(data.code==0){
                        param.orderId = data.id;//保存OrderId
                        param.level = 3;//为3级订单准备
                        Cookie.set("confirmInfo", encodeURI(JSON.stringify(param)), 1, "/", "{{{@root.cookieHost}}}");
                        location.href = "http://{{{@root.host}}}/goodRecommend/r" + param.rid + "/h0"+"-m"+param.modelId+
                        "-org"+param.orgId+"-pro"+param.productId+"-p"+param.periods+"-s"+param.downPayment+"-tel"+param.phone+"/"+getWx()+'f{{{@root.flow}}}/'+"?qua="+JSON.stringify(qualification)
                        +"&parentURL="+window.parent.document.URL.replace("http://","");
                  }
                });
            }
        });
    }


    function confirmAjax(url,params,callback){
        //代理处理ajax异步请求

        $.ajax({
            url: url,
            data:params,
            timeout : 15000,
            type:'POST',
            dataType:"json",
            error: function(){
             console.log("ajax error");
            },
            success: function (data) {//一级订单提交成功
              //  console.log("提交的参数：isHelper"+param.isHelper+"==>level:"+param.level+JSON.stringify(params))
//                console.log("提交结果如下\n");
                console.log(data);
                callback(data);
            }
        });
    }



    function getLoadData() {
        $(".m-progressbar i").addClass("cur");
        var name = Cookie.get("quename");
        if (name) {
            $("#chenghu").val(name);
        }
        var phone = Cookie.get("quephone");
        if (phone) {
            $("#telephone").val(phone);
        }
    }

    //是否是微信端输入
    function  getWx(){
        var str="";
        if(param.browser=="wx"){
            str="wx/";
        }
        return str;
    }


    function is_weixinSrc() {
        var ua = navigator.userAgent.toLowerCase();
        return (/micromessenger/.test(ua)) ? 5 : 2 ;
    }


</script>

</body>
</html>