123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- var params=parseQueryString(window.location.href);
- var hasError=params.hasError?params.hasError:''
- var getTypeId=""//接口获取到的typeId
- var obj={}//信用状况
- // var hasSet=false;
- $().ready(function(){
- clickRecord("openLink","链接打开")//链接打开
- getInfo();
- getType();
- if(params.hasCode==1) {
- $(".button").hide();
- }
- })
- $(".top img").on("click",function(){
- 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
- }
- })
- function init(index){
- var identityPicker = new mui.PopPicker();
- identityPicker.setData(credit_record_status,"贷款记录");
- // 设置选中的下拉项
- identityPicker.pickers[0].setSelectedIndex(index,2000)
- var identityDom = document.getElementById("credit_record_status");
- if(index>-1) {
- jQuery("#credit_record_status").text(credit_record_status[index].text)
- jQuery("#credit_record_status").addClass("hasValue")
- }
- identityDom.addEventListener('tap', function(event) {
- identityPicker.show(function(items) {
- $("#credit_record_status").text(items[0].text)
- jQuery("#credit_record_status").addClass("hasValue")
- obj.credit_record_status=items[0].value;
- });
- }, false);
- }
- function getType() {
- $.ajax({
- type:"post",
- url:"/user/typeList",
- success:function(res) {
- console.log(res)
- if(res&&res.errno==200) {
- var typeList=res.rst.type_list
- // 根据typeId来判断
- for(var i in typeList) {
- // 社保
- if(params.typeId==1&&typeList[i].type_name=="社保公积金") {
- getType=typeList[i].id
- // 公积金
- }else if(params.typeId==2&&typeList[i].type_name=="社保公积金"){
- getType=typeList[i].id
- // 流水
- }else if(params.typeId==3&&typeList[i].type_name=="流水"){
- getType=typeList[i].id
- // 车贷
- }else if(params.typeId==4&&typeList[i].type_name=="房车贷"){
- getType=typeList[i].id
- // 房贷
- }else if(params.typeId==5&&typeList[i].type_name=="房车贷"){
- getType=typeList[i].id
- }else if(!params.typeId&&typeList[i].type_name=="优质单") {
- getType=typeList[i].id
- }else if(params.typeId==0&&typeList[i].type_name=="优质单") {
- getType=typeList[i].id
- }
- }
- }else {
- showMsg(res.err)
- }
- },
- error:function(){
- showMsg("网络错误,请稍后再试");
- }
- })
- }
- $(".button").on("tap",function(){
- if(!$("#name").val()) {
- showMsg("请填写姓名")
- return false;
- }else if(!$("#id_no").val()) {
- showMsg("请填写身份证号")
- return false;
- }else if(!obj.credit_record_status||obj.credit_record_status<0){
- showMsg("请选择信用记录");
- return false;
- }else {
- setInfo();
- }
- })
- $(".button1").on("tap",function(){
- if(params.typeId) {
- window.location.href="status.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+1+"&code="+params.code+"&status=1"+"&typeId="+params.typeId
- }else {
- window.location.href="status.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+1+"&code="+params.code+"&status=1"
- }
- })
- // 展示错误提示信息
- function showMsg(msg) {
- $(".alert-info").show();
- $(".alert-info p").text(msg)
- setTimeout(function() {
- $(".alert-info").hide();
- }, 1000);
- }
- function getInfo(){
- $.ajax({
- url:"/user/getUser",
- type:"post",
- dataType:"json",
- data:{
- phone:params.phone,
- token:params.token,
- uid:params.uid,
- channel_id:params.source
- },
- success:function(res) {
- if(res&&res.errno==0) {
- var data=res.rst.data
- init(data.credit_record_status-1)
- if(data.name) {
- $("#name").attr("value",data.name)
- $("#name").addClass("hasValue")
- }
- if(data.id_no) {
- $("#id_no").attr("value",data.id_no)
- $("id_no").addClass("hasValue")
- }
- if(data.credit_record_status>0) {
- $("#credit_record_status").text(credit_record_status[data.credit_record_status-1].text)
- $("#credit_record_status").addClass("hasValue")
- }
- // obj.credit_record_status=data.credit_record_status-1
- obj.credit_record_status=data.credit_record_status
- }else {
- showMsg(res.rst.msg)
- }
- },
- error:function(err) {
- showMsg("网络错误,请稍后再试")
- }
- })
- }
- function setInfo(){
- // if(!hasSet) {
- $.ajax({
- url:"/user/setUser",
- type:"post",
- dataType:"json",
- data:{
- phone:params.phone,
- token:params.token,
- uid:params.uid,
- id_no:$("#id_no").val(),
- name:$("#name").val(),
- credit_record_status:obj.credit_record_status,
- channel_id:params.source,
- type_id:getType
- },
- success:function(res) {
- hasSet=true
- if(res&&res.errno==0) {
- clickRecord("submitApplyClick","提交申请按钮点击")//链接打开
- if(params.hasError==1) {
- reapply()
- }else {
- if(params.typeId) {
- window.location.href="status.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+1+"&code="+params.code+"&status=1"+"&typeId="+params.typeId
- }else {
- window.location.href="status.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+1+"&code="+params.code+"&status=1"
- }
- }
- }else {
- showMsg(res.rst.msg)
- }
- },
- error:function(err) {
- showMsg("网络错误,请稍后再试")
- }
- })
- // }
- }
- // 重新审核
- function reapply() {
- $.ajax({
- url:"/user/reapply",
- type:"post",
- dataType:"json",
- data:{
- phone:params.phone,
- token:params.token,
- channel_id:params.source,
- uid:params.uid
- },
- success:function(res) {
- if(res&&res.errno==0) {
- if(params.typeId) {
- window.location.href="status.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+1+"&code="+params.code+"&status=1"+"&typeId="+params.typeId
- }else {
- window.location.href="status.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+1+"&code="+params.code+"&status=1"
- }
- }else {
- showMsg(res.rst.msg)
- }
- },
- error:function(err) {
- showMsg("网络错误,请稍后再试")
- }
- })
- }
- //获取地址栏参数
- 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) {
- }
- })
- }
|