Authored by Rock Zhang

添加收藏有关的接口,并处理有关数据;为个人中心首页添加一些链接地址

... ... @@ -130,6 +130,24 @@ class UserData
}
/**
* 取消收藏的商品数据
*
* @param int $uid 用户ID
* @param int $fav_id 要取消的收藏id
* @return array 接口返回的数据
*/
public static function favoriteDelete($uid, $fav_id)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.cancel';
$param['type'] = 'product';
$param['fav_id'] = $fav_id;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* YOHO币数据
*
* @param int $uid 用户ID
... ...
{{> layout/header}}
<div class="my-page yoho-page">
<div class="my-header">
<div class="user-info">
<div class="user-info"><!--/home/personaldetails-->
<img class="user-avatar" src="{{head_ico}}">
<span class="username">{{profile_name}}</span>
{{#vip_info}}
... ... @@ -11,11 +11,11 @@
</div>
</div>
<div class="my-link clearfix">
<a class="link-item" href="/home/">
<a class="link-item" href="/home/favorite">
{{product_favorite_total}}
<p>收藏的商品</p>
</a>
<a class="link-item" href="/home/">
<a class="link-item" href="/home/favoritebrand">
{{brand_favorite_total}}
<p>收藏的品牌</p>
</a>
... ... @@ -54,26 +54,26 @@
</a>
</div>
<div class="group-list">
<a class="list-item" href="/home/">
<a class="list-item" href="/home/coupons">
<span class="iconfont icon">&#xe63a;</span>
优惠券
<span class="iconfont num">{{coupon_num}} &#xe604;</span>
</a>
<a class="list-item" href="/home/">
<a class="list-item" href="/home/currency">
<span class="iconfont icon">&#xe635;</span>
YOHO
<span class="iconfont num">{{yoho_coin_num}} &#xe604;</span>
</a>
</div>
<div class="group-list">
<a class="list-item" href="/home/">
<a class="list-item" href="/home/message">
<span class="iconfont icon">&#xe636;</span>
消息
<span class="iconfont num">{{inbox_total}} &#xe604;</span>
</a>
</div>
<div class="group-list">
<a class="list-item" href="/home/">
<a class="list-item" href="/home/onlineService">
<span class="iconfont icon">&#xe63c;</span>
在线客服
<span class="iconfont num">&#xe604;</span>
... ...
... ... @@ -46,114 +46,23 @@ class HomeController extends AbstractAction
* 用户收藏的商品
*/
public function favoriteAction() {
// 设置网站标题
$this->setTitle('我的收藏');
$this->setNavHeader('我的收藏', true, SITE_MAIN);
$uid = $this->getUid();
$uid = 8826435;
$gender = Helpers::getGenderByCookie();
$favProducts = \Index\UserModel::getFavProductData($uid);
//print_r($favProducts);
$favBrands = \Index\UserModel::getFavBrandData($uid, $gender);
$this->_view->display('favorite', array(
'favPage' => true, //加载js
'pageHeader' => array(
'navBack' => true,
'navTitle' => '我的收藏',
'navHome' => true
),
'pageFooter' => true,
'favorite' => true,
'hasFavProduct' => array(
'0' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'title' => 'adidas Originals ZX FLUXM22508 ',
'price' => '¥800',
'discountPrice' => false,
'savePrice' => false,
'sellOut' => true
),
'1' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'title' => 'adidas Originals ZX FLUXM22508 ',
'price' => '¥800',
'discountPrice' => '¥500',
'savePrice' => '¥300',
'sellOut' => false
)
),
'hasFavBrand' => array(
'0' => array(
'id' => '1',
'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'brandName' => 'VANS',
'update' => 12,
'discount' => 10,
'link' => '#',
'productList' => array(
'0' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'price' => '¥240',
'discount' => '¥240'
),
'1' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'price' => '¥240',
'discount' => '¥240'
),
'2' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'price' => '¥240',
'discount' => '¥240'
),
'3' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'price' => '¥240',
'discount' => '¥240'
)
)
),
'1' => array(
'id' => '2',
'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'brandName' => 'VANS',
'update' => 12,
'discount' => 10,
'link' => '#',
'productList' => array(
'0' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'price' => '¥240',
'discount' => '¥240'
),
'1' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'price' => '¥240',
'discount' => '¥240'
),
'2' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'price' => '¥240',
'discount' => '¥240'
),
'3' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'price' => '¥240',
'discount' => '¥240'
)
)
),
'2' => array(
'id' => '3',
'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'brandName' => 'VANS',
'update' => 12,
'discount' => 10,
'link' => '#',
'productList' => array(
'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'price' => '¥240',
'discount' => false
)
)
)
'hasFavProduct' => $favProducts,
'hasFavBrand' => $favBrands
));
}
... ... @@ -161,9 +70,22 @@ class HomeController extends AbstractAction
/**
* 用户收藏的商品-删除
*/
public function favoriteDelAction() {
public function favoriteDelAction()
{
$result = array();
//$this->echoJson();
if ($this->isAjax()) {
$uid = $this->getUid();
$fav_id = $this->post('fav_id', 0);
$result = \Index\UserModel::favoriteDelete($uid, $fav_id);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
... ...
... ... @@ -150,7 +150,19 @@ class UserModel
// 处理用户收藏的商品数据
if (isset($favProduct['data']) && !empty($favProduct['data'])) {
$result = $favProduct['data'];
$product = array();
foreach ($favProduct['data']['product_list'] as $val) {
$product = array();
$product['imgUrl'] = $val['image'];
$product['title'] = $val['product_name'];
$product['price'] = '¥'.$val['market_price'];
$product['discountPrice'] = '¥'.$val['sales_price'];
$product['savePrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥'.($val['market_price'] - $val['sales_price']) : false;
$product['sellOut'] = boolval($val['price_down']);
$result[] = $product;
}
}
return $result;
... ... @@ -172,7 +184,43 @@ class UserModel
// 处理用户收藏的品牌数据
if (isset($favBrand['data']) && !empty($favBrand['data'])) {
$result = $favBrand['data'];
$brand = array();
foreach ($favBrand['data']['brand_list'] as $val) {
$brand = array();
$brand['id'] = $val['brand_id'];
$brand['brandImg'] = Images::getImageUrl($val['brand_ico'], 235, 314);
$brand['brandName'] = $val['brand_name'];
$brand['update'] = $val['new_product_num'];
$brand['discount'] = $val['product_discount_num'];
$brand['link'] = '#';
// 处理品牌产品
$product = array();
foreach ($val['new_product'] as $one) {
$product = array();
$product['imgUrl'] = Images::getImageUrl($one['default_images'], 235, 314);
$product['price'] = '¥'.$one['market_price'];
$product['discount'] = '¥'.$one['sales_price'];
$brand['productList'][] = $product;
}
$result[] = $brand;
}
}
return $result;
}
public static function favoriteDelete($uid, $fav_id)
{
$result = array();
if (empty($fav_id)) {
$result['code'] = 400;
$result['message'] = '取消的商品不可用';
} else {
$result = UserData::favoriteDelete($uid, $fav_id);
}
return $result;
... ...