Нет описания

index.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. var qs = parseQueryString(location.href),id,source;
  2. $().ready(function(){
  3. if(qs.id){id = qs.id}
  4. if(qs.source){source = qs.source}
  5. getProductListByCatId();
  6. })
  7. function getProductListByCatId () {
  8. $(".loading").show();
  9. $.ajax({
  10. url:'/user/product/getProductListByCatId',
  11. type:'post',
  12. dataType:'json',
  13. data:{
  14. id:id,
  15. source:source
  16. },
  17. success:function (res) {
  18. $(".loading").hide();
  19. if(res&&res.errno == 0){
  20. var listHtml = '',status = '';
  21. res.rst.data.forEach(function (item,index) {
  22. if(item.prod_title){
  23. status = '<div class="status">' + item.prod_title + '</div>'
  24. }
  25. listHtml += '<li class="shopListLi" data-link="' + item.link + '"><div class="shop_detail_01"><div class="left"><img src="' + item.icon + '"/><div class="shop_detail_left_con"><div class="name"><p>' + item.name + '</p>' + status + '</div><p class="shop_detail_left_con_hine">' + item.description + '</p></div></div><img class="arrow" src="./img/arrow.png"/></div><div class="shop_detail_02"><div><p>额度(元)</p><span>' + item.upper_amount + '-' + item.lower_amount + '</span></div><div><p>期限</p><span>' + item.term + '</span></div><p>' + item.applicants_ch + '人申请成功</p></div></li>'
  26. });
  27. $(".shopList").html(listHtml)
  28. $(".shopListLi").on('click',function () {
  29. window.location.href = $(this).attr('data-link')
  30. })
  31. }else{
  32. showMsg(res.err)
  33. }
  34. },
  35. error:function (err){
  36. console.log(err)
  37. $(".loading").hide();
  38. showMsg('请稍后再试!')
  39. }
  40. })
  41. }
  42. // 展示错误提示信息
  43. function showMsg(msg) {
  44. $(".alert-info").show();
  45. $(".alert-info p").text(msg);
  46. setTimeout(function() {
  47. $(".alert-info").hide();
  48. }, 1000);
  49. }
  50. //获取地址栏参数
  51. function parseQueryString(url) {
  52. var urlObj = {};
  53. var reg = /([^?=&]+)=([^?=&]+)/g;
  54. url.replace(reg, function($0, $1, $2) {
  55. urlObj[$1] = decodeURIComponent($2);
  56. })
  57. return urlObj;
  58. }