<?php
/**文章
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author lss <lss@sina.cn>
 */
namespace Mobile\Controller;
class ArticleController extends BaseController {
        /**
          *帮助中心
          */
        public function help() {
            $data=D("Article")->help();
            $cat_info=$data['cat_info'];
            $this->assign('cat_info',$cat_info);
            $this->assign('page_title','帮助中心');
            $this->assign('before_title','帮助中心');
            $this->display();
        }
        /**
           *文章列表
           */
        public function article_list($type=0) {
            $article_cat_list = D('Article')->article_cat_list();
            $this->assign('article_cat_list',$article_cat_list);
            $catid=I('catid');//分类id
            $param=I('param.');
            if(empty($catid)){
                $param['is_tuijian'] = 1;
            }else{
                $param['is_tuijian'] = 0;
            }

            $data=D('Article')->article_list($catid,$param);
            foreach ($data['article_list']['list'] as $k => $v){
                if($v['shop_id'] > 0)
                    $data['article_list']['list'][$k]['shop_name'] = idtoname ($v['shop_id'],'Shops');
                else
                    $data['article_list']['list'][$k]['shop_name'] = '平台发布';
            }
            if($type==1)return $data;
            $article_list=$data['article_list'];
            // $catname=$data['catname'];
            $catname='头条';
            $this->assign($data['article_list']);
            $this->assign('article_list',$article_list);
            $this->assign('page_title',$catname);
            $this->assign('before_title',$catname);


            $this ->assign('pid',I('pid'));
            $this ->assign('catid',$catid);
            $this->assign('articleList',$articleList);
            $this->display();
        }

        public function article_list_more(){
            $return['status']=0;
            $data=$this->article_list(1);
            if(empty($data['article_list']['list']))$this->ajaxReturn($return);
            $return['status']=1;
             $article_list=$data['article_list'];
            $this->assign($data['article_list']);
             $this->assign('article_list',$article_list);
            $list_html = $this ->fetch('articles');
            $return['html']=$list_html;
            $return['nowPage']=$article_list['nowPage'];
            $return['totalPages']=$article_list['totalPages'];
            $this->ajaxReturn($return);
        }
        /**
           *文章内容
           */
        public function article_cont() {
			$id=I('param.id');
			$type=I('param.type');
            $member_info=session('member_info');
			$data=D('Article')->article_con($id,$type);
            $share_url=geturl('Article/article_cont',array('id'=>$id,'eid'=>$member_info['id']));
			if($data['status']==0){
				$content=$data['content'];
				$catname=$data['catname'];
                $this->assign('thumb',$data['thumb']);
                $this->assign('addtime_format',time_format($content['addtime']));
				$this->assign($content);
				$this->assign('type',$type);
				$this->assign('page_title',$catname);
				$this->assign('before_title',$catname);
				$this->display();
			}else{
				$this->Error($data['msg'],$data['url']);
			}
        }
}