Skip to content

Commit

Permalink
api
Browse files Browse the repository at this point in the history
  • Loading branch information
hui.liu committed Mar 12, 2016
1 parent 57c33c5 commit b0ffce0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion api/api_news.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@
break;
case 'list':
$catid = empty($_GET['catid']) ? 0 : intval($_GET['catid']);
$isHistory = empty($_GET['isHistory']) ? 0 : 1;
if($catid==0)
json_error('分类不存在');
$subids=C::t('news_cat')->getSonByCatid($catid);
$sql.=' and catid IN(%n)';
$param[]=$subids;
$sql.=" and status='1'";
$sql = !$isHistory ? $sql . ' and v.vid is null' : $sql;
$data = listView($sql,$param);
$message = 'success';
break;
Expand Down Expand Up @@ -139,7 +141,7 @@ function listView($sql,$param){
global $_G;
//查询
$orderby="ORDER BY n.istop DESC , n.dateline DESC";
$perpage=20;
$perpage=2;
$page = empty($_GET['page'])?1:intval($_GET['page']);
$start=($page-1)*$perpage;
$params = array('news');
Expand All @@ -161,6 +163,7 @@ function listView($sql,$param){
if($value['opuid'] && $opuser=getuserbyuid($value['opuid'])){
$value['opauthor']=$opuser['username'];
}
$value['dateDiff'] = dgmdate($value[dateline],'u');
$data[]=$value;
}
}
Expand Down
8 changes: 6 additions & 2 deletions user/class/class_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ function api_login()
$data = array(
'username'=>$result['ucresult']['username'],
'uid'=>$_G['member']['uid'],
'token'=>$token
'token'=>$token,
'avatar' =>$_G['config']['common']['home_url'].'/'.avatar($_G['member']['uid'],'middle',true),
'email'=>$result['ucresult']['email']
);
if (empty($_GET['handlekey']) || !empty($_GET['lssubmit'])) {
if (defined('IN_MOBILE')) {
Expand Down Expand Up @@ -378,7 +380,9 @@ function api_logout()
function api_userInfo(){
global $_G;
$uid = $_GET['uid'];
json_success('success',array('uid'=>2,'username'=>'test','token'=>111));
$user = C::t('user')->fetch_by_uid($uid);
$user['avatar'] = $_G['config']['common']['home_url'].'/'.avatar($uid,'middle',true);
json_success('success',$user);
}
}

Expand Down

0 comments on commit b0ffce0

Please sign in to comment.