123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- var id = ''; //id
- var channel_id = ''; //渠道号
- var page =1; //页数
- var maxPage =1; //最大页数
- var categoryList = [];//列表数组
- var title = '' ; //标题
- var sessionid = '';
- var loadingFlag = false;
- var qs = parseQueryString(window.location.href);
- $().ready(function() {
- if(qs.id) {
- id = qs.id;
- }
- if(qs.title) {
- title = qs.title;
- }
- document.title = title;
- if(qs.channel_id) {
- channel_id = qs.channel_id;
- }
- if(qs.sessionid) {
- sessionid = qs.sessionid;
-
- document.cookie="PHPSESSID=" + qs.sessionid + ';path=/' ;
- }
-
- getBannerDescription(id); //获取banner信息
- getListData(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 getBannerDescription(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 + '))'
- // $('.list_top .apply_now').css('background','-webkit-linear-gradient(top, '+ data.background_color_up + ', '+ data.background_color_down + '))')
- $('.loading').css({ 'background':data.background_color_down })
- $('.category_banner').css({ 'background':' url('+ data.banner +') no-repeat', 'background-size':'100% 100%' })
- $('.category_banner .de_1').html(data.description);
- $('.category_banner .de_2').html(data.sub_description);
- }
- },
- error:function(err){
- console.log(err)
- }
- })
- }
- //获取list数据
- function getListData(id,page,channel_id){
- loadingFlag = false;
- if(maxPage < page){
- $(".loading").html("没有更多了")
- return;
- }
- $.ajax({
- type: "post",
- url: "/user/product/getH5DetailProductList",
- 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.data;
- var html = '';
- categoryList = categoryList.concat(data)
- categoryList.forEach(function(item,index){
- html+='<li class="category_list" data_id = ' + item.id + ' data_title = ' + item.name + '><div class="list_top"><img src="'+ item.icon +'" class="list_icon" /> <div class="list_info"><h3 class="name">'+ item.name +'</h3><p class="description">'+ item.description +'</p></div><div class="applyNow"><div class="apply_now" data_id = ' + item.id + ' url=' + item.link + ' >立即申请</div></div></div><div class="list_bot"> <div class="list_bot_item"><p class="name">额度</p><p class="con" id="">'+ item.upper_amount +'-'+ item.lower_amount +'元</p></div><div class="list_bot_item"><p class="name">利率</p><p class="con" id="">'+ item.day_rate +'%</p></div><div class="list_bot_item"><p class="name">成功借款</p> <p class="con" id="">'+ item.applicants +'人</p> </div> </div> </li>'
- })
- loadingFlag = true;
- $('.category_con').html(html)
- toApply();//立即申请
-
- $(".loading").html("努力加载中...")
- }else{
- $(".loading").html("暂无数据")
- }
- },
- error:function(err){
- console.log(err)
- }
- })
- }
- //立即申请
- function toApply(){
- //category_list点击跳转原生
- $(".category_list").click(function () {
- var id = $(this).attr('data_id');
- var title = $(this).attr('data_title');
- toCategory(id,title);
- })
- $(".applyNow").click(function () {
- return false;
- })
- //立即申请点击跳转商户推广页
- $(".category_con li .apply_now").click(function () {
- var id = $(this).attr('data_id');
- var url = $(this).attr('url');
- window.location.href = url;
- shenqing(id);
- })
- }
- //立即申请点击跳转商户推广页
- function shenqing (id) {
- var jsons = {
- event:'nowApply',
- product:id
- };
- jsons = JSON.stringify(jsons);
- // console.log(jsons)
- if(navigator.userAgent.indexOf('Android') != -1){
- messageHandlers.censucEventCount(jsons)
- }else{
- window.webkit.messageHandlers.censucEventCount.postMessage(jsons)
- }
- }
- //category_list点击跳转原生
- function toCategory(id,title){
- var jsons = {
- productId:id,
- productTitle:title,
- prooductSkipEntersource:'H5HomeProductListSkip'
- };
- jsons = JSON.stringify(jsons);
- if(navigator.userAgent.indexOf('Android') != -1){
- messageHandlers.skipNativeDetail(jsons)
- }else{
- window.webkit.messageHandlers.skipNativeDetail.postMessage(jsons)
- }
- }
|