Нет описания

creditCard.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. var id = ''; //id
  2. var channel_id = ''; //渠道号
  3. var page =1; //页数
  4. var maxPage =1; //最大页数
  5. var title = '' ; //标题
  6. var loadingFlag = false;
  7. var qs = parseQueryString(window.location.href);
  8. $().ready(function() {
  9. if(qs.id) {
  10. id = qs.id;
  11. }
  12. if(qs.channel_id) {
  13. channel_id = qs.channel_id;
  14. }
  15. if(qs.title) {
  16. title = qs.title;
  17. }
  18. document.title = title;
  19. getCardBanner(id); //获取banner信息
  20. getCardListData(id,page,channel_id); //获取信用卡list数据
  21. // $(window).scroll(function(){
  22. // if($(window).scrollTop()>= $(document).height()-$(window).height() - 20){
  23. // //到达底部加载数据
  24. // if(loadingFlag){
  25. // page ++ ;
  26. // getListData(id,page,channel_id);
  27. // }
  28. // }
  29. // });
  30. })
  31. //获取地址栏参数
  32. function parseQueryString(url) {
  33. var urlObj = {};
  34. var reg = /([^?=&]+)=([^?=&]+)/g;
  35. url.replace(reg, ($0, $1, $2) => {
  36. urlObj[$1] = decodeURIComponent($2);
  37. })
  38. return urlObj;
  39. }
  40. //获取banner信息
  41. function getCardBanner(id){
  42. $.ajax({
  43. type: "post",
  44. url: "/user/product/getH5Detail",
  45. data:{
  46. id : id
  47. },
  48. success:function(res){
  49. if(res.errno == "0" && res.rst){
  50. var data = res.rst;
  51. // $('body').css({ 'background':data.background_color })
  52. document.body.style.background='-o-linear-gradient(top, '+ data.background_color_up + ', '+ data.background_color_down + '))'
  53. document.body.style.background='-webkit-linear-gradient(top, '+ data.background_color_up + ', '+ data.background_color_down + '))'
  54. document.body.style.background='-ms-gradient(linear, left top, left bottom, from('+ data.background_color_up + '), to('+ data.background_color_down + '))'
  55. document.body.style.background='-moz-gradient(linear, left top, left bottom, from('+ data.background_color_up + '), to('+ data.background_color_down + '))'
  56. document.body.style.background='-webkit-gradient(linear, left top, left bottom, from('+ data.background_color_up + '), to('+ data.background_color_down + '))'
  57. var bannerHtml = '';
  58. bannerHtml += '<img src='+ data.banner +' class="bannerimg" />';
  59. }
  60. $('.banner').html(bannerHtml)
  61. },
  62. error:function(err){
  63. console.log(err)
  64. }
  65. })
  66. }
  67. //获取信用卡list数据
  68. function getCardListData(id,page,channel_id){
  69. // loadingFlag = false;
  70. // if(maxPage < page){
  71. // $(".loading").html("没有更多了")
  72. // return;
  73. // }
  74. $.ajax({
  75. type: "post",
  76. url: "/user/product/getH5DetailCardProductList",
  77. data:{
  78. id : id,
  79. page : page,
  80. channel_id:channel_id
  81. },
  82. success:function(res){
  83. if(res.errno == "0" && res.rst){
  84. maxPage = res.rst.pageinfo.maxPage;
  85. var data = res.rst;
  86. var html = '';
  87. //没有数据的时候
  88. if(data.data == ''){ $('.card_list').hide() }
  89. for(var i in data){
  90. if(data[i].id){
  91. html += `<a href="${data[i].url}" class="cars_item"><img src="${data[i].card_icon}" class="card_img" /><div class="card_info"><p><span class="card_name">${data[i].name}</span><i class="li">礼</i><i class="jian">荐</i></p><p class="describe">${data[i].desc}</p><p class="num">申请人数:<span class="renshu">${data[i].apply_num}</span></p></div> </a>`
  92. }
  93. }
  94. // loadingFlag = true;
  95. $('.card_list').html(html)
  96. // $(".loading").html("努力加载中...")
  97. }else{
  98. // alert('暂无数据')
  99. }
  100. // }
  101. },
  102. error:function(err){
  103. console.log(err)
  104. }
  105. })
  106. }