123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- var id = ''; //id
- var channel_id = ''; //渠道号
- var page =1; //页数
- var maxPage =1; //最大页数
- var title = '' ; //标题
- var loadingFlag = false;
- var qs = parseQueryString(window.location.href);
- $().ready(function() {
- if(qs.id) {
- id = qs.id;
- }
- if(qs.channel_id) {
- channel_id = qs.channel_id;
- }
- if(qs.title) {
- title = qs.title;
- }
- document.title = title;
- getCardBanner(id); //获取banner信息
- getCardListData(id,page,channel_id); //获取信用卡list数据
- // $(window).scroll(function(){
- // if($(window).scrollTop()>= $(document).height()-$(window).height() - 20){
- // //到达底部加载数据
- // if(loadingFlag){
- // page ++ ;
- // getListData(id,page,channel_id);
- // }
- // }
- // });
-
- })
- //获取地址栏参数
- function parseQueryString(url) {
- var urlObj = {};
- var reg = /([^?=&]+)=([^?=&]+)/g;
- url.replace(reg, ($0, $1, $2) => {
- urlObj[$1] = decodeURIComponent($2);
- })
- return urlObj;
- }
- //获取banner信息
- function getCardBanner(id){
- $.ajax({
- type: "post",
- url: "/user/product/getH5Detail",
- data:{
- id : id
- },
- success:function(res){
- if(res.errno == "0" && res.rst){
- var data = res.rst;
- // $('body').css({ 'background':data.background_color })
- document.body.style.background='-o-linear-gradient(top, '+ data.background_color_up + ', '+ data.background_color_down + '))'
- document.body.style.background='-webkit-linear-gradient(top, '+ data.background_color_up + ', '+ data.background_color_down + '))'
- document.body.style.background='-ms-gradient(linear, left top, left bottom, from('+ data.background_color_up + '), to('+ data.background_color_down + '))'
- document.body.style.background='-moz-gradient(linear, left top, left bottom, from('+ data.background_color_up + '), to('+ data.background_color_down + '))'
- document.body.style.background='-webkit-gradient(linear, left top, left bottom, from('+ data.background_color_up + '), to('+ data.background_color_down + '))'
- var bannerHtml = '';
- bannerHtml += '<img src='+ data.banner +' class="bannerimg" />';
- }
- $('.banner').html(bannerHtml)
- },
- error:function(err){
- console.log(err)
- }
- })
- }
- //获取信用卡list数据
- function getCardListData(id,page,channel_id){
- // loadingFlag = false;
- // if(maxPage < page){
- // $(".loading").html("没有更多了")
- // return;
- // }
- $.ajax({
- type: "post",
- url: "/user/product/getH5DetailCardProductList",
- data:{
- id : id,
- page : page,
- channel_id:channel_id
- },
- success:function(res){
- if(res.errno == "0" && res.rst){
- maxPage = res.rst.pageinfo.maxPage;
- var data = res.rst;
- var html = '';
- //没有数据的时候
- if(data.data == ''){ $('.card_list').hide() }
- for(var i in data){
- if(data[i].id){
- 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>`
- }
- }
- // loadingFlag = true;
- $('.card_list').html(html)
- // $(".loading").html("努力加载中...")
- }else{
- // alert('暂无数据')
- }
- // }
- },
- error:function(err){
- console.log(err)
- }
- })
- }
|