Authored by hf

fixes bug to product detail page comments

... ... @@ -20,6 +20,7 @@ class DetailData
const PRODUCT_BASE_INFO = 'product/queryProductDetailByProductId';
const PRODUCT_SIZE_INFO = 'product/queryProductIntroBySkn';
const PRODUCT_CONSULT_LIST = 'consult/queryConsults';
const PRODUCT_COMMENT_LIST = 'sns/comments/commentList';
/**
* 商品基本信息
... ... @@ -63,6 +64,23 @@ class DetailData
) );
}
/**
* 评论内容列表
*
* @param int $productId 产品ID
* @param int $pageNum 页码数
* @param int $pageSize 每页显示个数
* @return array
*/
public static function commentList($productId, $pageNum, $pageSize)
{
return Yohobuy::jsonPost(Yohobuy::API_URL_PRODUCTDETAIL . self::PRODUCT_COMMENT_LIST, array(
'productId' => intval($productId),
'pageNum' => intval($pageNum),
'pageSize' => intval($pageSize),
) );
}
/**
* 为你优选的商品列表
*
... ...
... ... @@ -3,7 +3,7 @@
<div class="goto-consult">
<i class="iconfont consult-logo">&#xe639;</i>
<span>我要咨询</span>
<a href="/consultform" class="iconfont enter-consult-page">&#xe604;</a>
<a href="{{consultUrl}}" class="iconfont enter-consult-page">&#xe604;</a>
</div>
{{# consults}}
<div class="goods-consults" id="goods-consults">
... ...
... ... @@ -361,9 +361,25 @@ class DetailModel
/**
* 获取评价列表
*/
public static function getComments()
public static function getComments($productId, $pageNum = 1, $pageSize = 100)
{
$result = array();
if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) {
$commentList = DetailData::commentList($productId, $pageNum, $pageSize);
if (!empty($commentList)) {
$build = array();
foreach ($commentList as $value) {
$build['userName'] = '';
$build['desc'] = '';
$build['content'] = '';
$build['time'] = '';
$result[] = $build;
}
}
}
return $result;
}
/**
... ... @@ -406,7 +422,7 @@ class DetailModel
$result = array();
if (is_numeric($productSkn)) {
$preference = DetailData::preference($productSkn); var_dump($preference); exit;
$preference = DetailData::preference($productSkn);
if (!empty($preference['data'])) {
foreach ($preference['data'] as $value) {
$result['recommendList'][] = Helpers::formatProduct($value, false, true, true, 299, 388, false, false);
... ...
<?php
use Action\AbstractAction;
use Plugin\Helpers;
/**
* 商品详情的控制器
... ... @@ -66,6 +67,7 @@ class DetailController extends AbstractAction
*/
public function commentsAction()
{
$productId = $this->get('product_id', 0);
$total = $this->get('total');
if (!is_numeric($total)) {
$total = 0;
... ... @@ -81,29 +83,7 @@ class DetailController extends AbstractAction
'goodsCommentsPage' => true,
'pageFooter' => true,
'comments' => array(
'list' => array(
array(
'userName' => 'Lynnic',
'desc' => '购买了白色Mate7',
'content' => '活动时买的,挺超值。上身效果也不错。质量
很好,买送人的,很满意。而且物流相当给...',
'time' => '2014-08-12 10:24:26'
),
array(
'userName' => 'Lynnic',
'desc' => '购买了白色Mate7',
'content' => '活动时买的,挺超值。上身效果也不错。质量
很好,买送人的,很满意。而且物流相当给...',
'time' => '2014-08-12 10:24:26'
),
array(
'userName' => 'Lynnic',
'desc' => '购买了白色Mate7',
'content' => '活动时买的,挺超值。上身效果也不错。质量
很好,买送人的,很满意。而且物流相当给...',
'time' => '2014-08-12 10:24:26'
)
)
'list' => \Product\DetailModel::getConsults($productId),
),
);
... ... @@ -136,7 +116,8 @@ class DetailController extends AbstractAction
'pageFooter' => true,
'consults' => array(
'list' => \Product\DetailModel::getConsults($productId),
)
),
'consultUrl' => Helpers::url('/product/detail/consultform'),
);
// 渲染模板
... ... @@ -148,19 +129,11 @@ class DetailController extends AbstractAction
*/
public function consultformAction()
{
$data = array(
'consultform' => true,
'pageHeader' => array(
'navBack' => 'sss ',
// 'navHome' => 'sss ',
'navTitle' => '我要咨询'
)
);
$this->setTitle('我要咨询');
$this->setNavHeader('我要咨询');
$this->_view->assign('title', '我要咨询');
//$this->_view->display('brand', compact('brands'));
// 渲染模板
$this->_view->display('consultform', $data);
$this->_view->display('consultform', array('consultform' => true));
}
/**
... ... @@ -173,10 +146,10 @@ class DetailController extends AbstractAction
{
$result = array();
//if ($this->isAjax()) {
$productSkn = $this->get('productSkn', 50000058);
$result = \Product\DetailModel::getPreference($productSkn); var_dump($result);
//}
if ($this->isAjax()) {
$productSkn = $this->get('productSkn'); // 50000058
$result = \Product\DetailModel::getPreference($productSkn);
}
if (empty($result)) {
echo ' ';
... ...