var params=parseQueryString(window.location.href) var selectObj={}; var hasError=params.hasError?params.hasError:"" $().ready(function(){ clickRecord("openLink","链接打开")//链接打开 getInfo(); // typeId=0时,优质--全部必填 // typeId=3时,流水--月收入,收入形式,信用卡额度 // typeId=4时,车抵--名下车产,车产估值 // typeId=5,房抵 // typeId=6,寿险 // typeId=7,微粒贷--全都可以自动填写 if(params.typeId==3) { $("#month_income").parents().eq(0).prepend("
*
") $("#income_type").parents().eq(0).prepend("
*
") $("#credit_card_quota").parents().eq(0).prepend("
*
") }else if(params.typeId==4) { $("#has_car").parents().eq(0).prepend("
*
") }else if(params.typeId==5) { $("#has_house").parents().eq(0).prepend("
*
") }else if(params.typeId==6) { $("#has_Insurance").parents().eq(0).prepend("
*
") } }) $(".button").on("click",function(){ clickRecord("assetButtonClick","资产信息页下一步点击")//下一步 if(params.hasCode!=1) { selectObj.wx_load_quota=$("#weiliValue").val()?$("#weiliValue").val():selectObj.wx_load_quota; selectObj.sesame_credit=$("#zhimaValue").val()!=0?$("#zhimaValue").val():selectObj.sesame_credit; setUserInfo(); }else { if(params.typeId) { window.location.href="identity.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="identity.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) { window.location.href="index.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="index.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&hasCode="+params.hasCode } }) // 获取贷款信息 function getInfo() { $.ajax({ type:"post", url:"/user/getUserInfo", 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 // -1由于mui的下标是从0开始的 // 学历 mobanData("最高学历",educational,'educational',data.educational-1) // 月收入 mobanData("月收入",month_income,'month_income',data.month_income-1) // 收入形式 mobanData("收入形式",income_type,'income_type',data.income_type-1) // 信用卡额度 mobanData("信用卡额度",credit_card_quota,'credit_card_quota',data.credit_card_quota-1) // 微粒贷(微粒贷的最小值是0) mobanData("微粒贷",wx_load_quota,'wx_load_quota',data.wx_load_quota) // 芝麻分 mobanData("芝麻分",sesame_credit,'sesame_credit',data.sesame_credit) // 名下房产 mobanData("名下房产",has_house,'has_house',data.has_house-1) // 房产估值 mobanData("房产估值",house_value,"house_value",data.house_value-1) //名下车产 mobanData("名下车产",has_car,"has_car",data.has_car-1) // 车产估值 mobanData("车产估值",car_value,"car_value",data.car_value-1) // 个人保险 mobanData("个人保险",has_Insurance,'has_Insurance',data.has_Insurance-1) //投保类型 // mobanData("投保信息",insInf,"insInf",0) // 投保公司 mobanData("投保公司",Insurance_company,"Insurance_company",data.Insurance_company-1) // 投保金额 mobanData("投保金额",Insurance_value,"Insurance_value",data.Insurance_value-1) selectObj.educational=data.educational; selectObj.month_income=data.month_income; selectObj.income_type=data.income_type; selectObj.credit_card_quota=data.credit_card_quota; selectObj.wx_load_quota=data.wx_load_quota; selectObj.sesame_credit=data.sesame_credit; selectObj.has_house=data.has_house; selectObj.house_value=data.house_value; selectObj.has_car=data.has_car; selectObj.car_value=data.car_value; selectObj.has_Insurance=data.has_Insurance; // selectObj.insInf=data.insInf?data.insInf:0; selectObj.car_value=data.car_value; selectObj.Insurance_company=data.Insurance_company; selectObj.Insurance_value=data.Insurance_value; // 贷款城市 $("#city").text(params.city?params.city:data.loal_area?data.loal_area:"请选择所在城市>") city=params.city?params.city:data.loal_area?data.loal_area:"请选择所在城市>" if(params.typeId) { if(selectObj.has_house&&selectObj.has_house!=1) { jQuery(".house_value").attr("style","display:flex"); } if(selectObj.has_car>2){ jQuery(".car_value").attr("style","display:flex"); } // 当选择了投保时,判断是否选择了投保公司和保单价值 if(selectObj.has_Insurance!=1) { // 投保公司 if(selectObj.Insurance_company>=1){ jQuery(".Insurance_company").attr("style","display:flex"); jQuery(".insInf").attr("style","display:flex;"); } if(selectObj.Insurance_value>=1) { jQuery(".Insurance_value").attr("style","display:flex"); jQuery(".insInf").attr("style","display:flex;") mobanData("投保信息",insInf,"insInf",1) } } if(params.typeId!=0&&!selectObj.educational) { selectObj.educational=1 $("#educational").text(educational[0].text); $("#educational").addClass("hasValue"); // showMsg("请选择学历"); // return false; } if(params.typeId!=3&¶ms.typeId!=0&&!selectObj.month_income) { selectObj.month_income=1 $("#month_income").text(month_income[0].text); $("#month_income").addClass("hasValue"); // showMsg("请选择月收入"); // return false; } if(params.typeId!=3&¶ms.typeId!=0&&!selectObj.income_type){ selectObj.income_type=1 $("#income_type").text(income_type[0].text); $("#income_type").addClass("hasValue"); // showMsg("请选择收入形式"); // return false; } if(params.typeId!=3&¶ms.typeId!=0&&!selectObj.credit_card_quota) { selectObj.credit_card_quota=1 $("#credit_card_quota").text(credit_card_quota[0].text); $("#credit_card_quota").addClass("hasValue"); // showMsg("请选择信用卡额度"); // return false; } if(params.typeId!=0&&!selectObj.wx_load_quota) { selectObj.wx_load_quota=0 $("#wx_load_quota").text(wx_load_quota[0].text); $("#wx_load_quota").addClass("hasValue"); // showMsg("请选择微粒贷"); // return false; } if(params.typeId!=0&&!selectObj.sesame_credit) { selectObj.sesame_credit=0 $("#sesame_credit").text(sesame_credit[0].text); $("#sesame_credit").addClass("hasValue"); // showMsg("请选择芝麻分"); // return false; } if(params.typeId!=5&¶ms.typeId!=0&&!selectObj.has_house) { selectObj.has_house=1 $("#has_house").text(has_house[0].text); $("#has_house").addClass("hasValue"); // showMsg("请选择名下房产"); // return false; } if(params.typeId!=4&¶ms.typeId!=0&&!selectObj.has_car) { selectObj.has_car=1 $("#has_car").text(has_car[0].text); $("#has_car").addClass("hasValue"); } if(params.typeId!=6&¶ms.typeId!=0&&!selectObj.has_Insurance) { selectObj.has_Insurance=1 $("#has_Insurance").text(has_Insurance[0].text); $("#has_Insurance").addClass("hasValue"); selectObj.Insurance_company=0; selectObj.Insurance_value=0; } } }else{ showMsg(res.rst.msg) } }, error:function(){ showMsg("网络错误,请稍后再试"); } }); } // 设置资产信息 function setUserInfo(){ for(var i in selectObj) { // if(i!="car_value"&&i!="house_value") { if(!selectObj[i]) { console.log("开始") console.log(i) if(params.typeId) { if(i=="educational"&¶ms.typeId==0) { showMsg("请选择学历"); return false; } if(i=="month_income"&¶ms.typeId==0) { showMsg("请选择月收入"); return false; } if(i=="income_type"&¶ms.typeId==0){ showMsg("请选择收入形式"); return false; } if(i=="credit_card_quota"&¶ms.typeId==0) { showMsg("请选择信用卡额度"); return false; } if(i=="wx_load_quota"&¶ms.typeId==0&&selectObj["wx_load_quota"]!==0) { showMsg("请选择微粒贷"); return false; } if(i=="sesame_credit"&¶ms.typeId==0&&selectObj["sesame_credit"]!==0) { showMsg("请选择芝麻分"); return false; } if(i=="has_house"&¶ms.typeId==0) { showMsg("请选择名下房产"); return false; } if(i=="has_car"&¶ms.typeId==0) { showMsg("请选择名下车产"); return false; } if(i=="has_Insurance"&¶ms.typeId==0) { showMsg("请选择个人保险"); return false; } if(i=="credit_card_quota"&¶ms.typeId==3&&selectObj[i]==1) { showMsg("信用卡额度信息不能为无"); return false; } if(params.typeId==3&&i=="month_income"){ showMsg("请选择月收入"); return false; // 流水,收入形式为空 }else if(params.typeId==3&&i=="income_type"){ showMsg("请选择收入形式"); return false; }else if(params.typeId==3&&i=="credit_card_quota"){ showMsg("请选择信用卡额度"); return false; // 车产 }else if(params.typeId==4&&i=="has_car"){ showMsg("请选择名下车产"); return false; // 房产 }else if(params.typeId==5&&i=="has_house"){ showMsg("请选择名下房产"); return false; }else if(params.typeId==6&&i=="has_Insurance"){ showMsg("请选择个人保险"); return false; }else if(i=="has_Insurance"&&selectObj[i]!=1) { if(!selectObj["Insurance_company"]) { showMsg("请选择投保公司") return false; }else if(!selectObj["Insurance_value"]) { showMsg("请选择投保金额"); return false; } } // 有车时,has_Car=1 if(selectObj["has_car"]>2&&i=="car_value") { showMsg("请选择车产估值"); return false; }else if(selectObj["has_house"]!=1&&i=="house_value") { showMsg("请选择房产估值"); return false; }else if(i=="Insurance_company"&&selectObj["has_Insurance"]!=1) { showMsg("请选择投保公司") return false; }else if(i=="Insurance_value"&&selectObj["has_Insurance"]!=1) { showMsg("请选择投保金额"); return false; } }else { if(i=="educational") { showMsg("请选择学历"); return false; } if(i=="month_income") { showMsg("请选择月收入"); return false; } if(i=="income_type"){ showMsg("请选择收入形式"); return false; } if(i=="credit_card_quota") { showMsg("请选择信用卡额度"); return false; } if(i=="wx_load_quota"&&selectObj["wx_load_quota"]!==0) { showMsg("请选择微粒贷"); return false; } if(i=="sesame_credit"&&selectObj["sesame_credit"]!==0) { showMsg("请选择芝麻分"); return false; } if(i=="has_house") { showMsg("请选择名下房产"); return false; } if(i=="has_car") { showMsg("请选择名下车产"); return false; } if(i=="has_Insurance") { showMsg("请选择个人保险"); return false; } if(i=="credit_card_quota"&&selectObj[i]==1) { showMsg("信用卡额度信息不能为无"); return false; } if(i=="month_income"){ showMsg("请选择月收入"); return false; // 流水,收入形式为空 }else if(i=="income_type"){ showMsg("请选择收入形式"); return false; }else if(i=="credit_card_quota"){ showMsg("请选择信用卡额度"); return false; // 车产 }else if(i=="has_car"){ showMsg("请选择名下车产"); return false; // 房产 }else if(i=="has_house"){ showMsg("请选择名下房产"); return false; }else if(i=="has_Insurance"){ showMsg("请选择个人保险"); return false; }else if(i=="has_Insurance"&&selectObj[i]!=1) { if(!selectObj["Insurance_company"]) { showMsg("请选择投保公司") return false; }else if(!selectObj["Insurance_value"]) { showMsg("请选择投保金额"); return false; } } // 有车时,has_Car=1 if(selectObj["has_car"]>2&&i=="car_value") { showMsg("请选择车产估值"); return false; }else if(selectObj["has_house"]!=1&&i=="house_value") { showMsg("请选择房产估值"); return false; }else if(i=="Insurance_company"&&selectObj["has_Insurance"]!=1) { showMsg("请选择投保公司") return false; }else if(i=="Insurance_value"&&selectObj["has_Insurance"]!=1) { showMsg("请选择投保金额"); return false; } } } if(i=="credit_card_quota"&¶ms.typeId==3&&selectObj[i]==1) { showMsg("信用卡额度不能为无") return false; } if(i=="has_car"&¶ms.typeId==4&&selectObj[i]==1) { showMsg("车产信息不能为无") return false; } if(i=="has_house"&¶ms.typeId==5&&selectObj[i]==1) { showMsg("房产信息不能为无") return false; } if(i=="has_Insurance"&¶ms.typeId==6&&selectObj[i]==1) { showMsg("投保信息不能为无") return false; } // } // 如果微粒贷和芝麻选择有却没有选址 } // 贷款金额1-100之间 if(selectObj.wx_load_quota!=0&&$("#weiliValue").val()<500||$("#weiliValue").val()>200000) { showMsg("微粒贷额度请填写500-200000的范围") }else if(selectObj.sesame_credit!=0&&$("#zhimaValue").val()<350||$("#zhimaValue").val()>950){ showMsg("芝麻分信用请填写350-950的范围") }else { console.log("elese") $.ajax({ type:"post", url:"/user/setUserInfo", dataType:'json', data:{ phone:params.phone, uid:params.uid, token:params.token, educational:parseInt(selectObj.educational==0?'':selectObj.educational), month_income:parseInt(selectObj.month_income==0?'':selectObj.month_income), income_type:parseInt(selectObj.income_type==0?'':selectObj.income_type), credit_card_quota:parseInt(selectObj.credit_card_quota==0?'':selectObj.credit_card_quota), wx_load_quota:parseInt(selectObj.wx_load_quota), sesame_credit:parseInt(selectObj.sesame_credit), has_house:parseInt(selectObj.has_house==0?'':selectObj.has_house), house_value:parseInt(selectObj.house_value==0?'':selectObj.house_value), has_car:parseInt(selectObj.has_car==0?'':selectObj.has_car), car_value:parseInt(selectObj.car_value==0?'':selectObj.car_value), has_Insurance:parseInt(selectObj.has_Insurance==0?'':selectObj.has_Insurance), Insurance_company:parseInt(selectObj.Insurance_company==0?'':selectObj.Insurance_company), Insurance_value:parseInt(selectObj.Insurance_value==0?'':selectObj.Insurance_value), channel_id:params.source }, success: function (res){ if(res && res.errno == 0){ var data=res.rst.data // 跳转到下个页面判断是否有审核失败记录 if(params.typeId) { window.location.href="identity.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code+"&typeId="+params.typeId }else { window.location.href="identity.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 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); // 微粒贷和芝麻分不等于0时,区别判断 if(dom!="wx_load_quota"&&dom!="sesame_credit") { if(index>-1) { jQuery("#"+dom).text(data[index].text) jQuery("#"+dom).addClass("hasValue") } }else if(dom=="wx_load_quota"&&index!=-1) { if(index>0) { jQuery("#"+dom).addClass("hasValue") jQuery(".weiliValue").attr("style","display:flex"); jQuery("#weiliValue").attr("value",index) jQuery("#"+dom).text(data[1].text) }else if(index===0){ jQuery("#"+dom).text(data[0].text) jQuery("#"+dom).addClass("hasValue"); } }else if(dom=="sesame_credit"&&index!=-1) { if(index>0) { jQuery("#"+dom).addClass("hasValue") jQuery(".zhimaValue").attr("style","display:flex"); jQuery("#zhimaValue").attr("value",index) jQuery("#"+dom).text(data[1].text) }else if(index===0){ jQuery("#"+dom).text(data[0].text) jQuery("#"+dom).addClass("hasValue"); } } identityDom.addEventListener('tap', function(event) { console.log("click") identityPicker.show(function(items) { jQuery("#"+dom).text(items[0].text) jQuery("#"+dom).addClass("hasValue") selectObj[dom]=items[0].value; console.log(selectObj[dom]) // 有微粒贷时 if(dom=="wx_load_quota"&&items[0].text=="有") { jQuery(".weiliValue").attr("style","display:flex"); // 无微粒贷时 }else if(dom=="wx_load_quota"&&items[0].text!="有"){ jQuery(".weiliValue").hide(); jQuery("#weiliValue").val("") selectObj["wx_load_quota"]=0 // 芝麻 }else if(dom=="sesame_credit"&&items[0].text=="有") { jQuery(".zhimaValue").attr("style","display:flex"); }else if(dom=="sesame_credit"&&items[0].text!="有"){ jQuery(".zhimaValue").hide(); jQuery("#zhimaValue").val("") selectObj["sesame_credit"]=0 // 有房产时 }else if(dom=="has_house"&&items[0].text.indexOf("有")!=-1||dom=="house_value"){ jQuery(".house_value").attr("style","display:flex"); // selectObj["house_value"]=selectObj["house_value"]?selectObj["house_value"]:1; // selectObj["house_value"]=selectObj["house_value"]?selectObj["house_value"]:0; // 无房产时 }else if(dom=="house_value"||items[0].text.indexOf("有")==-1&&items[0].text.indexOf("房")!=-1){ jQuery(".house_value").hide(); selectObj.house_value=""; //有车产时 }else if(dom=="has_car"&&items[0].text.indexOf("有")!=-1||dom=="car_value") { jQuery(".car_value").attr("style","display:flex"); // 无车产时 }else if(dom=="car_value"||items[0].text.indexOf("有")==-1&&items[0].text.indexOf("车")!=-1){ jQuery(".car_value").hide(); selectObj.car_value=""; // 有保险时 }else if(dom=="has_Insurance"&&items[0].text.indexOf("无")==-1){ jQuery(".Insurance_company").attr("style","display:flex") jQuery(".Insurance_value").attr("style","display:flex") // 无投保时,投保公司和投保金额为0 }else if(dom=="has_Insurance"||items[0].text.indexOf("投保")==-1&&dom=="has_Insurance"){ jQuery(".insInf").hide(); jQuery(".Insurance_company").hide(); jQuery(".Insurance_value").hide(); selectObj.Insurance_company=""; selectObj.Insurance_value=""; }else if(dom=="insInf"&&items[0].text.indexOf("无")!=-1){ jQuery(".Insurance_company").hide(); jQuery(".Insurance_value").hide(); selectObj['Insurance_value']="" } }); }, false); } // 展示错误提示信息 function showMsg(msg) { $(".alert-info").show(); $(".alert-info p").text(msg) setTimeout(function() { $(".alert-info").hide(); }, 1000); } //获取地址栏参数 function parseQueryString(url) { var urlObj = {}; var reg = /([^?=&]+)=([^?=&]+)/g; url.replace(reg, function($0, $1, $2) { urlObj[$1] = decodeURIComponent($2); }) return urlObj; } // 埋点 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) { } }) }