public function articleList()
 {
     //分页设置
     $pageSize = 20;
     //查询条数
     $currPage = I('page', '1', 'intval');
     //获取当前页数
     $countPage = 0;
     //总页数
     $uid = I('uid', '', 'intval');
     //用户ID
     //查找显示帖子总数量
     $countPage = M('article')->where(array('uid' => $uid))->count();
     //查找分页数据
     $limit = ($currPage - 1) * $pageSize . ',' . $pageSize;
     $list = D('ArticleRelation')->getArticleHomeList(array('uid' => $uid), $limit);
     //插入赞及评论表
     for ($i = 0; $i < count($list); $i++) {
         $list[$i]['pic'] = pictureUrl($list[$i]['pic'], 640);
         //用户上传图片转换
         $list[$i]['time'] = timeFriendly($list[$i]['time']);
         //上传时间转换
         $list[$i]['userinfo']['headicon'] = headiconUrl($list[$i]['userinfo']['headicon'], 60);
         //用户头像转换
         $where = array('aid' => $list[$i]['id']);
         //获取帖子的赞
         $supportlist = D('SupportRelation')->getArticleSupports($where);
         if ($supportlistNum = count($supportlist)) {
             for ($num = 0; $num < $supportlistNum; $num++) {
                 $supportlist[$num]['time'] = timeFriendly($supportlist[$num]['time']);
                 $supportlist[$num]['userinfo']['headicon'] = headiconUrl($supportlist[$num]['userinfo']['headicon'], 60);
                 //用户头像转换
             }
             $list[$i]['supportlist'] = $supportlist;
         } else {
             $list[$i]['supportlist'] = '';
         }
         //获取帖子的评论
         $commontlist = D('CommentRelation')->getArticleComments($where, 2);
         if ($commontlistNum = count($commontlist)) {
             for ($num = 0; $num < $commontlistNum; $num++) {
                 $commontlist[$num]['time'] = timeFriendly($commontlist[$num]['time']);
                 $commontlist[$num]['fromuser']['headicon'] = headiconUrl($commontlist[$num]['fromuser']['headicon'], 60);
                 //用户头像转换
                 if (!$commontlist[$num]['touser']) {
                     $commontlist[$num]['touser'] = '';
                 } else {
                     $commontlist[$num]['touser']['headicon'] = headiconUrl($commontlist[$num]['touser']['headicon'], 60);
                     //用户头像转换
                 }
             }
             $list[$i]['commontlist'] = $commontlist;
         } else {
             $list[$i]['commontlist'] = '';
         }
         //是否赞
         if (inErArray(session('uid'), $info['supportlist'], 'uid')) {
             $info['issupport'] = 1;
         } else {
             $info['issupport'] = 0;
         }
     }
     $this->ajaxReturn($list, "个人中心帖子列表", 1);
 }
 public function homeList()
 {
     //分页设置
     $pageSize = 20;
     //查询条数
     $currPage = I('page', '1', 'intval');
     //获取当前页数
     $countPage = 0;
     //总页数
     $uid = session('uid');
     //登录用户的ID标识
     $focuslist = array();
     //查找出用户所关注的人的列表ID
     $focus = M('focus')->field('fid')->where(array('uid' => $uid))->select();
     foreach ($focus as $item) {
         $focuslist[] = $item['fid'];
     }
     $focuslist[] = $uid;
     //用户及所关注的人的列表ID
     //查找显示帖子总数量
     $where = array('uid' => array('IN', $focuslist));
     $countPage = M('article')->where($where)->count();
     //查找分页数据
     $limit = ($currPage - 1) * $pageSize . ',' . $pageSize;
     $list = D('ArticleRelation')->getArticleHomeList($where, $limit);
     for ($i = 0; $i < count($list); $i++) {
         if ($list[$i]['time'] < 1422281700) {
             $list[$i]['pic'] = pictureUrl($list[$i]['pic'], 640);
             //用户上传图片转换
         } else {
             $list[$i]['pic'] = pictureUrl($list[$i]['pic'], 1280);
             //用户上传图片转换
         }
         $list[$i]['time'] = timeFriendly($list[$i]['time']);
         //上传时间转换
         $list[$i]['userinfo']['headicon'] = headiconUrl($list[$i]['userinfo']['headicon'], 60);
         //用户头像转换
         $where = array('aid' => $list[$i]['id']);
         //获取帖子的赞
         $supportlist = D('SupportRelation')->getArticleSupports($where);
         if ($supportlistNum = count($supportlist)) {
             for ($num = 0; $num < $supportlistNum; $num++) {
                 $supportlist[$num]['time'] = timeFriendly($supportlist[$num]['time']);
                 $supportlist[$num]['userinfo']['headicon'] = headiconUrl($supportlist[$num]['userinfo']['headicon'], 60);
                 //用户头像转换
             }
             $list[$i]['supportlist'] = $supportlist;
         } else {
             $list[$i]['supportlist'] = '';
         }
         //获取帖子的评论
         $commontlist = D('CommentRelation')->getArticleComments($where, 3);
         if ($commontlistNum = count($commontlist)) {
             for ($num = 0; $num < $commontlistNum; $num++) {
                 $commontlist[$num]['time'] = timeFriendly($commontlist[$num]['time']);
                 $commontlist[$num]['fromuser']['headicon'] = headiconUrl($commontlist[$num]['fromuser']['headicon'], 60);
                 //用户头像转换
                 if (!$commontlist[$num]['touser']) {
                     $commontlist[$num]['touser'] = '';
                 } else {
                     $commontlist[$num]['touser']['headicon'] = headiconUrl($commontlist[$num]['touser']['headicon'], 60);
                     //用户头像转换
                 }
             }
             $list[$i]['commontlist'] = $commontlist;
         } else {
             $list[$i]['commontlist'] = '';
         }
         //是否赞
         if (inErArray(session('uid'), $list[$i]['supportlist'], 'uid')) {
             $list[$i]['issupport'] = 1;
         } else {
             $list[$i]['issupport'] = 0;
         }
     }
     $this->ajaxReturn($list, "主页帖子列表", 1);
 }