Authored by Rock Zhang

ll

framework @ e9d066dd
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
Subproject commit e9d066dd88a8e7e37103021c427a205a5cfcdcec
... ...
... ... @@ -28,9 +28,9 @@ class HomeController extends AbstractAction
// 检查用户是否登录, 未登录则跳转到登录页
// @todo 为了方便测试,支持传uid参数
$uid = $this->getUid();
if (!$uid) {
/*if (!$uid) {
$uid = $this->_uid = $this->get('uid', 8826435); //$this->getUid(true);
}
}*/
$action = $this->getRequest()->getActionName();
if (!$uid && $action !== 'index') {
... ... @@ -98,8 +98,8 @@ class HomeController extends AbstractAction
$uid = $this->getUid();
$gender = Helpers::getGenderByCookie();
$favProducts = UserModel::getFavProductData($uid);
$favBrands = UserModel::getFavBrandData($uid, $gender);
$favProducts = UserModel::getFavProductData($this->_uid, 1, 10);
$favBrands = UserModel::getFavBrandData($this->_uid, 10, 1, 10);
$data = array(
'favPage' => true, //加载js
... ... @@ -119,6 +119,44 @@ class HomeController extends AbstractAction
}
/**
* 用户收藏的商品数据获取接口
*/
public function favProductAction() {
$result = array();
if ($this->isAjax()) {
$page = $this->post('page', 1);
$result = UserModel::getFavProductData($this->_uid, $page, 10);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 用户收藏的品牌数据获取接口
*/
public function favBrandAction() {
$result = array();
if ($this->isAjax()) {
$page = $this->post('page', 1);
$result = UserModel::getFavBrandData($this->_uid, 10, $page, 10);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 用户收藏的商品-删除
*/
public function favoriteDelAction()
... ... @@ -205,6 +243,7 @@ class HomeController extends AbstractAction
'couponsUrl' => UserModel::getCouponData($uid),
'couponsPage' => true
);
$this->_view->display('coupons', $coupons);
}
... ...
... ... @@ -145,14 +145,16 @@ class UserModel
* 处理用户收藏的商品数据
*
* @param int $uid 用户ID
* @param int $page 第几页
* @param int $limit 限制读取的数目,默认10
* @return array|mixed 处理之后的收藏的商品数据
*/
public static function getFavProductData($uid)
public static function getFavProductData($uid, $page, $limit)
{
$result = array();
// 调用接口获取用户收藏的商品数据
$favProduct = UserData::favoriteProductData($uid);
$favProduct = UserData::favoriteProductData($uid, $page, $limit);
// 处理用户收藏的商品数据
if (isset($favProduct['data']) && !empty($favProduct['data'])) {
... ...