Authored by whb

修改bug

... ... @@ -235,11 +235,73 @@ define('mobile', function(require, exports) {
exports.news = function() {
$('select').on('change', function() {
/* var nowIndex = $('option').not(function() {
return !this.selected
}).index();
$('.news-main').removeClass('current').eq(nowIndex).addClass('current');*/
window.location.href = $(this).val();
})
});
var prevPage = '<a href="{url}"><span class="iconfont">&#xe60f;</span>&nbsp;PREV</a>';
var lastPage = '<a href="{url}" class="next">NEXT&nbsp;<span class="iconfont">&#xe610;</span></a>';
var pageHtml = '<div id="pageContent" style="text-align: center;" class="pagination">'+
'<div class="pagination-inner clearfix" id="img_page" model="default" rel="">{prevPage}{lastPage}</div></div>';
var getPagination = function(page, totalPage) {
if($("#pageContent").size() >0 ) {
return ""
}
if( page - 1 >= 1 ) {
prevPage = prevPage.replace("{url}", "/news/index/page/" + ((page - 1 ) * 4 - 3));
pageHtml = pageHtml.replace("{prevPage}", prevPage);
}
if(page < totalPage) {
lastPage = lastPage.replace("{url}", "/news/index/page/"+ (page * 4 + 1) );
pageHtml = pageHtml.replace("{lastPage}", lastPage);
}
if(page < 1) {
pageHtml = '';
}
pageHtml = pageHtml.replace("{prevPage}","").replace("{lastPage}","");
return pageHtml;
}
$(window).bind("scroll",function()
{
var total = $(".main-layout").attr("total");
var ajaxPage = $(".main-layout").attr("page");//ajax请求的page
var total_times = parseInt($(".main-layout").attr("total_times"));
var limit = 8;
var times = $(".main-layout").attr("times") ? $(".main-layout").attr("times") : 0;
var page = Math.ceil(parseInt(ajaxPage) / (total_times+1));
var totalPage = Math.ceil(total / (limit * (total_times + 1)));
if($(window).scrollTop() >= $(document).height() - $(window).height()- 50 ) {
if(total > limit && times < total_times && page < totalPage) {
$.ajax
({
type:"get",
url:"/news/index/page/"+(parseInt(ajaxPage)+1),
success:function(data)
{
var news_page = $(data);
if($(".main-layout").attr("page") != news_page.attr("page") && news_page.html() != "")
{
$(".main-layout").append(news_page.html());
$(".main-layout").attr({
"total":news_page.attr("total"),
"page":news_page.attr("page"),
"times":++times
});
// console.log(news_page.attr("page"));
// console.log("times:" + times);
}
page = Math.ceil(parseInt(news_page.attr("page")) / (total_times+1));//实现页码
// console.log("page:" + page);
// console.log("totalPage:" + totalPage);
if(times == total_times || news_page.html() == "")
{
$(".main-layout").append(getPagination(page, totalPage));
}
}
});
} else if(page == totalPage) {
$(".main-layout").append(getPagination(getPagination(page, totalPage)));
}
return false;
}
});
};
});
... ...
... ... @@ -71,10 +71,6 @@ class Controller_Abstract extends Framework_YController
$callback = $cookieUrl;
}
}
if($this->_request->isAjax())
{
$this->_platform = 'web';
}
//yohobuy.com连接,自动跳转到客户端
if(strpos($callback, 'yohobuy.com') !== false)
{
... ... @@ -97,7 +93,7 @@ class Controller_Abstract extends Framework_YController
{
$action .= 'Mobile';
}
else
else if(!$this->existsAction($action))
{
if(!file_exists($this->getViewBasePath().$this->getViewScriptPath().'/'.$_REQUEST['controller'].'/'.$this->_viewname.'.php'))
{
... ...
... ... @@ -61,6 +61,51 @@ class Controller_News extends Controller_Abstract
}
/**
* 手机端最新资讯
*
*/
public function indexMobileAction()
{
$requestTag = $tag = trim($this->_request->tag);//标签
$exceptTags = array('视频');
$limit = 8;
$total = Facade_News::getTotal($tag, $exceptTags);
$page = new Lib_Helper_Pagination($total, $limit);
if ($tag)
{
$page->setParames(array('tag' => $requestTag)) ;
}
$tagKeys = Facade_News::$types;
$list = Facade_News::getList($tag, $page->getOffset(), $limit, $exceptTags);
$this->_view['list'] = $list;
$newTags = Facade_News::getTags();
$this->_view['total'] = 0;
$tags = $temp = array();
foreach($newTags as $tag)
{
$temp[$tag['tag']] = $tag;
}
foreach($tagKeys as $tagKey)
{
$tags[$tagKey] = array('tag' => $tagKey, 'num'=> 0);
if(isset($temp[$tagKey]))
{
$tags[$tagKey] = $temp[$tagKey];
}
}
$tags['视频'] = $temp['手机视频'];
$this->_view['tags'] = $tags;
foreach($this->_view['tags'] as $val)
{
$this->_view['total'] += $val['num'];
}
$this->_view['current_tag'] = $requestTag;
$this->_view['isAjax'] = $this->_request->isAjax();
$this->_view['total'] = $total;
$this->_view['page'] = $page->getCurrentPage();
}
/**
* 发布资讯
*/
public function publishAction()
... ...
... ... @@ -85,7 +85,7 @@ class Service_News extends Lib_Service
$where = '`tag` like ("'.$tag.'%")' ;
}
$where = ' WHERE '.$where .' AND '.$exceptWhere;
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getList', array('offset' => $offset, 'limit' => $limit), array('where' => $where));
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getList', array('offset' => intval($offset), 'limit' => intval($limit)), array('where' => $where));
}
/**
... ...
... ... @@ -7,8 +7,6 @@
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="yes" name="apple-touch-fullscreen" />
<meta content="telephone=no" name="format-detection" />
<meta property="og:image" content="http://img03.res.yoho.cn/blogimg/2015/06/10/16/01a86ae7be6e232d20ae7847acd43caf44.jpg?imageMogr2/thumbnail/0100x0100"/>
<meta property="og:description" content="test>" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<link rel="stylesheet" href="<?php echo SITE_RES;?>/css/mobile.css"/>
<link rel="stylesheet" href="<?php echo SITE_RES;?>/css/emoji.css"/>
... ... @@ -16,7 +14,6 @@
<body>
<div class="mobile-wrap">
<div class="hd">
<div id="facebook_cover" style="width: 0px; height:0px;"><img src="http://img02.res.yoho.cn/blogimg/2015/06/12/15/02c7c0d9860ebd0c7096ceed035077ef8d.jpg" style="width: 0px; height:0px;"/></div>
<div class="header-download-wrap">
<div class="header-download clearfix">
<div class="tip-pic"></div>
... ...
<?php if($this->view->isAjax):?>
<div id="news_page" total="<?php echo $this->view->total;?>" page="<?php echo $this->view->page;?>">
<?php $this->_widget('news_listmobile', array('list'=> $this->view->list));?>
</div>
<?php else:?>
<?php $this->_extends('layout/default_layout_mobile');?>
<?php $this->_block('main');?>
<div class="news-select">
... ... @@ -14,18 +19,10 @@
</div>
<div class="news-main content-main current">
<div class="news-content">
<div class="main-layout clearfix">
<?php $this->_widget('news_listmobile', array('list'=> $this->view->list));?>
<div class="main-layout clearfix" total="<?php echo $this->view->total;?>" page="<?php echo $this->view->page;?>" total_times="3">
<?php $this->_widget('news_listmobile', array('list'=> $this->view->list));?>
</div>
</div>
<div id="pageContent" style="text-align: center;" class="pagination">
<?php $this->_component('Common_Pagination',array(
'pagination' => $this->view->pagination,'next_label' => 'NEXT&nbsp;<span class="iconfont">&#xe610;</span>',
'prev_label' => '<span class="iconfont">&#xe60f;</span>&nbsp;PREV',
'is_mobile' => true,'prev_class'=>'iconfont','prev_class'=>'iconfont',
'next_class'=>'next','page_class'=>'pagination-inner clearfix', 'id'=>'img_page'
));?>
</div>
</div>
<?php $this->_endblock();?>
<?php $this->_block('js');?>
... ... @@ -35,5 +32,6 @@ seajs.use("mobile", function(mobile)
mobile.news();
});
</script>
<?php $this->_endblock();?>
<?php $this->_endblock();?>
<?php endif;?>
 
\ No newline at end of file
... ...