Commit f7880a78 by 朱继来

热门商品接口

parent a5a02bbd
......@@ -69,7 +69,7 @@ return array(
'uploadresult' => 'Home/Index/uploadresult',
'integral' => 'Home/Index/integral',
'notice' => 'Home/Index/notice',
'chat' => 'Home/Index/chat'
'chat' => 'Home/Index/chat',
'hotgoods' => 'Home/Cms/getHotGoods',
),
);
\ No newline at end of file
......@@ -32,7 +32,7 @@ class BaseController extends Controller
} else {
return $this->apiReturn(7004, '未找到数据');
}
}
}
/**
* 统一格式返回
......
<?php
namespace Home\Controller;
use Home\Controller\BaseController;
class CmsController extends BaseController
{
// 获取热门商品
public function getHotGoods()
{
$datas = $this->apiBaseCache('pc_hot_goods', '', 5); // 热门商品
return $this->jsonReturn(0, '', $datas['data']);
}
/**
* 统一格式返回
* @param integer $code [description]
* @param string $msg [description]
* @param array $extend [description]
* @return [type] [description]
*/
protected function jsonReturn($code = 0, $msg = '', $extend = array())
{
$data = array(
'err_code' => $code,
'err_msg' => $msg,
'data' => $extend,
);
if(isset($_GET['callback']) && !empty($_GET['callback'])){
echo $_GET['callback'].'('.json_encode($data).')';exit;
}else{
echo json_encode($data);exit;
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment