fixes bug to product detail page comments
Showing
4 changed files
with
49 additions
and
42 deletions
@@ -20,6 +20,7 @@ class DetailData | @@ -20,6 +20,7 @@ class DetailData | ||
20 | const PRODUCT_BASE_INFO = 'product/queryProductDetailByProductId'; | 20 | const PRODUCT_BASE_INFO = 'product/queryProductDetailByProductId'; |
21 | const PRODUCT_SIZE_INFO = 'product/queryProductIntroBySkn'; | 21 | const PRODUCT_SIZE_INFO = 'product/queryProductIntroBySkn'; |
22 | const PRODUCT_CONSULT_LIST = 'consult/queryConsults'; | 22 | const PRODUCT_CONSULT_LIST = 'consult/queryConsults'; |
23 | + const PRODUCT_COMMENT_LIST = 'sns/comments/commentList'; | ||
23 | 24 | ||
24 | /** | 25 | /** |
25 | * 商品基本信息 | 26 | * 商品基本信息 |
@@ -63,6 +64,23 @@ class DetailData | @@ -63,6 +64,23 @@ class DetailData | ||
63 | ) ); | 64 | ) ); |
64 | } | 65 | } |
65 | 66 | ||
67 | + /** | ||
68 | + * 评论内容列表 | ||
69 | + * | ||
70 | + * @param int $productId 产品ID | ||
71 | + * @param int $pageNum 页码数 | ||
72 | + * @param int $pageSize 每页显示个数 | ||
73 | + * @return array | ||
74 | + */ | ||
75 | + public static function commentList($productId, $pageNum, $pageSize) | ||
76 | + { | ||
77 | + return Yohobuy::jsonPost(Yohobuy::API_URL_PRODUCTDETAIL . self::PRODUCT_COMMENT_LIST, array( | ||
78 | + 'productId' => intval($productId), | ||
79 | + 'pageNum' => intval($pageNum), | ||
80 | + 'pageSize' => intval($pageSize), | ||
81 | + ) ); | ||
82 | + } | ||
83 | + | ||
66 | /** | 84 | /** |
67 | * 为你优选的商品列表 | 85 | * 为你优选的商品列表 |
68 | * | 86 | * |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <div class="goto-consult"> | 3 | <div class="goto-consult"> |
4 | <i class="iconfont consult-logo"></i> | 4 | <i class="iconfont consult-logo"></i> |
5 | <span>我要咨询</span> | 5 | <span>我要咨询</span> |
6 | - <a href="/consultform" class="iconfont enter-consult-page"></a> | 6 | + <a href="{{consultUrl}}" class="iconfont enter-consult-page"></a> |
7 | </div> | 7 | </div> |
8 | {{# consults}} | 8 | {{# consults}} |
9 | <div class="goods-consults" id="goods-consults"> | 9 | <div class="goods-consults" id="goods-consults"> |
@@ -361,9 +361,25 @@ class DetailModel | @@ -361,9 +361,25 @@ class DetailModel | ||
361 | /** | 361 | /** |
362 | * 获取评价列表 | 362 | * 获取评价列表 |
363 | */ | 363 | */ |
364 | - public static function getComments() | 364 | + public static function getComments($productId, $pageNum = 1, $pageSize = 100) |
365 | { | 365 | { |
366 | + $result = array(); | ||
366 | 367 | ||
368 | + if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) { | ||
369 | + $commentList = DetailData::commentList($productId, $pageNum, $pageSize); | ||
370 | + if (!empty($commentList)) { | ||
371 | + $build = array(); | ||
372 | + foreach ($commentList as $value) { | ||
373 | + $build['userName'] = ''; | ||
374 | + $build['desc'] = ''; | ||
375 | + $build['content'] = ''; | ||
376 | + $build['time'] = ''; | ||
377 | + $result[] = $build; | ||
378 | + } | ||
379 | + } | ||
380 | + } | ||
381 | + | ||
382 | + return $result; | ||
367 | } | 383 | } |
368 | 384 | ||
369 | /** | 385 | /** |
@@ -406,7 +422,7 @@ class DetailModel | @@ -406,7 +422,7 @@ class DetailModel | ||
406 | $result = array(); | 422 | $result = array(); |
407 | 423 | ||
408 | if (is_numeric($productSkn)) { | 424 | if (is_numeric($productSkn)) { |
409 | - $preference = DetailData::preference($productSkn); var_dump($preference); exit; | 425 | + $preference = DetailData::preference($productSkn); |
410 | if (!empty($preference['data'])) { | 426 | if (!empty($preference['data'])) { |
411 | foreach ($preference['data'] as $value) { | 427 | foreach ($preference['data'] as $value) { |
412 | $result['recommendList'][] = Helpers::formatProduct($value, false, true, true, 299, 388, false, false); | 428 | $result['recommendList'][] = Helpers::formatProduct($value, false, true, true, 299, 388, false, false); |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use Plugin\Helpers; | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * 商品详情的控制器 | 7 | * 商品详情的控制器 |
@@ -66,6 +67,7 @@ class DetailController extends AbstractAction | @@ -66,6 +67,7 @@ class DetailController extends AbstractAction | ||
66 | */ | 67 | */ |
67 | public function commentsAction() | 68 | public function commentsAction() |
68 | { | 69 | { |
70 | + $productId = $this->get('product_id', 0); | ||
69 | $total = $this->get('total'); | 71 | $total = $this->get('total'); |
70 | if (!is_numeric($total)) { | 72 | if (!is_numeric($total)) { |
71 | $total = 0; | 73 | $total = 0; |
@@ -81,29 +83,7 @@ class DetailController extends AbstractAction | @@ -81,29 +83,7 @@ class DetailController extends AbstractAction | ||
81 | 'goodsCommentsPage' => true, | 83 | 'goodsCommentsPage' => true, |
82 | 'pageFooter' => true, | 84 | 'pageFooter' => true, |
83 | 'comments' => array( | 85 | 'comments' => array( |
84 | - 'list' => array( | ||
85 | - array( | ||
86 | - 'userName' => 'Lynnic', | ||
87 | - 'desc' => '购买了白色Mate7', | ||
88 | - 'content' => '活动时买的,挺超值。上身效果也不错。质量 | ||
89 | - 很好,买送人的,很满意。而且物流相当给...', | ||
90 | - 'time' => '2014-08-12 10:24:26' | ||
91 | - ), | ||
92 | - array( | ||
93 | - 'userName' => 'Lynnic', | ||
94 | - 'desc' => '购买了白色Mate7', | ||
95 | - 'content' => '活动时买的,挺超值。上身效果也不错。质量 | ||
96 | - 很好,买送人的,很满意。而且物流相当给...', | ||
97 | - 'time' => '2014-08-12 10:24:26' | ||
98 | - ), | ||
99 | - array( | ||
100 | - 'userName' => 'Lynnic', | ||
101 | - 'desc' => '购买了白色Mate7', | ||
102 | - 'content' => '活动时买的,挺超值。上身效果也不错。质量 | ||
103 | - 很好,买送人的,很满意。而且物流相当给...', | ||
104 | - 'time' => '2014-08-12 10:24:26' | ||
105 | - ) | ||
106 | - ) | 86 | + 'list' => \Product\DetailModel::getConsults($productId), |
107 | ), | 87 | ), |
108 | ); | 88 | ); |
109 | 89 | ||
@@ -136,7 +116,8 @@ class DetailController extends AbstractAction | @@ -136,7 +116,8 @@ class DetailController extends AbstractAction | ||
136 | 'pageFooter' => true, | 116 | 'pageFooter' => true, |
137 | 'consults' => array( | 117 | 'consults' => array( |
138 | 'list' => \Product\DetailModel::getConsults($productId), | 118 | 'list' => \Product\DetailModel::getConsults($productId), |
139 | - ) | 119 | + ), |
120 | + 'consultUrl' => Helpers::url('/product/detail/consultform'), | ||
140 | ); | 121 | ); |
141 | 122 | ||
142 | // 渲染模板 | 123 | // 渲染模板 |
@@ -148,19 +129,11 @@ class DetailController extends AbstractAction | @@ -148,19 +129,11 @@ class DetailController extends AbstractAction | ||
148 | */ | 129 | */ |
149 | public function consultformAction() | 130 | public function consultformAction() |
150 | { | 131 | { |
151 | - $data = array( | ||
152 | - 'consultform' => true, | ||
153 | - 'pageHeader' => array( | ||
154 | - 'navBack' => 'sss ', | ||
155 | - // 'navHome' => 'sss ', | ||
156 | - 'navTitle' => '我要咨询' | ||
157 | - ) | ||
158 | - ); | 132 | + $this->setTitle('我要咨询'); |
133 | + $this->setNavHeader('我要咨询'); | ||
159 | 134 | ||
160 | - $this->_view->assign('title', '我要咨询'); | ||
161 | - //$this->_view->display('brand', compact('brands')); | ||
162 | // 渲染模板 | 135 | // 渲染模板 |
163 | - $this->_view->display('consultform', $data); | 136 | + $this->_view->display('consultform', array('consultform' => true)); |
164 | } | 137 | } |
165 | 138 | ||
166 | /** | 139 | /** |
@@ -173,10 +146,10 @@ class DetailController extends AbstractAction | @@ -173,10 +146,10 @@ class DetailController extends AbstractAction | ||
173 | { | 146 | { |
174 | $result = array(); | 147 | $result = array(); |
175 | 148 | ||
176 | - //if ($this->isAjax()) { | ||
177 | - $productSkn = $this->get('productSkn', 50000058); | ||
178 | - $result = \Product\DetailModel::getPreference($productSkn); var_dump($result); | ||
179 | - //} | 149 | + if ($this->isAjax()) { |
150 | + $productSkn = $this->get('productSkn'); // 50000058 | ||
151 | + $result = \Product\DetailModel::getPreference($productSkn); | ||
152 | + } | ||
180 | 153 | ||
181 | if (empty($result)) { | 154 | if (empty($result)) { |
182 | echo ' '; | 155 | echo ' '; |
-
Please register or login to post a comment