No Description

details.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. var id = ''; //详情id
  2. var qs = parseQueryString(window.location.href);
  3. $().ready(function () {
  4. if(qs.id) {id = qs.id;}
  5. detailEvent();//详情页接口
  6. })
  7. function detailEvent () {
  8. //详情页接口数据
  9. $.ajax({
  10. type:'post',
  11. url:'/user/product/detail',
  12. dataType:'json',
  13. data:{
  14. id:id
  15. },
  16. success:function(res){
  17. console.log(res)
  18. if(res && res.errno == 0){
  19. var product_con_html = '',requirements_html = '';//申请条件
  20. var document_html = '';//所需资料
  21. var explain_html = '';//产品特色
  22. var periods = res.rst.loan_period[0].k;//贷款期限
  23. var money = res.rst.upper_amount;//贷款金额下线
  24. var star = '';//星星
  25. for(var i = 0; i < res.rst.star; i++){
  26. star += '<i class="active"></i>'
  27. }
  28. for(var j = res.rst.star; j<5; j++){
  29. star += '<i></i>'
  30. }
  31. var details_info_html = `<img src="imgs/yztj.png" class="yztj" />
  32. <div class="product">
  33. <img src="${res.rst.icon}" class="product_img" />
  34. <div class="product_info">
  35. <p class="name">${res.rst.name}</p>
  36. <p class="describe">${res.rst.description}</p>
  37. <p class="chance" style="height:0.2rem"><span>通过率</span>${star}</p>
  38. </div>
  39. </div>
  40. <div class="loan_info">
  41. <div class="loan_item">
  42. <p class="tit">额度 (元)</p>
  43. <p class="con">${res.rst.chinese_amount}</p>
  44. </div>
  45. <div class="loan_item">
  46. <p class="tit">期限</p>
  47. <p class="con">${res.rst.term}</p>
  48. </div>
  49. <div class="loan_item">
  50. <p class="tit">${res.rst.show_day}</p>
  51. <p class="con">${res.rst.day_rate}%</p>
  52. </div>
  53. </div>`
  54. if(res.rst.requirements){
  55. requirements_html=`<p class="question">申请条件</p>
  56. <p class="answer">${res.rst.requirements}</p>`
  57. }
  58. if(res.rst.document){
  59. document_html=`<p class="question">所需资料 </p>
  60. <p class="answer">${res.rst.document}</p>`
  61. }
  62. if(res.rst.explain){
  63. explain_html=`<p class="question">产品特色 </p>
  64. <div class="answer">${res.rst.explain}</div>`
  65. }
  66. product_con_html=`${explain_html}${requirements_html}${document_html}`;
  67. var applyHtml = `<div class="apply">立即申请</div>`
  68. if(res.rst.applicants_ch){
  69. applyHtml = `<div class="apply">立即申请(${res.rst.applicants_ch}人申请)</div>`
  70. }
  71. $("#apply").html(applyHtml)
  72. $('.product_con').html(product_con_html)
  73. $(".details_info").html(details_info_html);
  74. $('.apply').click(function () {
  75. addapplyEvent(periods,money)
  76. })
  77. }
  78. }
  79. })
  80. }
  81. //获取地址栏参数
  82. function parseQueryString(url) {
  83. var urlObj = {};
  84. var reg = /([^?=&]+)=([^?=&]+)/g;
  85. url.replace(reg, ($0, $1, $2) => {
  86. urlObj[$1] = decodeURIComponent($2);
  87. })
  88. return urlObj;
  89. }
  90. //提示信息
  91. function showMsg(msg) {
  92. var msg = msg;
  93. var msgBox = $('.alert-info');
  94. msgBox.children('p').text(msg);
  95. msgBox.show();
  96. setTimeout(function() {
  97. msgBox.hide();
  98. }, 2000);
  99. }
  100. //立即申请
  101. function addapplyEvent (periods,money) {
  102. $.ajax({
  103. type:"post",
  104. url:"/user/user/addapply",
  105. dataType:'json',
  106. data:{
  107. product_id:id,
  108. periods:periods,
  109. money:money
  110. },
  111. success: function(res){
  112. console.log(res)
  113. if(res && res.errno == 0){
  114. window.location.href=res.rst.url;
  115. }
  116. }
  117. });
  118. }