var params=parseQueryString(window.location.href) // 根据typeId来判断必填项 var selectObj={} // 当审核失败过之后,有传递参数hasError=1 // typeId=0时,优质--全部必填 var hasError=params.hasError?params.hasError:'' // 页面初始化 $().ready(function(){ // 获取贷款信息 getInfo(); clickRecord("openLink","链接打开")//链接打开 // typeId为1,本地社保必填 if(params.typeId==1) { $("#social_security_period").parents().eq(0).prepend("
*
") // typeId为2,本地公积金必填 }else if(params.typeId==2) { $("#loal_fund").parents().eq(0).prepend("
*
") } }) $("#city").on("tap",function(){ setLoanInfo("1"); }) // 设置贷款信息 $(".button").on("tap",function(){ clickRecord("loanButtonClick","贷款信息页下一步点击")//贷款信息页下一步点击 if(params.hasCode!=1) { setLoanInfo(); }else { if(params.typeId) { window.location.href="second.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode+"&typeId="+params.typeId }else { window.location.href="second.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode } } }) $(".top img").on("click",function(){ if(params.typeId==1) { window.location.href="shebaoLogin.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode }else if(params.typeId==2) { window.location.href="gjjLogin.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode }else if(params.typeId==3) { window.location.href="billLogin.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode }else if(params.typeId==4) { window.location.href="carLogin.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode }else if(params.typeId==5) { window.location.href="houseLogin.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode }else if(params.typeId==6) { window.location.href="insureLogin.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode }else if(params.typeId==7) { window.location.href="weiliLogin.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode }else if(!params.typeId) { window.location.href="login.html?source="+params.source }else if(params.typeId==0) { window.location.href="newLogin.html?source="+params.source } }) // 获取贷款信息 function getInfo() { $.ajax({ type:"post", url:"/user/getLoanInfo", dataType:'json', data:{ phone:params.phone, uid:params.uid, token:params.token, channel_id:params.source }, success: function (res){ if(res && res.errno == 0){ var data=res.rst.data // 贷款金额 $(".right input").val(data.loan_amount) // -1由于mui的下标是从0开始的 // 贷款期限 mobanData("贷款期限",loan_period,'loan_period',data.loan_period-1) // 贷款用途 mobanData("贷款用途",loan_purpose,'loan_purpose',data.loan_purpose-1) //职业身份 mobanData("职业身份",professional_identity,"professional_identity",data.professional_identity-1) // 本地社保 mobanData("本地社保",social_security_period,'social_security_period',data.social_security_period-1) // 公积金 mobanData("公积金",loal_fund,'loal_fund',data.loal_fund-1) selectObj.loan_period=data.loan_period; selectObj.loan_purpose=data.loan_purpose; selectObj.professional_identity=data.professional_identity; selectObj.social_security_period=data.social_security_period; selectObj.loal_fund=data.loal_fund; // 贷款城市 $("#city").text(params.city?params.city:data.loal_area?data.loal_area:"请选择所在城市>") params.city=params.city?params.city:data.loal_area?data.loal_area:"" if(params.city) { $("#city").text(params.city) $("#city").addClass("hasValue") selectObj.loal_area=params.city } if(params.city||data.loal_area) { $("#city").addClass("hasValue"); } if(params.typeId) { if(!selectObj.social_security_period&¶ms.typeId!=1&¶ms.typeId!=0){ // showMsg("请选择本地社保") selectObj.social_security_period=1 $("#social_security_period").text(social_security_period[0].text); $("#social_security_period").addClass("hasValue"); } if(!selectObj.loal_fund&¶ms.typeId!=2&¶ms.typeId!=0){ selectObj.loal_fund=1 $("#loal_fund").text(loal_fund[0].text); $("#loal_fund").addClass("hasValue"); } } }else{ showMsg(res.rst.msg) } }, error:function(){ showMsg("网络错误,请稍后再试"); } }); } // 设置贷款信息 function setLoanInfo(type){ // if(!selectObj.social_security_period&¶ms.typeId!=1&¶ms.typeId!=0){ // // showMsg("请选择本地社保") // selectObj.social_security_period=1 // $("#social_security_period").text(social_security_period[0].text); // $("#social_security_period").addClass("hasValue"); // } // if(!selectObj.loal_fund&¶ms.typeId!=2&¶ms.typeId!=0){ // selectObj.loal_fund=1 // $("#loal_fund").text(loal_fund[0].text); // $("#loal_fund").addClass("hasValue"); // } if($(".right input").val()<=0||$(".right input").val()>100) { showMsg("贷款金额请填写1-100的范围") }else if(!selectObj.loan_period){ showMsg("请选择贷款期限") }else if(!selectObj.loan_purpose){ showMsg("请选择贷款用途") }else if(!selectObj.professional_identity){ showMsg("请选择职业身份") }else if(!selectObj.social_security_period&¶ms.typeId==1){ showMsg("请选择本地社保") }else if(!selectObj.social_security_period&¶ms.typeId==0){ showMsg("请选择本地社保") }else if(!selectObj.loal_fund&¶ms.typeId==2){ showMsg("请选择本地公积金") }else if(!selectObj.loal_fund&¶ms.typeId==0){ showMsg("请选择本地公积金") }else if(selectObj.social_security_period==1&¶ms.typeId==1) { showMsg("社保时长不能为无") }else if(selectObj.loal_fund==1&¶ms.typeId==2) { showMsg("本地公积金不能为无") }else if(!selectObj.loal_area&&type!=1){ showMsg("请选择所在城市") }else{ $.ajax({ type:"post", url:"/user/setLoanInfo", dataType:'json', data:{ phone:params.phone, uid:params.uid, token:params.token, loan_amount:$(".right input").val(), loan_period:parseInt(selectObj.loan_period==-1?'':selectObj.loan_period), loan_purpose:parseInt(selectObj.loan_purpose==-1?'':selectObj.loan_purpose), professional_identity:parseInt(selectObj.professional_identity==-1?'':selectObj.professional_identity), social_security_period:parseInt(selectObj.social_security_period==-1?'':selectObj.social_security_period), loal_fund:parseInt(selectObj.loal_fund==-1?'':selectObj.loal_fund), loal_area:$("#city").text()=="请选择所在城市>"?"":$("#city").text(), channel_id:params.source }, success: function (res){ if(res && res.errno == 0){ var data=res.rst.data if(params.typeId) { if(type==1){ window.location.href="choose.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&city="+city+"&code="+params.code+"&typeId="+params.typeId }else { // 跳转到下个页面判断是否有审核失败记录 window.location.href="second.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&typeId="+params.typeId } }else { if(type==1){ window.location.href="choose.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&city="+city+"&code="+params.code }else { // 跳转到下个页面判断是否有审核失败记录 window.location.href="second.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code } } }else{ showMsg(res.rst.msg) } }, error:function(){ showMsg("网络错误,请稍后再试"); } }); } } //获取地址栏参数 function parseQueryString(url) { var urlObj = {}; var reg = /([^?=&]+)=([^?=&]+)/g; url.replace(reg, function($0, $1, $2) { urlObj[$1] = decodeURIComponent($2); }) return urlObj; } // 展示错误提示信息 function showMsg(msg) { $(".alert-info").show(); $(".alert-info p").text(msg); setTimeout(function() { $(".alert-info").hide(); }, 1000); } // 下拉列表初始化 function mobanData(title,data,dom,index){ var identityPicker = new mui.PopPicker(); identityPicker.setData(data,title); // 设置选中的下拉项 identityPicker.pickers[0].setSelectedIndex(index,2000) var identityDom = document.getElementById(dom); if(index>-1) { jQuery("#"+dom).text(data[index].text) jQuery("#"+dom).addClass("hasValue") } identityDom.addEventListener('tap', function(event) { identityPicker.show(function(items) { jQuery("#"+dom).text(items[0].text) jQuery("#"+dom).addClass("hasValue") selectObj[dom]=parseInt(items[0].value); }); }, false); } // 埋点 function clickRecord(eventId,eventName){ $.ajax({ url:"/user/clickRecord", type:"post", dataType:"json", data:{ event_id:eventId, event_name:eventName, channel_id:params.source }, success:function(res) { } }) }