Authored by Rock Zhang

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

@@ -29,11 +29,15 @@ class DetailData @@ -29,11 +29,15 @@ class DetailData
29 * @param int $uid 用户ID 29 * @param int $uid 用户ID
30 * @return array 30 * @return array
31 */ 31 */
32 - public static function baseInfo($productId, $uid) 32 + public static function baseInfo($productId, $uid, $productSkn = null)
33 { 33 {
34 $param = Yohobuy::param(); 34 $param = Yohobuy::param();
35 $param['method'] = 'h5.product.data'; 35 $param['method'] = 'h5.product.data';
36 - $param['productId'] = $productId; 36 + if ($productId !== null) {
  37 + $param['productId'] = $productId;
  38 + } elseif ($productSkn !== null) {
  39 + $param['product_skn'] = $productSkn;
  40 + }
37 $param['uid'] = $uid; 41 $param['uid'] = $uid;
38 $param['client_secret'] = Sign::getSign($param); 42 $param['client_secret'] = Sign::getSign($param);
39 43
@@ -546,8 +546,8 @@ class Helpers @@ -546,8 +546,8 @@ class Helpers
546 $arr[$key]['appearDate'] = $vo['expect_arrival_time']; 546 $arr[$key]['appearDate'] = $vo['expect_arrival_time'];
547 } 547 }
548 // 商品链接 548 // 商品链接
549 - if ($haveLink && isset($vo['product_id'])) {  
550 - $arr[$key]['link'] = self::url('/product/pro_' . $vo['product_id'] . '_' . $vo['goods_id'] . '/' . $vo['cn_alphabet'] . '.html'); 549 + if ($haveLink && isset($vo['product_skn'])) {
  550 + $arr[$key]['link'] = self::url('/product/show_' . $vo['product_skn'] . '.html');
551 } 551 }
552 // 累计购买数 552 // 累计购买数
553 $count += intval($vo['buy_number']); 553 $count += intval($vo['buy_number']);
@@ -18,9 +18,9 @@ var panelTmpl, @@ -18,9 +18,9 @@ var panelTmpl,
18 $chosePanel = $('#chose-panel'), 18 $chosePanel = $('#chose-panel'),
19 $num, 19 $num,
20 $chosed, 20 $chosed,
21 - re = /\d+/, 21 +
  22 + // re = /\d+/,
22 leftNum, 23 leftNum,
23 - $sizeList,  
24 confirming, 24 confirming,
25 hasChooseColor = false, 25 hasChooseColor = false,
26 hasChooseSize = false, 26 hasChooseSize = false,
@@ -98,7 +98,7 @@ function hide() { @@ -98,7 +98,7 @@ function hide() {
98 $('body').css('overflow', 'auto'); 98 $('body').css('overflow', 'auto');
99 } 99 }
100 100
101 -$('.yoho-page').on('touchstart', '.infos', function(e) { 101 +$('.yoho-page').on('touchstart', '.chose-panel', function(e) {
102 var $cur = $(e.target); 102 var $cur = $(e.target);
103 103
104 if ($cur.closest('.main').length > 0) { 104 if ($cur.closest('.main').length > 0) {
@@ -132,6 +132,7 @@ $('.color-list').on('touchstart', '.block', function(e) { @@ -132,6 +132,7 @@ $('.color-list').on('touchstart', '.block', function(e) {
132 132
133 //颜色原来已经是勾选时,要清空剩余件数的提示 133 //颜色原来已经是勾选时,要清空剩余件数的提示
134 $that.find('.num .left-num').html(''); 134 $that.find('.num .left-num').html('');
  135 + $('#left-num').val(0);
135 hasChooseColor = false; 136 hasChooseColor = false;
136 137
137 // 当前颜色不是选中状态,选中时 138 // 当前颜色不是选中状态,选中时
@@ -161,9 +162,11 @@ $('.color-list').on('touchstart', '.block', function(e) { @@ -161,9 +162,11 @@ $('.color-list').on('touchstart', '.block', function(e) {
161 //如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式 162 //如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
162 if (curGoodNum > 0) { 163 if (curGoodNum > 0) {
163 $that.find('.num .left-num').html('剩余' + curGoodNum + '件'); 164 $that.find('.num .left-num').html('剩余' + curGoodNum + '件');
  165 + $('#left-num').val(curGoodNum);
164 } else { 166 } else {
165 $(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock'); 167 $(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock');
166 $that.find('.num .left-num').html(''); 168 $that.find('.num .left-num').html('');
  169 + $('#left-num').val(0);
167 } 170 }
168 } 171 }
169 } 172 }
@@ -250,7 +253,6 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -250,7 +253,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
250 $that = $(e.target).closest('.chose-items'), 253 $that = $(e.target).closest('.chose-items'),
251 index, 254 index,
252 $colorChosed, 255 $colorChosed,
253 - selectedColorindex,  
254 curGoodNum; 256 curGoodNum;
255 257
256 var $siblingBlock = $this.closest('.block-list').siblings(':first'); 258 var $siblingBlock = $this.closest('.block-list').siblings(':first');
@@ -259,7 +261,6 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -259,7 +261,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
259 index = $this.index(); 261 index = $this.index();
260 262
261 $colorChosed = $siblingBlock.find('.chosed'); 263 $colorChosed = $siblingBlock.find('.chosed');
262 - selectedColorindex = $colorChosed.index();  
263 $curSizeRow = $sizeRowList.eq(index); 264 $curSizeRow = $sizeRowList.eq(index);
264 265
265 // 当前尺码已经是选中状态,再点击时 266 // 当前尺码已经是选中状态,再点击时
@@ -267,6 +268,7 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -267,6 +268,7 @@ $('.size-list').on('touchstart', '.block', function(e) {
267 268
268 //尺码原来已经是勾选时,要清空剩余件数的提示 269 //尺码原来已经是勾选时,要清空剩余件数的提示
269 $that.find('.num .left-num').html(''); 270 $that.find('.num .left-num').html('');
  271 + $('#left-num').val(0);
270 hasChooseSize = false; 272 hasChooseSize = false;
271 273
272 // 去掉已经选中颜色的 数量为0的样式 274 // 去掉已经选中颜色的 数量为0的样式
@@ -286,11 +288,13 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -286,11 +288,13 @@ $('.size-list').on('touchstart', '.block', function(e) {
286 } 288 }
287 289
288 // 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数 290 // 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数
289 - if (curGoodNum > 0) { 291 + if (curGoodNum > 0 && hasChooseColor) {
290 $that.find('.num .left-num').html('剩余' + curGoodNum + '件'); 292 $that.find('.num .left-num').html('剩余' + curGoodNum + '件');
  293 + $('#left-num').val(curGoodNum);
291 } else { 294 } else {
292 $colorChosed.removeClass('zero-stock').addClass('zero-stock'); 295 $colorChosed.removeClass('zero-stock').addClass('zero-stock');
293 $that.find('.num .left-num').html(''); 296 $that.find('.num .left-num').html('');
  297 + $('#left-num').val(0);
294 } 298 }
295 } 299 }
296 300
@@ -375,8 +379,9 @@ $('.size-list').on('touchstart', '.block', function(e) { @@ -375,8 +379,9 @@ $('.size-list').on('touchstart', '.block', function(e) {
375 }); 379 });
376 380
377 $('.btn-minus').on('touchstart', function() { 381 $('.btn-minus').on('touchstart', function() {
378 - var num = $num.val(),  
379 - leftNum = re.exec($('.num .left-num').html()); 382 + var num = $num.val();
  383 +
  384 + leftNum = $('#left-num').val();
380 385
381 if (!checkColorSizeNum()) { 386 if (!checkColorSizeNum()) {
382 return; 387 return;
@@ -392,12 +397,14 @@ $('.btn-minus').on('touchstart', function() { @@ -392,12 +397,14 @@ $('.btn-minus').on('touchstart', function() {
392 $('.btn-plus').on('touchstart', function() { 397 $('.btn-plus').on('touchstart', function() {
393 var num = $num.val(); 398 var num = $num.val();
394 399
  400 + leftNum = $('#left-num').val();
  401 +
395 if (!checkColorSizeNum()) { 402 if (!checkColorSizeNum()) {
396 return; 403 return;
397 } 404 }
398 405
399 - leftNum = re.exec($('.num .left-num').html());  
400 - if (num - 0 === leftNum - 0 || 0 === leftNum - 0) { 406 +
  407 + if (num - 0 === leftNum || 0 === leftNum) {
401 return; 408 return;
402 } 409 }
403 410
@@ -405,7 +412,7 @@ $('.btn-plus').on('touchstart', function() { @@ -405,7 +412,7 @@ $('.btn-plus').on('touchstart', function() {
405 $num.val(num + 1); 412 $num.val(num + 1);
406 }); 413 });
407 414
408 -$('#chose-btn-sure').on('touchend', function() { 415 +$('#chose-btn-sure').on('touchstart', function() {
409 416
410 var productSku, 417 var productSku,
411 buyNumber = $('#good-num').val() - 0, 418 buyNumber = $('#good-num').val() - 0,
@@ -419,7 +426,11 @@ $('#chose-btn-sure').on('touchend', function() { @@ -419,7 +426,11 @@ $('#chose-btn-sure').on('touchend', function() {
419 return; 426 return;
420 } 427 }
421 428
422 - leftNum = re.exec($('.num .left-num').html()); 429 + if ($('#chose-btn-sure').html() === '已售罄') {
  430 + return;
  431 + }
  432 +
  433 + leftNum = $('#left-num').val();
423 434
424 if (num > leftNum) { 435 if (num > leftNum) {
425 tip.show('您选择的数量超过了最大库存量~'); 436 tip.show('您选择的数量超过了最大库存量~');
@@ -429,7 +440,7 @@ $('#chose-btn-sure').on('touchend', function() { @@ -429,7 +440,7 @@ $('#chose-btn-sure').on('touchend', function() {
429 $chosed = $('.block-list>ul>li.chosed'); 440 $chosed = $('.block-list>ul>li.chosed');
430 441
431 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) { 442 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
432 - productSku = $sizeList.closest('.chosed').data('skuid'); 443 + productSku = $curSizeBlock.data('skuid');
433 promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id'); 444 promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
434 if (confirming) { 445 if (confirming) {
435 return false; 446 return false;
@@ -116,11 +116,26 @@ @@ -116,11 +116,26 @@
116 color: #8f8f8f; 116 color: #8f8f8f;
117 } 117 }
118 } 118 }
119 -  
120 - .price-compute { 119 + .activity{
121 padding: 20rem / $pxConvertRem; 120 padding: 20rem / $pxConvertRem;
122 - border-bottom: 1px solid #e0e0e0;  
123 font-size: 26rem / $pxConvertRem; 121 font-size: 26rem / $pxConvertRem;
  122 + h1{
  123 + font-size: 32rem / $pxConvertRem;
  124 + }
  125 + li:before {
  126 + content: "";
  127 + display: inline-block;
  128 + width: 4px;
  129 + height: 4px;
  130 + background-color: #000;
  131 + border-radius: 50%;
  132 + margin-right: 8rem / $pxConvertRem;
  133 + }
  134 + }
  135 + .price-compute {
  136 + padding: 20rem / $pxConvertRem;
  137 + border-top: 1px solid #e0e0e0;
  138 + font-size: 28rem / $pxConvertRem;
124 139
125 .title { 140 .title {
126 display: inline-block; 141 display: inline-block;
@@ -33,18 +33,21 @@ @@ -33,18 +33,21 @@
33 {{/if}} 33 {{/if}}
34 </ul> 34 </ul>
35 {{/if}} 35 {{/if}}
36 - 36 +<div class="activity">
  37 + <h1>以参与活动</h1>
  38 + <ul>
  39 + {{# promotionInfo}}
  40 + <li>{{name}}</li>
  41 + {{/ promotionInfo}}
  42 + </ul>
  43 +</div>
37 <div class="price-compute"> 44 <div class="price-compute">
38 - <p class="sum-price">  
39 - <span class="title">总价</span>  
40 - <span id="good-totalprice">¥{{price}}</span> 45 + <p>
  46 + <span>总价(¥{{price}})<i>-</i></span>
  47 + <span>活动价(¥{{activityPrice}})</span>
41 </p> 48 </p>
42 - <p class="activity-price">  
43 - <span class="title">  
44 - 活动价  
45 - <i class="minus">-</i>  
46 - </span>  
47 - <span id="good-activityPrice">¥{{activityPrice}}</span> 49 + <p>
  50 + <span><i>=</i>商品总计金额 (¥{{sumPrice}})</span>
48 </p> 51 </p>
49 </div> 52 </div>
50 53
@@ -20,265 +20,270 @@ class DetailModel @@ -20,265 +20,270 @@ class DetailModel
20 /** 20 /**
21 * 商品基本信息 21 * 商品基本信息
22 * 22 *
23 - * @param int $productId 商品ID 23 + * @param int $productId 商品ID SKN 和 ID 只需要传一个
24 * @param int $goodsId 某个颜色的商品 24 * @param int $goodsId 某个颜色的商品
25 * @param int $uid 当前登录用户ID, 未登录为0 25 * @param int $uid 当前登录用户ID, 未登录为0
  26 + * @param int $productSkn SKN 和 ID 只需要传一个
26 * @return array 27 * @return array
27 */ 28 */
28 - public static function getBaseInfo($productId, $goodsId, $uid, $vipLevel) 29 + public static function getBaseInfo($productId, $goodsId, $uid, $vipLevel, $productSkn = null)
29 { 30 {
30 $result = array(); 31 $result = array();
31 32
  33 + $baseInfo = array();
  34 + // 通过ID获取
32 if (is_numeric($productId) && is_numeric($goodsId)) { 35 if (is_numeric($productId) && is_numeric($goodsId)) {
33 - // 调用服务  
34 $baseInfo = DetailData::baseInfo($productId, $uid); 36 $baseInfo = DetailData::baseInfo($productId, $uid);
  37 + }
  38 + // 通过SKN获取
  39 + elseif (is_numeric($productSkn)) {
  40 + $baseInfo = DetailData::baseInfo(null, $uid, $productSkn);
  41 + }
  42 +
  43 + // 商品名称
  44 + if (empty($baseInfo['productName'])) {
  45 + return $result;
  46 + }
  47 + $result['goodsName'] = $baseInfo['productName'];
35 48
36 - // 商品名称  
37 - if (empty($baseInfo['productName'])) {  
38 - return $result;  
39 - }  
40 -  
41 - $result['goodsName'] = $baseInfo['productName'];  
42 -  
43 - // 商品促销短语  
44 - if (!empty($baseInfo['salesPhrase'])) {  
45 - $result['goodsSubtitle'] = $baseInfo['salesPhrase'];  
46 - } 49 + // 商品促销短语
  50 + if (!empty($baseInfo['salesPhrase'])) {
  51 + $result['goodsSubtitle'] = $baseInfo['salesPhrase'];
  52 + }
47 53
48 - // 商品标签  
49 - if (!empty($baseInfo['productTagBoList'])) {  
50 - foreach ($baseInfo['productTagBoList'] as $value) {  
51 - switch ($value['tagLabel']) {  
52 - case 'is_soon_sold_out': // 即将售磬  
53 - $result['tags']['is_soon_sold_out'] = true;  
54 - break;  
55 - case 'is_new': // 新品NEW  
56 - $result['tags']['is_new'] = true;  
57 - break;  
58 - case 'is_discount': // SALE  
59 - $result['tags']['is_discount'] = true;  
60 - break;  
61 - case 'is_limited': // 限量  
62 - $result['tags']['is_limited'] = true;  
63 - break;  
64 - case 'is_yohood': // YOHOOD  
65 - $result['tags']['is_yohood'] = true;  
66 - break;  
67 - case 'is_advance': // 再到着  
68 - $result['tags']['is_advance'] = true;  
69 - break;  
70 - } 54 + // 商品标签
  55 + if (!empty($baseInfo['productTagBoList'])) {
  56 + foreach ($baseInfo['productTagBoList'] as $value) {
  57 + switch ($value['tagLabel']) {
  58 + case 'is_soon_sold_out': // 即将售磬
  59 + $result['tags']['is_soon_sold_out'] = true;
  60 + break;
  61 + case 'is_new': // 新品NEW
  62 + $result['tags']['is_new'] = true;
  63 + break;
  64 + case 'is_discount': // SALE
  65 + $result['tags']['is_discount'] = true;
  66 + break;
  67 + case 'is_limited': // 限量
  68 + $result['tags']['is_limited'] = true;
  69 + break;
  70 + case 'is_yohood': // YOHOOD
  71 + $result['tags']['is_yohood'] = true;
  72 + break;
  73 + case 'is_advance': // 再到着
  74 + $result['tags']['is_advance'] = true;
  75 + break;
71 } 76 }
72 } 77 }
  78 + }
73 79
74 - // 商品价格  
75 - if (isset($baseInfo['productPriceBo'])) {  
76 - $result['goodsPrice'] = array();  
77 - $result['goodsPrice']['currentPrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];  
78 - if ($baseInfo['productPriceBo']['formatMarketPrice'] !== $baseInfo['productPriceBo']['formatSalesPrice']) {  
79 - $result['goodsPrice']['previousPrice'] = $baseInfo['productPriceBo']['formatMarketPrice'];  
80 - } 80 + // 商品价格
  81 + if (isset($baseInfo['productPriceBo'])) {
  82 + $result['goodsPrice'] = array();
  83 + $result['goodsPrice']['currentPrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];
  84 + if ($baseInfo['productPriceBo']['formatMarketPrice'] !== $baseInfo['productPriceBo']['formatSalesPrice']) {
  85 + $result['goodsPrice']['previousPrice'] = $baseInfo['productPriceBo']['formatMarketPrice'];
81 } 86 }
82 - // VIP商品价格  
83 - if (isset($baseInfo['productPriceBo']['vipPrices'])) {  
84 - $build = array();  
85 - foreach ($baseInfo['productPriceBo']['vipPrices'] as $value) {  
86 - $build['level'] = $value['vipLevel'];  
87 - $build['text'] = $value['vipPrice'];  
88 - $build['currentLevel'] = ($value['vipLevel'] == $vipLevel) ? true : false;  
89 - $result['vipLevel']['list'][] = $build;  
90 - } 87 + }
  88 + // VIP商品价格
  89 + if (isset($baseInfo['productPriceBo']['vipPrices'])) {
  90 + $build = array();
  91 + foreach ($baseInfo['productPriceBo']['vipPrices'] as $value) {
  92 + $build['level'] = $value['vipLevel'];
  93 + $build['text'] = $value['vipPrice'];
  94 + $build['currentLevel'] = ($value['vipLevel'] == $vipLevel) ? true : false;
  95 + $result['vipLevel']['list'][] = $build;
91 } 96 }
  97 + }
92 98
93 - // 上市期  
94 - if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {  
95 - $result['periodOfMarket'] = $baseInfo['expectArrivalTime'] . '月';  
96 - } 99 + // 上市期
  100 + if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {
  101 + $result['periodOfMarket'] = $baseInfo['expectArrivalTime'] . '月';
  102 + }
97 103
98 - // 促销信息  
99 - if (isset($baseInfo['promotionBoList'])) {  
100 - $build = array();  
101 - foreach ($baseInfo['promotionBoList'] as $value) {  
102 - $build['text'] = '【' . $value['promotionType'] . '】' . $value['promotionTitle'];  
103 - $result['goodsDiscount']['list'][] = $build;  
104 - } 104 + // 促销信息
  105 + if (isset($baseInfo['promotionBoList'])) {
  106 + $build = array();
  107 + foreach ($baseInfo['promotionBoList'] as $value) {
  108 + $build['text'] = '【' . $value['promotionType'] . '】' . $value['promotionTitle'];
  109 + $result['goodsDiscount']['list'][] = $build;
105 } 110 }
  111 + }
106 112
107 - $result['feedbacks'] = array();  
108 -  
109 - // 商品咨询  
110 - $result['feedbacks']['consultsNum'] = 0;  
111 - if (!empty($baseInfo['consultBoWrapper'])) {  
112 - $result['feedbacks']['consultsNum'] = $baseInfo['consultBoWrapper']['consultTotal'];  
113 - $result['feedbacks']['consults'] = array();  
114 - $build = array();  
115 - foreach ($baseInfo['consultBoWrapper']['consultBoList'] as $value) {  
116 - $build['question'] = $value['ask'];  
117 - $build['time'] = $value['askTime'];  
118 - $build['answer'] = $value['answer'];  
119 - $result['feedbacks']['consults'][] = $build;  
120 - }  
121 - $result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $result['feedbacks']['consultsNum']));  
122 - }  
123 - // 暂无咨询  
124 - else {  
125 - $result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consultform', array('product_id' => $productId)); 113 + $result['feedbacks'] = array();
  114 +
  115 + // 商品咨询
  116 + $result['feedbacks']['consultsNum'] = 0;
  117 + if (!empty($baseInfo['consultBoWrapper'])) {
  118 + $result['feedbacks']['consultsNum'] = $baseInfo['consultBoWrapper']['consultTotal'];
  119 + $result['feedbacks']['consults'] = array();
  120 + $build = array();
  121 + foreach ($baseInfo['consultBoWrapper']['consultBoList'] as $value) {
  122 + $build['question'] = $value['ask'];
  123 + $build['time'] = $value['askTime'];
  124 + $build['answer'] = $value['answer'];
  125 + $result['feedbacks']['consults'][] = $build;
126 } 126 }
  127 + $result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $result['feedbacks']['consultsNum']));
  128 + }
  129 + // 暂无咨询
  130 + else {
  131 + $result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consultform', array('product_id' => $productId));
  132 + }
127 133
128 - // 商品评价  
129 - $result['feedbacks']['commentsNum'] = 0;  
130 - if (!empty($baseInfo['commentBoWrapper'])) {  
131 - $result['feedbacks']['commentsNum'] = $baseInfo['commentBoWrapper']['commentTotal'];  
132 - $result['feedbacks']['comments'] = array();  
133 - $build = array();  
134 - foreach ($baseInfo['commentBoWrapper']['commentBoList'] as $value) {  
135 - $build['userName'] = $value['nickName'];  
136 - $build['desc'] = $value['colorName'] . '/' . $value['sizeName'];  
137 - $build['content'] = isset($value['content']) ? $value['content'] : '';  
138 - $build['time'] = $value['createTime'];  
139 - $result['feedbacks']['comments'][] = $build;  
140 - }  
141 - $result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum'])); 134 + // 商品评价
  135 + $result['feedbacks']['commentsNum'] = 0;
  136 + if (!empty($baseInfo['commentBoWrapper'])) {
  137 + $result['feedbacks']['commentsNum'] = $baseInfo['commentBoWrapper']['commentTotal'];
  138 + $result['feedbacks']['comments'] = array();
  139 + $build = array();
  140 + foreach ($baseInfo['commentBoWrapper']['commentBoList'] as $value) {
  141 + $build['userName'] = $value['nickName'];
  142 + $build['desc'] = $value['colorName'] . '/' . $value['sizeName'];
  143 + $build['content'] = isset($value['content']) ? $value['content'] : '';
  144 + $build['time'] = $value['createTime'];
  145 + $result['feedbacks']['comments'][] = $build;
142 } 146 }
  147 + $result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
  148 + }
143 149
144 - // 品牌信息  
145 - if (!empty($baseInfo['brand'])) {  
146 - $result['enterStore'] = array(  
147 - 'img' => Helpers::getImageUrl($baseInfo['brand']['brandIco'], 47, 47),  
148 - 'storeName' => $baseInfo['brand']['brandName'],  
149 - 'url' => Helpers::url('', array(), $baseInfo['brand']['brandDomain'])  
150 - );  
151 - // 为你优选的链接  
152 - $result['preferenceUrl'] = Helpers::url('/product/detail/preference', array('productSkn' => $baseInfo['erpProductId'], 'brandId' => $baseInfo['brand']['id']), '');  
153 - } 150 + // 品牌信息
  151 + if (!empty($baseInfo['brand'])) {
  152 + $result['enterStore'] = array(
  153 + 'img' => Helpers::getImageUrl($baseInfo['brand']['brandIco'], 47, 47),
  154 + 'storeName' => $baseInfo['brand']['brandName'],
  155 + 'url' => Helpers::url('', array(), $baseInfo['brand']['brandDomain'])
  156 + );
  157 + // 为你优选的链接
  158 + $result['preferenceUrl'] = Helpers::url('/product/detail/preference', array('productSkn' => $baseInfo['erpProductId'], 'brandId' => $baseInfo['brand']['id']), '');
  159 + }
154 160
155 - // 商品信息  
156 - if (!empty($baseInfo['goodsList'])) {  
157 - $colorGroup = array();  
158 - $sizeGroup = array();  
159 - $goodsGroup = array();  
160 - $sizeList = array();  
161 - $thumbImageList = array();  
162 - $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔  
163 - $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔 161 + // 商品信息
  162 + if (!empty($baseInfo['goodsList'])) {
  163 + $colorGroup = array();
  164 + $sizeGroup = array();
  165 + $goodsGroup = array();
  166 + $sizeList = array();
  167 + $thumbImageList = array();
  168 + $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
  169 + $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔
  170 + $colorStorageNum = 0;
  171 + $totalStorageNum = 0; // 总库存数
  172 + foreach ($baseInfo['goodsList'] as $value) {
164 $colorStorageNum = 0; 173 $colorStorageNum = 0;
165 - $totalStorageNum = 0; // 总库存数  
166 - foreach ($baseInfo['goodsList'] as $value) {  
167 - $colorStorageNum = 0;  
168 - $sizeStorageStr = '';  
169 -  
170 - // 商品分组  
171 - if (isset($value['goodsImagesList'])) {  
172 - foreach ($value['goodsImagesList'] as $goods) {  
173 - $goodsGroup[] = array(  
174 - 'goodsId' => $goods['goodsId'],  
175 - 'img' => $goods['imageUrl'],  
176 - );  
177 - }  
178 - }  
179 -  
180 - // 商品的尺码列表  
181 - if (isset($value['goodsSizeBoList'])) {  
182 - foreach ($value['goodsSizeBoList'] as $size) {  
183 - $sizeList[$value['colorId']][] = array(  
184 - 'id' => $size['id'],  
185 - 'skuId' => $size['goodsSizeSkuId'],  
186 - 'goodsId' => $size['goodsId'],  
187 - 'colorId' => $value['colorId'],  
188 - 'name' => $size['sizeName'],  
189 - 'sizeNum' => $size['goodsSizeStorageNum'],  
190 - );  
191 - $colorStorageNum += intval($size['goodsSizeStorageNum']);  
192 - $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';  
193 - $colorStorageGroup[$size['sizeName']][$value['colorName']] = $size['goodsSizeStorageNum'];  
194 - }  
195 -  
196 - // 颜色分组  
197 - $colorGroup[] = array(  
198 - 'id' => $value['colorId'],  
199 - 'skcId' => $value['productSkc'],  
200 - 'name' => $value['colorName'],  
201 - 'goodsName' => $value['goodsName'],  
202 - 'colorNum' => $colorStorageNum,  
203 - 'sizeNumStr' => rtrim($sizeStorageStr, '/'), 174 + $sizeStorageStr = '';
  175 +
  176 + // 商品分组
  177 + if (isset($value['goodsImagesList'])) {
  178 + foreach ($value['goodsImagesList'] as $goods) {
  179 + $goodsGroup[] = array(
  180 + 'goodsId' => $goods['goodsId'],
  181 + 'img' => $goods['imageUrl'],
204 ); 182 );
205 } 183 }
  184 + }
206 185
207 - // 缩略图  
208 - $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60));  
209 -  
210 - // 添加尺码对应的各个颜色的库存量  
211 - foreach ($sizeList as $colorId => $sizeArr) {  
212 - foreach ($sizeArr as $key => $value) {  
213 - $sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[$value['name']]));  
214 - } 186 + // 商品的尺码列表
  187 + if (isset($value['goodsSizeBoList'])) {
  188 + foreach ($value['goodsSizeBoList'] as $size) {
  189 + $sizeList[$value['colorId']][] = array(
  190 + 'id' => $size['id'],
  191 + 'skuId' => $size['goodsSizeSkuId'],
  192 + 'goodsId' => $size['goodsId'],
  193 + 'colorId' => $value['colorId'],
  194 + 'name' => $size['sizeName'],
  195 + 'sizeNum' => $size['goodsSizeStorageNum'],
  196 + );
  197 + $colorStorageNum += intval($size['goodsSizeStorageNum']);
  198 + $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
  199 + $colorStorageGroup[$size['sizeName']][$value['colorId']] = $size['goodsSizeStorageNum'];
215 } 200 }
216 201
217 - // 商品库存总数  
218 - $totalStorageNum += $colorStorageNum; 202 + // 颜色分组
  203 + $colorGroup[] = array(
  204 + 'id' => $value['colorId'],
  205 + 'skcId' => $value['productSkc'],
  206 + 'name' => $value['colorName'],
  207 + 'goodsName' => $value['goodsName'],
  208 + 'colorNum' => $colorStorageNum,
  209 + 'sizeNumStr' => rtrim($sizeStorageStr, '/'),
  210 + );
219 } 211 }
220 212
221 - // 格式化尺码对应的各个颜色分组  
222 - foreach ($colorGroup as $value) {  
223 - $sizeGroup[]['size'] = $sizeList[ $value['id'] ];  
224 - } 213 + // 缩略图
  214 + $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60));
225 215
226 - // 商品图: 多个  
227 - if (isset($goodsGroup[1])) {  
228 - foreach ($goodsGroup as $value) {  
229 - $result['bannerTop']['list'][] = array(  
230 - 'img' => Helpers::getImageUrl($value['img'], 450, 600)  
231 - ); 216 + // 添加尺码对应的各个颜色的库存量
  217 + foreach ($sizeList as $colorId => $sizeArr) {
  218 + foreach ($sizeArr as $key => $value) {
  219 + $sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[$value['name']]));
232 } 220 }
233 } 221 }
234 - // 商品图: 单个  
235 - elseif (isset($goodsGroup[0])) {  
236 - $result['bannerTop'] = array(  
237 - 'img' => Helpers::getImageUrl($goodsGroup[0]['img'], 450, 600)  
238 - );  
239 - } 222 +
  223 + // 商品库存总数
  224 + $totalStorageNum += $colorStorageNum;
240 } 225 }
241 226
242 - // 悬浮的购物车信息  
243 - $result['cartInfo'] = array(  
244 - 'cartUrl' => Helpers::url('/cart/index/index', null), // 购物车链接  
245 - 'numInCart' => 0,  
246 - 'goodsInstore' => $baseInfo['storage'], // 库存量  
247 - );  
248 - $soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0);  
249 - $notForSale = $baseInfo['attribute'] == 2;  
250 - // 显示加入购物车链接  
251 - if (!$soldOut && !$notForSale) {  
252 - $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');  
253 - $result['cartInfo']['productId'] = $productId;  
254 - $result['cartInfo']['thumbs'] = $thumbImageList;  
255 - $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';  
256 - $result['cartInfo']['price'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';  
257 - $result['cartInfo']['salePrice'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';  
258 - $result['cartInfo']['totalNum'] = $totalStorageNum;  
259 - $result['cartInfo']['colors'] = $colorGroup;  
260 - $result['cartInfo']['sizes'] = $sizeGroup; 227 + // 格式化尺码对应的各个颜色分组
  228 + foreach ($colorGroup as $value) {
  229 + $sizeGroup[]['size'] = $sizeList[ $value['id'] ];
261 } 230 }
262 - // 非卖品  
263 - elseif ($notForSale) {  
264 - $result['cartInfo']['notForSale'] = true; 231 +
  232 + // 商品图: 多个
  233 + if (isset($goodsGroup[1])) {
  234 + foreach ($goodsGroup as $value) {
  235 + $result['bannerTop']['list'][] = array(
  236 + 'img' => Helpers::getImageUrl($value['img'], 450, 600)
  237 + );
  238 + }
265 } 239 }
266 - // 已售磬  
267 - elseif ($soldOut) {  
268 - $result['cartInfo']['soldOut'] = true; 240 + // 商品图: 单个
  241 + elseif (isset($goodsGroup[0])) {
  242 + $result['bannerTop'] = array(
  243 + 'img' => Helpers::getImageUrl($goodsGroup[0]['img'], 450, 600)
  244 + );
269 } 245 }
  246 + }
270 247
271 - // 是否收藏  
272 - $result['isCollect'] = false;  
273 - if (isset($baseInfo['isCollect']) && $baseInfo['isCollect'] === 'Y') {  
274 - $result['isCollect'] = true;  
275 - } 248 + // 悬浮的购物车信息
  249 + $result['cartInfo'] = array(
  250 + 'cartUrl' => Helpers::url('/cart/index/index', null), // 购物车链接
  251 + 'numInCart' => 0,
  252 + 'goodsInstore' => $baseInfo['storage'], // 库存量
  253 + );
  254 + $soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0);
  255 + $notForSale = $baseInfo['attribute'] == 2;
  256 + // 显示加入购物车链接
  257 + if (!$soldOut && !$notForSale) {
  258 + $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
  259 + $result['cartInfo']['productId'] = $productId;
  260 + $result['cartInfo']['thumbs'] = $thumbImageList;
  261 + $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
  262 + $result['cartInfo']['price'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';
  263 + $result['cartInfo']['salePrice'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';
  264 + $result['cartInfo']['totalNum'] = $totalStorageNum;
  265 + $result['cartInfo']['colors'] = $colorGroup;
  266 + $result['cartInfo']['sizes'] = $sizeGroup;
  267 + }
  268 + // 非卖品
  269 + elseif ($notForSale) {
  270 + $result['cartInfo']['notForSale'] = true;
  271 + }
  272 + // 已售磬
  273 + elseif ($soldOut) {
  274 + $result['cartInfo']['soldOut'] = true;
  275 + }
276 276
277 - // 底部简介的URL链接  
278 - $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html', null, '');  
279 - $result['id'] = $productId; 277 + // 是否收藏
  278 + $result['isCollect'] = false;
  279 + if (isset($baseInfo['isCollect']) && $baseInfo['isCollect'] === 'Y') {
  280 + $result['isCollect'] = true;
280 } 281 }
281 282
  283 + // 底部简介的URL链接
  284 + $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html', null, '');
  285 + $result['id'] = $productId;
  286 +
282 return $result; 287 return $result;
283 } 288 }
284 289
@@ -47,6 +47,39 @@ class DetailController extends AbstractAction @@ -47,6 +47,39 @@ class DetailController extends AbstractAction
47 // 渲染模板 47 // 渲染模板
48 $this->_view->display('index', $data); 48 $this->_view->display('index', $data);
49 } 49 }
  50 +
  51 + /**
  52 + * 商品详情 (SKN)
  53 + *
  54 + * @param int productSkn
  55 + */
  56 + public function showAction()
  57 + {
  58 + $productSkn = $this->param('productSkn');
  59 + if (!is_numeric($productSkn)) {
  60 + $this->error();
  61 + }
  62 + $uid = $this->getUid();
  63 +
  64 + $vipLevel = 0;
  65 + if (isset($this->_vip)) {
  66 + $vipLevel = Helpers::getVipLevel($this->_vip);
  67 + }
  68 +
  69 + $data = \Product\DetailModel::getBaseInfo(null, null, $uid, $vipLevel, $productSkn);
  70 + if (array() === $data) {
  71 + $this->error();
  72 + }
  73 + $data['goodsDetailPage'] = true;
  74 + $data['pageFooter'] = true;
  75 +
  76 + if (isset($data['goodsName'])) {
  77 + $this->setTitle($data['goodsName']);
  78 + }
  79 + $this->setNavHeader('商品详情');
  80 + // 渲染模板
  81 + $this->_view->display('index', $data);
  82 + }
50 83
51 /** 84 /**
52 * 尺码描述信息 85 * 尺码描述信息
@@ -147,6 +147,13 @@ routes.productintro.route.controller = Detail @@ -147,6 +147,13 @@ routes.productintro.route.controller = Detail
147 routes.productintro.route.action = Intro 147 routes.productintro.route.action = Intro
148 routes.productintro.map.1 = productSkn 148 routes.productintro.map.1 = productSkn
149 149
  150 +routes.productskn.type = "regex"
  151 +routes.productskn.match = "#/product/show_([0-9]+).html#"
  152 +routes.productskn.route.module = Product
  153 +routes.productskn.route.controller = Detail
  154 +routes.productskn.route.action = Show
  155 +routes.productskn.map.1 = productSkn
  156 +
150 ; 订单相关 157 ; 订单相关
151 routes.cart.type = "rewrite" 158 routes.cart.type = "rewrite"
152 routes.cart.match = "/home/order/detail$" 159 routes.cart.match = "/home/order/detail$"
@@ -20,3 +20,10 @@ routes.productintro.route.module = Product @@ -20,3 +20,10 @@ routes.productintro.route.module = Product
20 routes.productintro.route.controller = Detail 20 routes.productintro.route.controller = Detail
21 routes.productintro.route.action = Intro 21 routes.productintro.route.action = Intro
22 routes.productintro.map.1 = productSkn 22 routes.productintro.map.1 = productSkn
  23 +
  24 +routes.productskn.type = "regex"
  25 +routes.productskn.match = "#/product/show_([0-9]+).html#"
  26 +routes.productskn.route.module = Product
  27 +routes.productskn.route.controller = Detail
  28 +routes.productskn.route.action = Show
  29 +routes.productskn.map.1 = productSkn