var qs = parseQueryString(location.href),id,source; $().ready(function(){ if(qs.id){id = qs.id} if(qs.source){source = qs.source} getProductListByCatId(); }) function getProductListByCatId () { $(".loading").show(); $.ajax({ url:'/user/product/getProductListByCatId', type:'post', dataType:'json', data:{ id:id, source:source }, success:function (res) { $(".loading").hide(); if(res&&res.errno == 0){ var listHtml = '',status = ''; res.rst.data.forEach(function (item,index) { if(item.prod_title){ status = '
' + item.prod_title + '
' } listHtml += '
  • ' + item.name + '

    ' + status + '

    ' + item.description + '

    额度(元)

    ' + item.upper_amount + '-' + item.lower_amount + '

    期限

    ' + item.term + '

    ' + item.applicants_ch + '人申请成功

  • ' }); $(".shopList").html(listHtml) $(".shopListLi").on('click',function () { window.location.href = $(this).attr('data-link') }) }else{ showMsg(res.err) } }, error:function (err){ console.log(err) $(".loading").hide(); showMsg('请稍后再试!') } }) } // 展示错误提示信息 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; }