Bez popisu

index.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. var params=parseQueryString(window.location.href)
  2. // 根据typeId来判断必填项
  3. var selectObj={}
  4. // 当审核失败过之后,有传递参数hasError=1
  5. // typeId=0时,优质--全部必填
  6. var hasError=params.hasError?params.hasError:''
  7. // 页面初始化
  8. $().ready(function(){
  9. // 获取贷款信息
  10. getInfo();
  11. clickRecord("openLink","链接打开")//链接打开
  12. // typeId为1,本地社保必填
  13. if(params.typeId==1) {
  14. $("#social_security_period").parents().eq(0).prepend("<div class='speical'>*</div>")
  15. // typeId为2,本地公积金必填
  16. }else if(params.typeId==2) {
  17. $("#loal_fund").parents().eq(0).prepend("<div class='speical'>*</div>")
  18. }
  19. })
  20. $("#city").on("tap",function(){
  21. setLoanInfo("1");
  22. })
  23. // 设置贷款信息
  24. $(".button").on("tap",function(){
  25. clickRecord("loanButtonClick","贷款信息页下一步点击")//贷款信息页下一步点击
  26. if(params.hasCode!=1) {
  27. setLoanInfo();
  28. }else {
  29. if(params.typeId) {
  30. 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
  31. }else {
  32. 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
  33. }
  34. }
  35. })
  36. $(".top img").on("click",function(){
  37. if(params.typeId==1) {
  38. 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
  39. }else if(params.typeId==2) {
  40. 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
  41. }else if(params.typeId==3) {
  42. 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
  43. }else if(params.typeId==4) {
  44. 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
  45. }else if(params.typeId==5) {
  46. 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
  47. }else if(params.typeId==6) {
  48. 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
  49. }else if(params.typeId==7) {
  50. 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
  51. }else if(!params.typeId) {
  52. window.location.href="login.html?source="+params.source
  53. }else if(params.typeId==0) {
  54. window.location.href="newLogin.html?source="+params.source
  55. }
  56. })
  57. // 获取贷款信息
  58. function getInfo() {
  59. $.ajax({
  60. type:"post",
  61. url:"/user/getLoanInfo",
  62. dataType:'json',
  63. data:{
  64. phone:params.phone,
  65. uid:params.uid,
  66. token:params.token,
  67. channel_id:params.source
  68. },
  69. success: function (res){
  70. if(res && res.errno == 0){
  71. var data=res.rst.data
  72. // 贷款金额
  73. $(".right input").val(data.loan_amount)
  74. // -1由于mui的下标是从0开始的
  75. // 贷款期限
  76. mobanData("贷款期限",loan_period,'loan_period',data.loan_period-1)
  77. // 贷款用途
  78. mobanData("贷款用途",loan_purpose,'loan_purpose',data.loan_purpose-1)
  79. //职业身份
  80. mobanData("职业身份",professional_identity,"professional_identity",data.professional_identity-1)
  81. // 本地社保
  82. mobanData("本地社保",social_security_period,'social_security_period',data.social_security_period-1)
  83. // 公积金
  84. mobanData("公积金",loal_fund,'loal_fund',data.loal_fund-1)
  85. selectObj.loan_period=data.loan_period;
  86. selectObj.loan_purpose=data.loan_purpose;
  87. selectObj.professional_identity=data.professional_identity;
  88. selectObj.social_security_period=data.social_security_period;
  89. selectObj.loal_fund=data.loal_fund;
  90. // 贷款城市
  91. $("#city").text(params.city?params.city:data.loal_area?data.loal_area:"请选择所在城市>")
  92. params.city=params.city?params.city:data.loal_area?data.loal_area:""
  93. if(params.city) {
  94. $("#city").text(params.city)
  95. $("#city").addClass("hasValue")
  96. selectObj.loal_area=params.city
  97. }
  98. if(params.city||data.loal_area) {
  99. $("#city").addClass("hasValue");
  100. }
  101. if(params.typeId) {
  102. if(!selectObj.social_security_period&&params.typeId!=1&&params.typeId!=0){
  103. // showMsg("请选择本地社保")
  104. selectObj.social_security_period=1
  105. $("#social_security_period").text(social_security_period[0].text);
  106. $("#social_security_period").addClass("hasValue");
  107. }
  108. if(!selectObj.loal_fund&&params.typeId!=2&&params.typeId!=0){
  109. selectObj.loal_fund=1
  110. $("#loal_fund").text(loal_fund[0].text);
  111. $("#loal_fund").addClass("hasValue");
  112. }
  113. }
  114. }else{
  115. showMsg(res.rst.msg)
  116. }
  117. },
  118. error:function(){
  119. showMsg("网络错误,请稍后再试");
  120. }
  121. });
  122. }
  123. // 设置贷款信息
  124. function setLoanInfo(type){
  125. // if(!selectObj.social_security_period&&params.typeId!=1&&params.typeId!=0){
  126. // // showMsg("请选择本地社保")
  127. // selectObj.social_security_period=1
  128. // $("#social_security_period").text(social_security_period[0].text);
  129. // $("#social_security_period").addClass("hasValue");
  130. // }
  131. // if(!selectObj.loal_fund&&params.typeId!=2&&params.typeId!=0){
  132. // selectObj.loal_fund=1
  133. // $("#loal_fund").text(loal_fund[0].text);
  134. // $("#loal_fund").addClass("hasValue");
  135. // }
  136. if($(".right input").val()<=0||$(".right input").val()>100) {
  137. showMsg("贷款金额请填写1-100的范围")
  138. }else if(!selectObj.loan_period){
  139. showMsg("请选择贷款期限")
  140. }else if(!selectObj.loan_purpose){
  141. showMsg("请选择贷款用途")
  142. }else if(!selectObj.professional_identity){
  143. showMsg("请选择职业身份")
  144. }else if(!selectObj.social_security_period&&params.typeId==1){
  145. showMsg("请选择本地社保")
  146. }else if(!selectObj.social_security_period&&params.typeId==0){
  147. showMsg("请选择本地社保")
  148. }else if(!selectObj.loal_fund&&params.typeId==2){
  149. showMsg("请选择本地公积金")
  150. }else if(!selectObj.loal_fund&&params.typeId==0){
  151. showMsg("请选择本地公积金")
  152. }else if(selectObj.social_security_period==1&&params.typeId==1) {
  153. showMsg("社保时长不能为无")
  154. }else if(selectObj.loal_fund==1&&params.typeId==2) {
  155. showMsg("本地公积金不能为无")
  156. }else if(!selectObj.loal_area&&type!=1){
  157. showMsg("请选择所在城市")
  158. }else{
  159. $.ajax({
  160. type:"post",
  161. url:"/user/setLoanInfo",
  162. dataType:'json',
  163. data:{
  164. phone:params.phone,
  165. uid:params.uid,
  166. token:params.token,
  167. loan_amount:$(".right input").val(),
  168. loan_period:parseInt(selectObj.loan_period==-1?'':selectObj.loan_period),
  169. loan_purpose:parseInt(selectObj.loan_purpose==-1?'':selectObj.loan_purpose),
  170. professional_identity:parseInt(selectObj.professional_identity==-1?'':selectObj.professional_identity),
  171. social_security_period:parseInt(selectObj.social_security_period==-1?'':selectObj.social_security_period),
  172. loal_fund:parseInt(selectObj.loal_fund==-1?'':selectObj.loal_fund),
  173. loal_area:$("#city").text()=="请选择所在城市>"?"":$("#city").text(),
  174. channel_id:params.source
  175. },
  176. success: function (res){
  177. if(res && res.errno == 0){
  178. var data=res.rst.data
  179. if(params.typeId) {
  180. if(type==1){
  181. 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
  182. }else {
  183. // 跳转到下个页面判断是否有审核失败记录
  184. 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
  185. }
  186. }else {
  187. if(type==1){
  188. window.location.href="choose.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&city="+city+"&code="+params.code
  189. }else {
  190. // 跳转到下个页面判断是否有审核失败记录
  191. window.location.href="second.html?source="+params.source+"&phone="+params.phone+"&uid="+params.uid+"&token="+params.token+"&hasError="+hasError+"&code="+params.code
  192. }
  193. }
  194. }else{
  195. showMsg(res.rst.msg)
  196. }
  197. },
  198. error:function(){
  199. showMsg("网络错误,请稍后再试");
  200. }
  201. });
  202. }
  203. }
  204. //获取地址栏参数
  205. function parseQueryString(url) {
  206. var urlObj = {};
  207. var reg = /([^?=&]+)=([^?=&]+)/g;
  208. url.replace(reg, function($0, $1, $2) {
  209. urlObj[$1] = decodeURIComponent($2);
  210. })
  211. return urlObj;
  212. }
  213. // 展示错误提示信息
  214. function showMsg(msg) {
  215. $(".alert-info").show();
  216. $(".alert-info p").text(msg);
  217. setTimeout(function() {
  218. $(".alert-info").hide();
  219. }, 1000);
  220. }
  221. // 下拉列表初始化
  222. function mobanData(title,data,dom,index){
  223. var identityPicker = new mui.PopPicker();
  224. identityPicker.setData(data,title);
  225. // 设置选中的下拉项
  226. identityPicker.pickers[0].setSelectedIndex(index,2000)
  227. var identityDom = document.getElementById(dom);
  228. if(index>-1) {
  229. jQuery("#"+dom).text(data[index].text)
  230. jQuery("#"+dom).addClass("hasValue")
  231. }
  232. identityDom.addEventListener('tap', function(event) {
  233. identityPicker.show(function(items) {
  234. jQuery("#"+dom).text(items[0].text)
  235. jQuery("#"+dom).addClass("hasValue")
  236. selectObj[dom]=parseInt(items[0].value);
  237. });
  238. }, false);
  239. }
  240. // 埋点
  241. function clickRecord(eventId,eventName){
  242. $.ajax({
  243. url:"/user/clickRecord",
  244. type:"post",
  245. dataType:"json",
  246. data:{
  247. event_id:eventId,
  248. event_name:eventName,
  249. channel_id:params.source
  250. },
  251. success:function(res) {
  252. }
  253. })
  254. }