Authored by 毕凯

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

@@ -133,8 +133,10 @@ class DetailData @@ -133,8 +133,10 @@ class DetailData
133 133
134 /** 134 /**
135 * 为你优选的商品列表 135 * 为你优选的商品列表
136 - * 136 + *
137 * @param int $productSkn 商品SKN号 137 * @param int $productSkn 商品SKN号
  138 + * @param int $channel
  139 + * @param int $brandId
138 * @return array 140 * @return array
139 */ 141 */
140 public static function preference($productSkn, $channel, $brandId) 142 public static function preference($productSkn, $channel, $brandId)
@@ -220,4 +222,26 @@ class DetailData @@ -220,4 +222,26 @@ class DetailData
220 return Yohobuy::get(Yohobuy::API_URL, $param); 222 return Yohobuy::get(Yohobuy::API_URL, $param);
221 } 223 }
222 224
  225 + /**
  226 + * 获取限购商品详情
  227 + *
  228 + * @param int $uid 用户UID
  229 + * @param string $productCode 限购商品商品码
  230 + * @return mixed
  231 + */
  232 + public static function limitProductData($uid, $productCode)
  233 + {
  234 + $param = Yohobuy::param();
  235 + $param['method'] = 'app.limitProduct.limitProductDetail';
  236 + $param['limitProductCode'] = $productCode;
  237 +
  238 + if (!empty($uid)) {
  239 + $param['uid'] = $uid;
  240 + }
  241 +
  242 + $param['client_secret'] = Sign::getSign($param);
  243 +
  244 + return Yohobuy::get(Yohobuy::API_URL, $param);
  245 + }
  246 +
223 } 247 }
@@ -895,4 +895,21 @@ class Helpers @@ -895,4 +895,21 @@ class Helpers
895 } 895 }
896 return $area.'-'.$mobile; 896 return $area.'-'.$mobile;
897 } 897 }
  898 +
  899 + /**
  900 + * 按照数组中指定字段排序二维数组
  901 + *
  902 + * @param array &$array 需要排序的数组
  903 + * @param string $field 字段名称
  904 + * @param boolean $desc 时候降序排列,默认为false
  905 + */
  906 + public static function sortArrByField(&$array, $field, $desc = false)
  907 + {
  908 + $fieldArr = array();
  909 + foreach ($array as $k => $v) {
  910 + $fieldArr[$k] = isset($v[$field]) ? $v[$field] : '';
  911 + }
  912 + $sort = $desc == false ? SORT_ASC : SORT_DESC;
  913 + array_multisort($fieldArr, $sort, $array);
  914 + }
898 } 915 }
@@ -49,6 +49,16 @@ var limitProductCode, @@ -49,6 +49,16 @@ var limitProductCode,
49 // 限购商品的skn。只有限购商品时才会设置。 49 // 限购商品的skn。只有限购商品时才会设置。
50 skn; 50 skn;
51 51
  52 +//禁用数字编辑
  53 +function disableNumEdit() {
  54 + var $numBtn = $('.chose-panel').find('.num .btn>.iconfont');
  55 +
  56 + //添加disabled样式
  57 + $numBtn.hasClass('disabled') ? null : $numBtn.addClass('disabled');
  58 +
  59 + $yohoPage.off('touchstart', '.btn-minus');
  60 + $yohoPage.off('touchstart', '.btn-plus');
  61 +}
52 62
53 // 初始化购物车面板显示 63 // 初始化购物车面板显示
54 function init() { 64 function init() {
@@ -94,7 +104,8 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { @@ -94,7 +104,8 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) {
94 * @return {undefined} 104 * @return {undefined}
95 */ 105 */
96 function setLimitGoodModeWithSknId(code, sknId) { 106 function setLimitGoodModeWithSknId(code, sknId) {
97 - $('#chose-btn-sure').html('结算'); 107 + disableNumEdit();
  108 + $('#chose-btn-sure').html('立即购买');
98 limitProductCode = code; 109 limitProductCode = code;
99 skn = sknId; 110 skn = sknId;
100 } 111 }
@@ -127,16 +138,6 @@ function checkColorSizeNum() { @@ -127,16 +138,6 @@ function checkColorSizeNum() {
127 return true; 138 return true;
128 } 139 }
129 140
130 -//禁用数字编辑  
131 -function disableNumEdit() {  
132 - var $numBtn = $('.chose-panel').find('.num .btn>.iconfont');  
133 -  
134 - //添加disabled样式  
135 - $numBtn.hasClass('disabled') ? null : $numBtn.addClass('disabled');  
136 -  
137 - $yohoPage.off('touchstart', '.btn-minus');  
138 - $yohoPage.off('touchstart', '.btn-plus');  
139 -}  
140 141
141 142
142 function show(html, cb) { 143 function show(html, cb) {
@@ -172,7 +173,7 @@ function updateConformButtonClassAndText() { @@ -172,7 +173,7 @@ function updateConformButtonClassAndText() {
172 if (2 === $chosed.closest('.zero-stock').length) { 173 if (2 === $chosed.closest('.zero-stock').length) {
173 $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄'); 174 $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
174 } else if (limitProductCode) { 175 } else if (limitProductCode) {
175 - $('#chose-btn-sure').css('background-color', '#eb0313').html('结算'); 176 + $('#chose-btn-sure').css('background-color', '#eb0313').html('立即购买');
176 } else { 177 } else {
177 $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车'); 178 $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车');
178 } 179 }
@@ -473,8 +474,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -473,8 +474,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
473 } else if (limitProductCode) { 474 } else if (limitProductCode) {
474 475
475 // 当前面板选择的是限购商品 476 // 当前面板选择的是限购商品
476 - url = 'http://m.yohobuy.com/cart/index/orderEnsure?code=' + limitProductCode + '&&sku=' +  
477 - productSku + '&&skn=' + skn + '&&buy_num=' + buyNumber; 477 + url = $('#limitProductPay').val() + '?limitproductcode=' + limitProductCode + '&sku=' +
  478 + productSku + '&skn=' + skn + '&buy_number=' + buyNumber;
478 479
479 //打开结算页面,结束函数执行。 480 //打开结算页面,结束函数执行。
480 window.location.href = url; 481 window.location.href = url;
@@ -30,6 +30,26 @@ require('../common'); @@ -30,6 +30,26 @@ require('../common');
30 30
31 lazyLoad(); 31 lazyLoad();
32 32
  33 +function getQueryParam() {
  34 + var queryArray = location.search.substr(1).split('&'),
  35 + i,
  36 + subArr = [],
  37 + obj = {};
  38 +
  39 + for (i = 0; i < queryArray.length; i++) {
  40 + subArr = queryArray[i].split('=');
  41 + obj[subArr[0]] = subArr[1];
  42 + subArr = [];
  43 + }
  44 +
  45 + return obj;
  46 +}
  47 +
  48 +function isLimitGood() {
  49 + return getQueryParam().limitproductcode;
  50 +}
  51 +
  52 +
33 if (window.getUid() !== orderInfo('uid')) { 53 if (window.getUid() !== orderInfo('uid')) {
34 order.init(); 54 order.init();
35 window.location.reload(); 55 window.location.reload();
@@ -46,6 +66,18 @@ if (document.referrer && document.referrer.indexOf('/cart/index/index') !== -1) @@ -46,6 +66,18 @@ if (document.referrer && document.referrer.indexOf('/cart/index/index') !== -1)
46 orderInfo('couponName', null); 66 orderInfo('couponName', null);
47 } 67 }
48 68
  69 +isLimitGood() && (function() {
  70 + var a = [];
  71 +
  72 + var data = getQueryParam();
  73 +
  74 + data['type'] = 'limitcode';
  75 +
  76 + a.push(data);
  77 + orderInfo('skuList', JSON.stringify(a));
  78 + orderInfo('limitUrlSufix', location.search);
  79 +})();
  80 +
49 if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) { 81 if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) {
50 orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary'); 82 orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary');
51 } 83 }
@@ -102,7 +134,8 @@ function orderCompute() { @@ -102,7 +134,8 @@ function orderCompute() {
102 deliveryId: orderInfo('deliveryId'), 134 deliveryId: orderInfo('deliveryId'),
103 paymentTypeId: orderInfo('paymentTypeId'), 135 paymentTypeId: orderInfo('paymentTypeId'),
104 couponCode: orderInfo('couponCode'), 136 couponCode: orderInfo('couponCode'),
105 - yohoCoin: yohoCoin 137 + yohoCoin: yohoCoin,
  138 + skuList: isLimitGood() ? orderInfo('skuList') : undefined
106 } 139 }
107 }).then(function(res) { 140 }).then(function(res) {
108 var priceHtml; 141 var priceHtml;
@@ -177,7 +210,9 @@ function submitOrder() { @@ -177,7 +210,9 @@ function submitOrder() {
177 paymentTypeId: orderInfo('paymentTypeId'), 210 paymentTypeId: orderInfo('paymentTypeId'),
178 paymentType: orderInfo('paymentType'), //支付方式 211 paymentType: orderInfo('paymentType'), //支付方式
179 couponCode: orderInfo('couponCode'), 212 couponCode: orderInfo('couponCode'),
180 - yohoCoin: orderInfo('yohoCoin') 213 + yohoCoin: orderInfo('yohoCoin'),
  214 + skuList: isLimitGood() ? orderInfo('skuList') : undefined
  215 +
181 } 216 }
182 }).then(function(res) { 217 }).then(function(res) {
183 var url; 218 var url;
@@ -26,7 +26,7 @@ $('.address-item').on('touchend', function() { @@ -26,7 +26,7 @@ $('.address-item').on('touchend', function() {
26 orderInfo('addressId', addressId); 26 orderInfo('addressId', addressId);
27 orderInfo('address', address); 27 orderInfo('address', address);
28 28
29 - window.location.href = $this.data('href'); 29 + window.location.href = $this.data('href') + (orderInfo('limitUrlSufix') || '');
30 }).on('touchend', '.edit', function() { 30 }).on('touchend', '.edit', function() {
31 window.location.href = $(this).data('href'); 31 window.location.href = $(this).data('href');
32 return false; 32 return false;
@@ -68,7 +68,7 @@ $('#likeBtn').on('touchstart', function() { @@ -68,7 +68,7 @@ $('#likeBtn').on('touchstart', function() {
68 68
69 $('#addtoCart').on('touchstart', function() { 69 $('#addtoCart').on('touchstart', function() {
70 $('.cart-bar').hide(); 70 $('.cart-bar').hide();
71 - chosePanel.setLimitGoodModeWithSknId(productCode, skn); 71 + productCode && chosePanel.setLimitGoodModeWithSknId(productCode, skn);
72 chosePanel.show(); 72 chosePanel.show();
73 73
74 //统计代码:用于统计用户加入购物车的动作 74 //统计代码:用于统计用户加入购物车的动作
@@ -8,17 +8,15 @@ @@ -8,17 +8,15 @@
8 line-height: 2.2rem; 8 line-height: 2.2rem;
9 margin-bottom: 0.1rem; 9 margin-bottom: 0.1rem;
10 background-color: #fff; 10 background-color: #fff;
11 - padding: 0.2rem 0; 11 + padding: 0.2rem 0 0.2rem 0.5rem;
12 12
13 13
14 div { 14 div {
15 - width: 20%; 15 + width: 0%;
16 display: inline-block; 16 display: inline-block;
17 float: left; 17 float: left;
18 img { 18 img {
19 width: 1.5rem; 19 width: 1.5rem;
20 - border: 1px solid #ccc;  
21 - border-radius: 100%;  
22 position: relative; 20 position: relative;
23 top: 0.25rem; 21 top: 0.25rem;
24 } 22 }
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 line-height: 2.2rem; 8 line-height: 2.2rem;
9 margin-bottom: 0.1rem; 9 margin-bottom: 0.1rem;
10 background-color: #fff; 10 background-color: #fff;
11 - padding: 0.2rem 0; 11 + padding: 0.2rem 0 0.2rem 0.5rem;
12 12
13 13
14 div { 14 div {
@@ -63,6 +63,15 @@ @@ -63,6 +63,15 @@
63 63
64 .goodDesc { 64 .goodDesc {
65 margin-top: 1rem; 65 margin-top: 1rem;
  66 +
  67 + p {
  68 + font-size: 0.6rem;
  69 + line-height: 1rem;
  70 + }
  71 +
  72 + img {
  73 + margin: 0.3rem 0;
  74 + }
66 } 75 }
67 76
68 .bottom { 77 .bottom {
@@ -70,8 +79,6 @@ @@ -70,8 +79,6 @@
70 border-top: 1px solid #e6e6e6; 79 border-top: 1px solid #e6e6e6;
71 padding: 0.5rem 2rem 2rem 2rem; 80 padding: 0.5rem 2rem 2rem 2rem;
72 height: 3rem; 81 height: 3rem;
73 - position: absolute;  
74 - bottom: 0;  
75 width: 12rem; 82 width: 12rem;
76 margin: 0 auto; 83 margin: 0 auto;
77 84
@@ -299,7 +299,7 @@ $basicBtnC:#eb0313; @@ -299,7 +299,7 @@ $basicBtnC:#eb0313;
299 font-weight: bold; 299 font-weight: bold;
300 } 300 }
301 301
302 - .limit-sale:active { 302 + .limit-sale:not(.got-limit-sale):active {
303 background-color: #f0f0f0; 303 background-color: #f0f0f0;
304 } 304 }
305 305
@@ -510,6 +510,9 @@ $basicBtnC:#eb0313; @@ -510,6 +510,9 @@ $basicBtnC:#eb0313;
510 &.sold-out { 510 &.sold-out {
511 background-color: #f58189; 511 background-color: #f58189;
512 } 512 }
  513 + &.sold-out.limit {
  514 + background-color: #ccc;
  515 + }
513 } 516 }
514 .num-tag { 517 .num-tag {
515 display: block; 518 display: block;
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 line-height: 2.2rem; 8 line-height: 2.2rem;
9 margin-bottom: 0.1rem; 9 margin-bottom: 0.1rem;
10 background-color: #fff; 10 background-color: #fff;
11 - padding: 0.2rem 0; 11 + padding: 0.2rem 0 0.2rem 0.5rem;
12 12
13 13
14 div { 14 div {
@@ -63,6 +63,18 @@ @@ -63,6 +63,18 @@
63 63
64 .goodDesc { 64 .goodDesc {
65 margin-top: 1rem; 65 margin-top: 1rem;
  66 + padding: 0.5rem;
  67 + border-top: 1px solid #e6e6e6;
  68 + background-color: #fff;
  69 +
  70 + p {
  71 + font-size: 0.6rem;
  72 + line-height: 1rem;
  73 + }
  74 +
  75 + img {
  76 + margin: 0.3rem 0;
  77 + }
66 } 78 }
67 79
68 .bottom { 80 .bottom {
@@ -70,8 +82,6 @@ @@ -70,8 +82,6 @@
70 border-top: 1px solid #e6e6e6; 82 border-top: 1px solid #e6e6e6;
71 padding: 0.5rem 2rem 2rem 2rem; 83 padding: 0.5rem 2rem 2rem 2rem;
72 height: 3rem; 84 height: 3rem;
73 - position: absolute;  
74 - bottom: 0;  
75 width: 12rem; 85 width: 12rem;
76 margin: 0 auto; 86 margin: 0 auto;
77 87
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 <ul class="sale-invoice"> 43 <ul class="sale-invoice">
44 {{#if isOrdinaryCart}} 44 {{#if isOrdinaryCart}}
45 <li class="coupon"> 45 <li class="coupon">
46 - <a href="/cart/index/selectCoupon"> 46 + <a href="{{#if isLimit}}javascript:void(0);{{else}}/cart/index/selectCoupon{{/if}}">
47 <span class="title">优惠券</span> 47 <span class="title">优惠券</span>
48 {{# coupon}} 48 {{# coupon}}
49 <!--<span class="coupon-count"> 49 <!--<span class="coupon-count">
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 </span> 57 </span>
58 {{^}} 58 {{^}}
59 <span class="not-used coupon-use"> 59 <span class="not-used coupon-use">
60 - 未使用 60 + {{#if isLimit}}该商品不可使用优惠券{{else}}未使用{{/if}}
61 <i class="iconfont">&#xe614;</i> 61 <i class="iconfont">&#xe614;</i>
62 </span> 62 </span>
63 {{/if}} 63 {{/if}}
@@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
53 {{/if}} 53 {{/if}}
54 54
55 {{#if gotCode}} 55 {{#if gotCode}}
56 - <button class="got-limit-sale">已获限购码</button> 56 + <button class="got-limit-sale">已获限购码</button>
57 {{/if}} 57 {{/if}}
58 {{/noLimitGoodsBtn}} 58 {{/noLimitGoodsBtn}}
59 59
@@ -136,7 +136,7 @@ @@ -136,7 +136,7 @@
136 136
137 {{#if addToCartUrl}} 137 {{#if addToCartUrl}}
138 <!-- <a id="addtoCart" href="{{addToCartUrl}}" class="addto-cart">加入购物车</a> --> 138 <!-- <a id="addtoCart" href="{{addToCartUrl}}" class="addto-cart">加入购物车</a> -->
139 - <a id="addtoCart" href="javascript:;" class="addto-cart">加入购物车</a> 139 + <a id="addtoCart" href="javascript:;" class="addto-cart">加入购物车</a>
140 {{/if}} 140 {{/if}}
141 141
142 {{#if soldOut}} 142 {{#if soldOut}}
@@ -148,19 +148,20 @@ @@ -148,19 +148,20 @@
148 {{/if}} 148 {{/if}}
149 149
150 {{#if limitNotForSale}} 150 {{#if limitNotForSale}}
151 - <a href="javascript:;" class="sold-out">即将开售</a> 151 + <a href="javascript:;" class="sold-out limit">即将发售</a>
152 {{/if}} 152 {{/if}}
153 153
154 {{#if canBuyLimit}} 154 {{#if canBuyLimit}}
155 - <a href="javascript:;" class="addto-cart">立即购买</a> 155 + <a href="javascript:;" id="addtoCart" class="addto-cart">立即购买</a>
156 {{/if}} 156 {{/if}}
157 157
158 {{#if noLimitCode}} 158 {{#if noLimitCode}}
159 - <a href="javascript:;" class="sold-out">立即购买</a> 159 + <a href="javascript:;" class="sold-out limit">立即购买</a>
160 {{/if}} 160 {{/if}}
161 - <input type="hidden" name="limitCodeUrl" value="{{limitCodeUrl}}"> 161 + <input type="hidden" id="limitCodeUrl" name="limitCodeUrl" value="{{limitCodeUrl}}">
  162 + <input type="hidden" id="limitProductPay" name="limitProductPay" value="{{limitProductPay}}">
162 {{#limitProductCode}} 163 {{#limitProductCode}}
163 - <input type="hidden" name="limitProductCode" value="{{.}}"> 164 + <input type="hidden" id="limitProductCode" name="limitProductCode" value="{{.}}">
164 {{/limitProductCode}} 165 {{/limitProductCode}}
165 166
166 <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}">&#xe605;</a> 167 <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}">&#xe605;</a>
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="limit-good-page yoho-page"> 2 <div class="limit-good-page yoho-page">
3 <div class="top clearfix"> 3 <div class="top clearfix">
4 - <div>  
5 - <img src="{{profile}}" alt="">  
6 - </div>  
7 <p>我在Yoho!Buy有货发现了一个限定发售商品</p> 4 <p>我在Yoho!Buy有货发现了一个限定发售商品</p>
8 </div> 5 </div>
9 <div class="banner"> 6 <div class="banner">
10 - <a href="{{bannerSrc}}">  
11 - <img src="{{banner}}" alt="">  
12 - </a> 7 + <img src="{{banner}}" alt="">
13 </div> 8 </div>
14 <div class="detail clearfix"> 9 <div class="detail clearfix">
15 <p class="name">{{name}}</p> 10 <p class="name">{{name}}</p>
16 <div class="sale-info"> 11 <div class="sale-info">
17 - <span class="price">{{price}}</span> 12 + <span class="price">{{price}}</span>
18 <span class="date"> 13 <span class="date">
19 <span class="iconfont">&#xe603;</span> 14 <span class="iconfont">&#xe603;</span>
20 <span class="text">{{releaseDate}}</span> 15 <span class="text">{{releaseDate}}</span>
@@ -22,28 +17,26 @@ @@ -22,28 +17,26 @@
22 </div> 17 </div>
23 </div> 18 </div>
24 19
  20 + {{#if attaches}}
25 <div class="goodDesc"> 21 <div class="goodDesc">
26 - {{#mainImg}}  
27 - <img class="lazy" src="{{mainImg}}" alt="">  
28 - {{/mainImg}}  
29 -  
30 - {{#goodDescription}}  
31 - <p class="desc">{{goodDescription}}</p>  
32 - {{/goodDescription}} 22 + {{# attaches}}
  23 + {{#img}}
  24 + <img src="{{attachUrl}}" alt="{{attachName}}">
  25 + {{/img}}
33 26
34 - {{#imgList}}  
35 - <img class="lazy" src="{{img}}" alt="">  
36 - {{/imgList}} 27 + {{#text}}
  28 + <p class="desc">{{intro}}</p>
  29 + {{/text}}
37 30
38 - {{#vedio}}  
39 - <video poster="{{img}}" controls="controls" controls="controls" preload="metadata" loop="loop" width="100%" name="media">  
40 - {{#list}}  
41 - <source src="{{src}}" type="video/ogg;codecs=" theora,vorbis"" media="screen" />  
42 - <source src="{{src}}"/>  
43 - {{/list}}  
44 - </video>  
45 - {{/vedio}} 31 + {{#video}}
  32 + <video poster="{{img}}" controls="controls" controls="controls" preload="metadata" loop="loop" width="100%" name="media">
  33 + <source src="{{attachUrl}}" type="video/ogg;codecs=" theora,vorbis"" media="screen" />
  34 + <source src="{{attachUrl}}"/>
  35 + </video>
  36 + {{/video}}
  37 + {{/attaches}}
46 </div> 38 </div>
  39 + {{/if}}
47 40
48 <div class="bottom"> 41 <div class="bottom">
49 <div class="logo"></div> 42 <div class="logo"></div>
@@ -34,7 +34,7 @@ class HomeController extends AbstractAction @@ -34,7 +34,7 @@ class HomeController extends AbstractAction
34 { 34 {
35 $uid = $this->getUid($useSession); 35 $uid = $this->getUid($useSession);
36 if (!$uid) { 36 if (!$uid) {
37 - $this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN)))); 37 + $this->go(Helpers::url('/signin.html', array('refer' => Helpers::url($this->server('REQUEST_URI', '/home')))));
38 } 38 }
39 } 39 }
40 40
@@ -325,7 +325,8 @@ class CartModel @@ -325,7 +325,8 @@ class CartModel
325 $result = array(); 325 $result = array();
326 326
327 $skuList = ''; 327 $skuList = '';
328 - if (!empty($sku) && !empty($skn) && !empty($buyNumber)) { // 存在sku,skn和buyNumber时 328 + $isLimitGoods = !empty($sku) && !empty($skn) && !empty($buyNumber);
  329 + if ($isLimitGoods) { // 存在sku,skn和buyNumber时为限购商品
329 $skuList = json_encode(array( 330 $skuList = json_encode(array(
330 array( 331 array(
331 'type' => 'limitcode', 332 'type' => 'limitcode',
@@ -335,17 +336,22 @@ class CartModel @@ -335,17 +336,22 @@ class CartModel
335 'buy_number' => $buyNumber 336 'buy_number' => $buyNumber
336 ) 337 )
337 )); 338 ));
  339 + $result['isLimit'] = true;
338 } 340 }
339 341
340 $pay = CartData::cartPay($uid, $cartType, 0, $skuList); 342 $pay = CartData::cartPay($uid, $cartType, 0, $skuList);
341 343
342 - // 商品为空返回  
343 - if (!$pay || empty($pay['data']['goods_list'])) {  
344 - $result['cartUrl'] = Helpers::url('/cart/index/index');  
345 - return $result;  
346 - } 344 + do {
  345 + if (!$pay || $pay['code'] != 200 || empty($pay['data']['goods_list'])) {
  346 + if ($isLimitGoods) {
  347 + $result['error'] = true;
  348 + } else {
  349 + $result['cartUrl'] = Helpers::url('/cart/index/index');
  350 + }
  351 +
  352 + break;
  353 + }
347 354
348 - if ($pay && isset($pay['code']) && $pay['code'] === 200) {  
349 $payReturn = $pay['data']; 355 $payReturn = $pay['data'];
350 $address = array(); 356 $address = array();
351 $orderCompute = array(); 357 $orderCompute = array();
@@ -506,7 +512,8 @@ class CartModel @@ -506,7 +512,8 @@ class CartModel
506 $coupons['couponName'] = $orderInfo['couponName']; 512 $coupons['couponName'] = $orderInfo['couponName'];
507 } 513 }
508 $result['coupon'] = $coupons; 514 $result['coupon'] = $coupons;
509 - } 515 +
  516 + } while (false);
510 517
511 return $result; 518 return $result;
512 } 519 }
@@ -44,6 +44,7 @@ class DetailModel @@ -44,6 +44,7 @@ class DetailModel
44 if (empty($baseInfo['productName'])) { 44 if (empty($baseInfo['productName'])) {
45 return $result; 45 return $result;
46 } 46 }
  47 +
47 $result['goodsName'] = $baseInfo['productName']; 48 $result['goodsName'] = $baseInfo['productName'];
48 49
49 // 商品促销短语 50 // 商品促销短语
@@ -290,16 +291,10 @@ class DetailModel @@ -290,16 +291,10 @@ class DetailModel
290 $soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0 || $totalStorageNum === 0); 291 $soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0 || $totalStorageNum === 0);
291 $notForSale = $baseInfo['attribute'] == 2; 292 $notForSale = $baseInfo['attribute'] == 2;
292 293
293 - // 是否为限购商品  
294 - $isLimited = ($baseInfo['isLimitBuy'] === 'Y');  
295 -  
296 -  
297 -  
298 // 显示加入购物车链接 294 // 显示加入购物车链接
299 - if (!$soldOut && !$notForSale && !$isLimited) { 295 + if (!$soldOut && !$notForSale) {
300 ksort($colorGroup, SORT_NUMERIC); 296 ksort($colorGroup, SORT_NUMERIC);
301 -  
302 - $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); 297 +
303 $result['cartInfo']['productId'] = $productId; 298 $result['cartInfo']['productId'] = $productId;
304 $result['cartInfo']['thumbs'] = $thumbImageList; 299 $result['cartInfo']['thumbs'] = $thumbImageList;
305 $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : ''; 300 $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
@@ -308,6 +303,26 @@ class DetailModel @@ -308,6 +303,26 @@ class DetailModel
308 $result['cartInfo']['totalNum'] = $totalStorageNum; 303 $result['cartInfo']['totalNum'] = $totalStorageNum;
309 $result['cartInfo']['colors'] = $colorGroup; 304 $result['cartInfo']['colors'] = $colorGroup;
310 $result['cartInfo']['sizes'] = $sizeGroup; 305 $result['cartInfo']['sizes'] = $sizeGroup;
  306 +
  307 + // 限购商品
  308 + if ($baseInfo['isLimitBuy'] === 'Y') {
  309 + // 是否开售
  310 + $isBeginSale = (isset($baseInfo['saleStatus']) && $baseInfo['saleStatus'] == 1);
  311 + // 限购商品有关的展示状态
  312 + $showStatus = 1;
  313 + if (isset($baseInfo['showStatus'])) {
  314 + $showStatus = intval($baseInfo['showStatus']);
  315 + }
  316 +
  317 + // 处理限购商品有关的按钮状态
  318 + self::procShowStatus($result, $showStatus, $isBeginSale);
  319 +
  320 + $result['cartInfo']['limitProductCode'] = $baseInfo['limitProductCode'];
  321 + $result['cartInfo']['limitCodeUrl'] = self::getLimitCodeUrl($baseInfo['erpProductId']);
  322 + $result['cartInfo']['limitProductPay'] = Helpers::url('/cart/index/orderEnsure');
  323 + } else {
  324 + $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
  325 + }
311 } 326 }
312 // 非卖品 327 // 非卖品
313 elseif ($notForSale) { 328 elseif ($notForSale) {
@@ -317,22 +332,6 @@ class DetailModel @@ -317,22 +332,6 @@ class DetailModel
317 elseif ($soldOut) { 332 elseif ($soldOut) {
318 $result['cartInfo']['soldOut'] = true; 333 $result['cartInfo']['soldOut'] = true;
319 } 334 }
320 - // 限购商品  
321 - elseif ($isLimited) {  
322 - // 是否开售  
323 - $isBeginSale = (isset($baseInfo['saleStatus']) && $baseInfo['saleStatus'] == 1);  
324 - // 限购商品有关的展示状态  
325 - $showStatus = 1;  
326 - if (isset($baseInfo['showStatus'])) {  
327 - $showStatus = intval($baseInfo['showStatus']);  
328 - }  
329 -  
330 - // 处理限购商品有关的按钮状态  
331 - self::procShowStatus($result, $showStatus, $isBeginSale);  
332 -  
333 - $result['cartInfo']['limitProductCode'] = $baseInfo['limitProductCode'];  
334 - $result['cartInfo']['limitCodeUrl'] = 'yohobuy://' . Helpers::url('/product', array('skn' => $baseInfo['erpProductId']));  
335 - }  
336 335
337 // 是否收藏 336 // 是否收藏
338 $result['isCollect'] = false; 337 $result['isCollect'] = false;
@@ -717,6 +716,8 @@ class DetailModel @@ -717,6 +716,8 @@ class DetailModel
717 * 获取为你优选的商品 716 * 获取为你优选的商品
718 * 717 *
719 * @param int $productSkn 商品SKN 718 * @param int $productSkn 商品SKN
  719 + * @param int $channel
  720 + * @param int $brandId
720 * @return array 721 * @return array
721 */ 722 */
722 public static function getPreference($productSkn, $channel, $brandId) 723 public static function getPreference($productSkn, $channel, $brandId)
@@ -738,6 +739,89 @@ class DetailModel @@ -738,6 +739,89 @@ class DetailModel
738 return $result; 739 return $result;
739 } 740 }
740 741
  742 +
  743 + /**
  744 + * 获取限购商品详情
  745 + *
  746 + * @param int $uid 用户UID
  747 + * @param string $productCode
  748 + * @return array
  749 + */
  750 + public static function getLimitProductData($uid, $productCode)
  751 + {
  752 + $result = array();
  753 +
  754 + do {
  755 + $productData = DetailData::limitProductData($uid, $productCode);
  756 +
  757 + if (empty($productData) || empty($productData['data'])) {
  758 + break;
  759 + }
  760 + $product = $productData['data'];
  761 +
  762 + $result['price'] = $product['price'];
  763 + $result['name'] = $product['productName'];
  764 + // 发售日期
  765 + $result['releaseDate'] = $product['saleTime'] . '发售';
  766 + // baner
  767 + $result['banner'] = $product['defaultUrl'];
  768 + $result['description'] = $product['description'];
  769 +
  770 + // 附件
  771 + if (isset($product['attachment'])) {
  772 + foreach ($product['attachment'] as $item) {
  773 + $result['attaches'][] = self::procLimitProductAttach($item);
  774 + }
  775 + }
  776 +
  777 + } while (false);
  778 +
  779 + return $result;
  780 + }
  781 +
  782 + /**
  783 + * 处理限购商品附件数据
  784 + *
  785 + * @param array $attachment 附件数据
  786 + * @return array
  787 + */
  788 + private static function procLimitProductAttach($attachment)
  789 + {
  790 + $result = array();
  791 +
  792 + switch(intval($attachment['attachType'])) {
  793 + case 1: // 大图文字
  794 + $result['img'] = array(
  795 + 'attachUrl' => Helpers::getImageUrl($attachment['attachUrl'], 290, 200),
  796 + 'attachName' => $attachment['attachName'],
  797 + 'intro' => $attachment['intro'],
  798 + 'orderBy' => $attachment['orderBy']
  799 + );
  800 + break;
  801 + case 2: // 视频
  802 + $result['video'] = array(
  803 + 'attachUrl' => $attachment['attachUrl'],
  804 + 'orderBy' => $attachment['orderBy'],
  805 + 'img' => Helpers::getImageUrl($attachment['intro'], 290, 200)
  806 + );
  807 + break;
  808 + case 3: // 文本类型
  809 + $result['text'] = array(
  810 + 'intro' => $attachment['intro'],
  811 + 'orderBy' => $attachment['orderBy']
  812 + );
  813 + break;
  814 + default:
  815 + break;
  816 + }
  817 +
  818 + if(count($result) > 1) {
  819 + Helpers::sortArrByField($result, 'orderBy');
  820 + }
  821 +
  822 + return $result;
  823 + }
  824 +
741 /** 825 /**
742 * 处理限购商品的有关按钮状态(或取现购买以及底部商品购买按钮) 826 * 处理限购商品的有关按钮状态(或取现购买以及底部商品购买按钮)
743 * 827 *
@@ -783,4 +867,22 @@ class DetailModel @@ -783,4 +867,22 @@ class DetailModel
783 } 867 }
784 } 868 }
785 869
  870 + /**
  871 + * 根据设备类型获得限购商品跳转app的url
  872 + *
  873 + * @param string $skn 商品skn
  874 + * @return string 限购商品跳转url
  875 + */
  876 + private static function getLimitCodeUrl($skn)
  877 + {
  878 + $url = 'yohoapp://yoho.app/openwith?product_skn=' . $skn;
  879 +
  880 + // 苹果设备或者苹果IPAD
  881 + if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
  882 + $url = 'yohobuy://' . Helpers::url('/product', array('skn' => $skn));
  883 + }
  884 +
  885 + return $url;
  886 + }
  887 +
786 } 888 }
@@ -295,17 +295,20 @@ class IndexController extends AbstractAction @@ -295,17 +295,20 @@ class IndexController extends AbstractAction
295 } 295 }
296 296
297 // 如果传递了code, sku,skn,buy_number就代表是限购商品 297 // 如果传递了code, sku,skn,buy_number就代表是限购商品
298 - $limitProductCode = $this->get('code', ''); 298 + $limitProductCode = $this->get('limitproductcode', '');
299 $sku = $this->get('sku', ''); 299 $sku = $this->get('sku', '');
300 $skn = $this->get('skn', ''); 300 $skn = $this->get('skn', '');
301 - $buyNumber = $this->get('buy_number', ''); 301 + $buyNumber = $this->get('buy_number', 1);
302 302
303 // 购物车商品为空跳转到购物车页面 303 // 购物车商品为空跳转到购物车页面
304 $uid = $this->getUid(true); 304 $uid = $this->getUid(true);
305 $order = CartModel::cartPay($uid, $cartType, $orderInfo, $limitProductCode, $sku, $skn, $buyNumber); 305 $order = CartModel::cartPay($uid, $cartType, $orderInfo, $limitProductCode, $sku, $skn, $buyNumber);
306 - if (isset($order['cartUrl'])) { 306 + if (isset($order['cartUrl'])) { // 普通或者预售商品为空时
307 $this->go($order['cartUrl']); 307 $this->go($order['cartUrl']);
308 } 308 }
  309 + if (isset($order['error'])) { // 限购商品支付接口返回为空或错误时
  310 + $this->error();
  311 + }
309 312
310 $data = array( 313 $data = array(
311 'orderEnsurePage' => true, 314 'orderEnsurePage' => true,
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use Plugin\Helpers; 4 use Plugin\Helpers;
5 use LibModels\Wap\Product\DetailData; 5 use LibModels\Wap\Product\DetailData;
  6 +use Product\DetailModel;
6 7
7 /** 8 /**
8 * 商品详情的控制器 9 * 商品详情的控制器
@@ -33,10 +34,11 @@ class DetailController extends AbstractAction @@ -33,10 +34,11 @@ class DetailController extends AbstractAction
33 $vipLevel = Helpers::getVipLevel($this->_vip); 34 $vipLevel = Helpers::getVipLevel($this->_vip);
34 } 35 }
35 36
36 - $data = \Product\DetailModel::getBaseInfo($productId, $goodsId, $uid, $vipLevel); 37 + $data = DetailModel::getBaseInfo($productId, $goodsId, $uid, $vipLevel);
37 if (array() === $data) { 38 if (array() === $data) {
38 $this->error(); 39 $this->error();
39 } 40 }
  41 +
40 $data['goodsDetailPage'] = true; 42 $data['goodsDetailPage'] = true;
41 $data['pageFooter'] = true; 43 $data['pageFooter'] = true;
42 44
@@ -66,7 +68,7 @@ class DetailController extends AbstractAction @@ -66,7 +68,7 @@ class DetailController extends AbstractAction
66 $vipLevel = Helpers::getVipLevel($this->_vip); 68 $vipLevel = Helpers::getVipLevel($this->_vip);
67 } 69 }
68 70
69 - $data = \Product\DetailModel::getBaseInfo(null, null, $uid, $vipLevel, $productSkn); 71 + $data = DetailModel::getBaseInfo(null, null, $uid, $vipLevel, $productSkn);
70 if (array() === $data) { 72 if (array() === $data) {
71 $this->error(); 73 $this->error();
72 } 74 }
@@ -94,7 +96,7 @@ class DetailController extends AbstractAction @@ -94,7 +96,7 @@ class DetailController extends AbstractAction
94 // 加入uid和udid参数,为了实现记录浏览记录的功能 96 // 加入uid和udid参数,为了实现记录浏览记录的功能
95 $uid = $this->getUid(); 97 $uid = $this->getUid();
96 $udid = $this->getUdid(); 98 $udid = $this->getUdid();
97 - $data = \Product\DetailModel::getSizeInfo($productSkn, $uid, $udid); 99 + $data = DetailModel::getSizeInfo($productSkn, $uid, $udid);
98 if (array() === $data) { 100 if (array() === $data) {
99 echo ' '; 101 echo ' ';
100 exit(); 102 exit();
@@ -126,7 +128,7 @@ class DetailController extends AbstractAction @@ -126,7 +128,7 @@ class DetailController extends AbstractAction
126 'goodsCommentsPage' => true, 128 'goodsCommentsPage' => true,
127 'pageFooter' => true, 129 'pageFooter' => true,
128 'comments' => array( 130 'comments' => array(
129 - 'list' => \Product\DetailModel::getComments($productId), 131 + 'list' => DetailModel::getComments($productId),
130 ), 132 ),
131 ); 133 );
132 134
@@ -155,14 +157,14 @@ class DetailController extends AbstractAction @@ -155,14 +157,14 @@ class DetailController extends AbstractAction
155 $this->setTitle('购买咨询'); 157 $this->setTitle('购买咨询');
156 158
157 $uid = $this->getUid(); 159 $uid = $this->getUid();
158 - $consults = \Product\DetailModel::getConsults($uid, $productId); 160 + $consults = DetailModel::getConsults($uid, $productId);
159 $data = array( 161 $data = array(
160 'goodsConsultsPage' => true, 162 'goodsConsultsPage' => true,
161 'pageFooter' => true, 163 'pageFooter' => true,
162 'consults' => array( 164 'consults' => array(
163 'list' => $consults 165 'list' => $consults
164 ), 166 ),
165 - 'faq' => \Product\DetailModel::getCommonConsults(), 167 + 'faq' => DetailModel::getCommonConsults(),
166 'showReadMore' => count($consults) > 2, 168 'showReadMore' => count($consults) > 2,
167 'link' => Helpers::url('/product/detail/consultform', array('product_id' => $productId)), 169 'link' => Helpers::url('/product/detail/consultform', array('product_id' => $productId)),
168 ); 170 );
@@ -184,7 +186,7 @@ class DetailController extends AbstractAction @@ -184,7 +186,7 @@ class DetailController extends AbstractAction
184 $total = $this->post('total', 0); 186 $total = $this->post('total', 0);
185 $uid = $this->getUid(); 187 $uid = $this->getUid();
186 $id = $this->post('id'); 188 $id = $this->post('id');
187 - $result = \Product\DetailModel::upvoteConsult($uid, $id, $productId, $total); 189 + $result = DetailModel::upvoteConsult($uid, $id, $productId, $total);
188 } 190 }
189 191
190 $this->echoJson($result); 192 $this->echoJson($result);
@@ -202,7 +204,7 @@ class DetailController extends AbstractAction @@ -202,7 +204,7 @@ class DetailController extends AbstractAction
202 $total = $this->post('total', 0); 204 $total = $this->post('total', 0);
203 $uid = $this->getUid(); 205 $uid = $this->getUid();
204 $id = $this->post('id'); 206 $id = $this->post('id');
205 - $result = \Product\DetailModel::usefulConsult($uid, $id, $productId, $total); 207 + $result = DetailModel::usefulConsult($uid, $id, $productId, $total);
206 } 208 }
207 209
208 $this->echoJson($result); 210 $this->echoJson($result);
@@ -266,7 +268,7 @@ class DetailController extends AbstractAction @@ -266,7 +268,7 @@ class DetailController extends AbstractAction
266 $productSkn = $this->get('productSkn'); 268 $productSkn = $this->get('productSkn');
267 $brandId = $this->get('brandId'); 269 $brandId = $this->get('brandId');
268 $channel = Helpers::getChannelByCookie(); 270 $channel = Helpers::getChannelByCookie();
269 - $result = \Product\DetailModel::getPreference($productSkn, $channel, $brandId); 271 + $result = DetailModel::getPreference($productSkn, $channel, $brandId);
270 } 272 }
271 273
272 if (empty($result)) { 274 if (empty($result)) {
@@ -276,4 +278,35 @@ class DetailController extends AbstractAction @@ -276,4 +278,35 @@ class DetailController extends AbstractAction
276 } 278 }
277 } 279 }
278 280
  281 + /**
  282 + * 限购商品说明页面
  283 + */
  284 + public function limitHelpAction()
  285 + {
  286 + $data = array();
  287 + $this->_view->display('limit-help', $data);
  288 + }
  289 +
  290 + /**
  291 + * 限购商品详情页
  292 + */
  293 + public function limitAction()
  294 + {
  295 + $productCode = $this->get('code', '');
  296 + if (empty($productCode)) {
  297 + $this->error();
  298 + }
  299 +
  300 + $uid = $this->getUid();
  301 + $data = DetailModel::getLimitProductData($uid, $productCode);
  302 + if (empty($data)) {
  303 + $this->error();
  304 + }
  305 +
  306 + // APP下载链接地址
  307 + $data['appSrc'] = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho';
  308 +
  309 + $this->_view->display('limit', $data);
  310 + }
  311 +
279 } 312 }
@@ -228,54 +228,4 @@ class IndexController extends AbstractAction @@ -228,54 +228,4 @@ class IndexController extends AbstractAction
228 228
229 $this->_view->display('index', $data); 229 $this->_view->display('index', $data);
230 } 230 }
231 -  
232 - public function limitHelpAction()  
233 - {  
234 - $data = array();  
235 - $this->_view->display('limit-help', $data);  
236 - }  
237 -  
238 - public function limitAction()  
239 - {  
240 - $data = array(  
241 - 'profile' => 'http://cdn.yoho.cn/myohobuy/assets/img/me/index/user-avatar.png?1455719653',  
242 - 'banner' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240',  
243 - 'bannerSrc' => './',  
244 - 'name' => '潮流尖端商品啊啊啊啊',  
245 - 'price' => '1999',  
246 - 'releaseDate' => '2016年12月发售',  
247 - 'appSrc' => './',  
248 - 'mainImg' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240',  
249 - 'goodDescription' => '独独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤',  
250 - 'imgList' => array(  
251 - array(  
252 - 'img' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240'  
253 - ),  
254 - array(  
255 - 'img' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240'  
256 - ),  
257 - array(  
258 - 'img' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240'  
259 - )  
260 - ),  
261 - 'vedio' => array(  
262 - 'img' => './',  
263 - 'list' => array(  
264 - array(  
265 - 'src' => 'http://video.yohoboys.com/xuanchuan/wuyifan_mobile.mp4'  
266 - ),  
267 - array(  
268 - 'src' => 'http://video.yohoboys.com/xuanchuan/wuyifan_mobile.webm'  
269 - ),  
270 - array(  
271 - 'src' => 'http://video.yohoboys.com/xuanchuan/wuyifan_mobile.ogv'  
272 - )  
273 - )  
274 - )  
275 - );  
276 -  
277 -  
278 -  
279 - $this->_view->display('limit', $data);  
280 - }  
281 } 231 }