123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- var id = ''; //详情id
- var qs = parseQueryString(window.location.href);
- $().ready(function () {
- if(qs.id) {id = qs.id;}
- detailEvent();//详情页接口
- })
- function detailEvent () {
- //详情页接口数据
- $.ajax({
- type:'post',
- url:'/user/product/detail',
- dataType:'json',
- data:{
- id:id
- },
- success:function(res){
- console.log(res)
- if(res && res.errno == 0){
- var product_con_html = '',requirements_html = '';//申请条件
- var document_html = '';//所需资料
- var explain_html = '';//产品特色
- var periods = res.rst.loan_period[0].k;//贷款期限
- var money = res.rst.upper_amount;//贷款金额下线
- var star = '';//星星
- for(var i = 0; i < res.rst.star; i++){
- star += '<i class="active"></i>'
- }
- for(var j = res.rst.star; j<5; j++){
- star += '<i></i>'
- }
- var details_info_html = `<img src="imgs/yztj.png" class="yztj" />
- <div class="product">
- <img src="${res.rst.icon}" class="product_img" />
- <div class="product_info">
- <p class="name">${res.rst.name}</p>
- <p class="describe">${res.rst.description}</p>
- <p class="chance" style="height:0.2rem"><span>通过率</span>${star}</p>
- </div>
- </div>
- <div class="loan_info">
- <div class="loan_item">
- <p class="tit">额度 (元)</p>
- <p class="con">${res.rst.chinese_amount}</p>
- </div>
- <div class="loan_item">
- <p class="tit">期限</p>
- <p class="con">${res.rst.term}</p>
- </div>
- <div class="loan_item">
- <p class="tit">${res.rst.show_day}</p>
- <p class="con">${res.rst.day_rate}%</p>
- </div>
- </div>`
- if(res.rst.requirements){
- requirements_html=`<p class="question">申请条件</p>
- <p class="answer">${res.rst.requirements}</p>`
- }
- if(res.rst.document){
- document_html=`<p class="question">所需资料 </p>
- <p class="answer">${res.rst.document}</p>`
- }
- if(res.rst.explain){
- explain_html=`<p class="question">产品特色 </p>
- <div class="answer">${res.rst.explain}</div>`
- }
- product_con_html=`${explain_html}${requirements_html}${document_html}`;
- var applyHtml = `<div class="apply">立即申请</div>`
- if(res.rst.applicants_ch){
- applyHtml = `<div class="apply">立即申请(${res.rst.applicants_ch}人申请)</div>`
- }
- $("#apply").html(applyHtml)
- $('.product_con').html(product_con_html)
- $(".details_info").html(details_info_html);
- $('.apply').click(function () {
- addapplyEvent(periods,money)
- })
- }
- }
- })
- }
- //获取地址栏参数
- function parseQueryString(url) {
- var urlObj = {};
- var reg = /([^?=&]+)=([^?=&]+)/g;
- url.replace(reg, ($0, $1, $2) => {
- urlObj[$1] = decodeURIComponent($2);
- })
- return urlObj;
- }
- //提示信息
- function showMsg(msg) {
- var msg = msg;
- var msgBox = $('.alert-info');
- msgBox.children('p').text(msg);
- msgBox.show();
- setTimeout(function() {
- msgBox.hide();
- }, 2000);
- }
- //立即申请
- function addapplyEvent (periods,money) {
- $.ajax({
- type:"post",
- url:"/user/user/addapply",
- dataType:'json',
- data:{
- product_id:id,
- periods:periods,
- money:money
- },
- success: function(res){
- console.log(res)
- if(res && res.errno == 0){
- window.location.href=res.rst.url;
- }
- }
- });
- }
|