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 + if ($productId !== null) {
36 $param['productId'] = $productId; 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,24 +20,30 @@ class DetailModel @@ -20,24 +20,30 @@ 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 + }
35 42
36 // 商品名称 43 // 商品名称
37 if (empty($baseInfo['productName'])) { 44 if (empty($baseInfo['productName'])) {
38 return $result; 45 return $result;
39 } 46 }
40 -  
41 $result['goodsName'] = $baseInfo['productName']; 47 $result['goodsName'] = $baseInfo['productName'];
42 48
43 // 商品促销短语 49 // 商品促销短语
@@ -190,7 +196,7 @@ class DetailModel @@ -190,7 +196,7 @@ class DetailModel
190 ); 196 );
191 $colorStorageNum += intval($size['goodsSizeStorageNum']); 197 $colorStorageNum += intval($size['goodsSizeStorageNum']);
192 $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/'; 198 $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
193 - $colorStorageGroup[$size['sizeName']][$value['colorName']] = $size['goodsSizeStorageNum']; 199 + $colorStorageGroup[$size['sizeName']][$value['colorId']] = $size['goodsSizeStorageNum'];
194 } 200 }
195 201
196 // 颜色分组 202 // 颜色分组
@@ -277,7 +283,6 @@ class DetailModel @@ -277,7 +283,6 @@ class DetailModel
277 // 底部简介的URL链接 283 // 底部简介的URL链接
278 $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html', null, ''); 284 $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html', null, '');
279 $result['id'] = $productId; 285 $result['id'] = $productId;
280 - }  
281 286
282 return $result; 287 return $result;
283 } 288 }
@@ -49,6 +49,39 @@ class DetailController extends AbstractAction @@ -49,6 +49,39 @@ class DetailController extends AbstractAction
49 } 49 }
50 50
51 /** 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 + }
  83 +
  84 + /**
52 * 尺码描述信息 85 * 尺码描述信息
53 */ 86 */
54 public function introAction() 87 public function introAction()
@@ -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