Authored by 郭成尧

'购物车为你优选'

... ... @@ -191,8 +191,8 @@ function getTogetherProduct($obj, url, page) {
});
}
// 最近浏览
getTogetherProduct($histroy, '/cart/index/getHistroyProduct');
// 为你优选
getTogetherProduct($histroy, '/cart/index/getRecommendProduct');
// 凑单商品
getTogetherProduct($together, '/cart/index/getTogetherProduct');
... ... @@ -205,7 +205,7 @@ $together.on('click', '.pagenext, .pageprev', function() {
});
//凑单商品,历史商品商品折叠
//凑单商品,为你优选商品商品折叠
$shopCart.on('click', '.icon-minus, .icon-add', function() {
if ($(this).hasClass('icon-minus')) {
$(this).parents('.title').next('.main').hide();
... ... @@ -226,7 +226,7 @@ $histroy.on('click', '.pagenext, .pageprev', function() {
} else {
--pageNum > 0 || (pageNum = 1);
}
getTogetherProduct($histroy, '/cart/index/getHistroyProduct', {
getTogetherProduct($histroy, '/cart/index/getRecommendProduct', {
page: pageNum
});
... ... @@ -271,15 +271,16 @@ function productInfo(data) {
$('.detail-bigpic:not(.none) .bigpic:gt(0)').hide();
$('.showSizeBox:not(.none)').find('span').each(function() {
if ($(this).hasClass('null-atcivec')) {
$('.addcart').addClass('none');
$('.btn_sellout').removeClass('none');
} else {
$('.addcart').removeClass('none');
$('.btn_sellout').addClass('none');
return false;
}
});
if ($(this).hasClass('null-atcivec')) {
$('.addcart').addClass('none');
$('.btn_sellout').removeClass('none');
} else {
$('.addcart').removeClass('none');
$('.btn_sellout').addClass('none');
return false;
}
});
});
}
... ... @@ -304,7 +305,7 @@ $payWapper.on('click', '.cart-add-btn', function() {
});
});
//凑单商品,历史商品商品记录
//凑单商品,为你优选商品商品记录
$('.clearfix').on('click', '.btn_view_s', function() {
productId = $(this).data('id');
promotionId = $(this).parents('table').data('promotion');
... ...
... ... @@ -420,6 +420,56 @@ class CartModel
}
/**
* 获取为你优选商品 待处理
*
* @param int $page 分页页码
* @return array
*/
public static function getRecommendProduct($page)
{
$result = array('code' => 200, 'message' => '', 'data' => array('header' => '为你优选', 'hasPrev' => false, 'hasNext' => false, 'item' => array()));
do {
if (!is_numeric($page)) {
break;
}
$together = CartData::togetherProduct($page);
if (empty($together['data']['goods'])) {
break;
}
$result['data']['hasNext'] = true;
$result['data']['hasPrev'] = true;
$build = array();
foreach ($together['data']['goods'] as $value) {
$build = array();
$build['id'] = $value['id'];
$build['skn'] = $value['product_skn'];
$build['href'] = $value['url'];
$build['title'] = $value['product_name'];
$build['img'] = Helpers::getImageUrl($value['default_pic'], 100, 100);
$build['alt'] = $value['product_name'];
$build['price'] = $value['price']['sales_price'];
if ($value['price']['sales_price'] !== $value['price']['market_price']) {
$build['marketPrice'] = $value['price']['market_price'];
}
$result['data']['item'][] = $build;
}
// 当数据量不足6个时,判定为没有下一页
if ($page == 1 && !isset($result['data']['item'][5])) {
$result['data']['hasPrev'] = false;
$result['data']['hasNext'] = false;
}
} while (false);
return $result;
}
/**
* 获取最近浏览商品
*
* @param int $page 分页页码
... ...
... ... @@ -176,6 +176,21 @@ class IndexController extends WebAction
}
/**
* 为你优选商品异步请求 待处理
*/
public function getRecommendProductAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '为你优选');
if ($this->isAjax()) {
$page = $this->get('page', 1);
$result = CartModel::getRecommendProduct($page);
}
$this->echoJson($result);
}
/**
* 最近浏览的商品异步请求
*/
public function getHistroyProductAction()
... ...