123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- // Initialize your app
- var myApp = new Framework7({
- animateNavBackIcon: true,
- modalButtonOk: '确定',
- modalButtonCancel: '取消'
- });
- var $$ = Dom7;
- var mainView = myApp.addView('.view-main', {
- dynamicNavbar: true
- });
- function getCategory(package_id){
- var cate_id = '';
- var html = '', res = null, className = '';
- $$.post('/user/information/getclassification', { package_id: package_id}, function (data) {
- console.log(JSON.parse(data))
- res = JSON.parse(data);
- if (res.errno == 0 && res.rst != []) {
- html += '<li><a data-label="'+ res.rst[0] +'" href="#nav1" class="tab-link active">'+ res.rst[0] +'</a></li><li><a data-label="'+ res.rst[1] +'" href="#nav2" class="tab-link">'+ res.rst[1] +'</a></li>';
- $$('#nav').html(html);
- }
- });
- }
- function getList(package_id, classification_id, id, page){
- var html = '', res = null, className = '';
- $$.post('/user/information/getinformationsbypackage', { package_id: package_id, classification_id: classification_id, page: page}, function (data) {
- // 请求成功
- res = JSON.parse(data);
- var pageInfo = res.rst.listdata.pageinfo;
- if (res.errno == 0) {
- // 添加banner
- // if (res.rst.banner !== null) {
- // $$('.swiper-slide').html('<a class="external" href="details.html?id='+ res.rst.banner.id +'"><img src="'+ res.rst.banner.thumbnail +'"></a>');
- // }
- // list 循环
- if (pageInfo.page == 1) {
- $$(id).html('');
- $$('.infinite-scroll-preloader').remove();
- // loading = false;
- }
- if (pageInfo.page == 1 && pageInfo.hasNext) {
- $$('.infinite-scroll').append('<div class="infinite-scroll-preloader"><div class="preloader"></div></div>');
- }
- if(!pageInfo.hasNext){
- // myApp.detachInfiniteScroll($$('.infinite-scroll'));
- // console.log('test');
- $$('.infinite-scroll-preloader').remove();
- }else{
- loading = false;
- }
- console.log(res.rst.listdata.data)
- $$.each(res.rst.listdata.data , function(index, el) {
- html += '<li><a class="external" href="details.html?id='+el.id+'"> <div class="content fl"> <h5 class="elli">'+ el.title +'</h5> <div class="label"> <span class="fl" style="max-width: 30%;">'+ el.source +'</span> <span class="zixun_number" style="max-width: 60%; padding-left:0.4rem">'+ el.page_views +'人阅读</span></div></div> <div class="img-box fr"><img src="'+ el.thumbnail +'"></div> </a></li>';
- });
- $$(id).append(html);
- }else if(res.errno == 40044){
- myApp.detachInfiniteScroll($$('.infinite-scroll'));
- $$('.infinite-scroll-preloader').remove();
- // if (pageInfo.page == 1) {
- // $$(id).html('<li class="nomore"><p>没有数据了~</p></li>');
- // }else{
- // if ($$(id + ' li.nomore').length == 0) {
- // // $$(id).append('<li class="nomore"><p>已全部加载完成</p></li>');
- // }
- // }
- }
- });
- }
- var loading = true, page = 1;
- var cate_id = '推荐',timer, index = 1;
- timer = setInterval( function(){
- // cate_id = $$('#nav li a.active').attr('data-label');
- if (cate_id != '' && cate_id != null ) {clearInterval(timer); getList('package_9',cate_id, '#nav1'); }
- $$('.infinite-scroll').on('infinite', function () {
- console.log(loading);
- if (loading) return;
- loading = true;
- setTimeout(function () {
- var nav = '';
- getList('package_9',cate_id, '#nav'+index, ++page);
- console.log(index);
- }, 500);
- });
- // 点击tab请求list接口
- $$('#nav li a').on('click', function(e){
- cate_id = $$(this).attr('data-label');
- index = $$(this).parent('li').index() + 1;
- page = 1;
- if (cate_id != '' && cate_id != null ) {getList('package_9', cate_id, '#nav'+index); }
- });
- },100);
- $$('.external img').click(function () {
- if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){
- window.location.href='https://itunes.apple.com/cn/app/%E9%87%91%E7%89%9B%E8%AE%B0%E8%B4%A6/id1398141686?mt=8';
- }
- if(navigator.userAgent.match(/android/i)){
- window.location.href='http://android.myapp.com/myapp/detail.htm?apkName=com.kuxuan.jinniunote&ADTAG=mobile';
- }
- })
|