Toggle navigation
Toggle navigation
This project
Loading...
Sign in
chenchao
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
b7195dea8a67e63ae4bf134d41ee6c8404eb79c1
2 parents
d21a81a9
e9c438dc
Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
329 additions
and
244 deletions
library/LibModels/Wap/Product/DetailData.php
library/Plugin/Helpers.php
static/js/cart/chose-panel.js
static/sass/cart/_index.scss
template/m.yohobuy.com/partials/cart/cart-content.phtml
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Detail.php
yohobuy/m.yohobuy.com/configs/routes.index.ini
yohobuy/m.yohobuy.com/configs/routes.product.ini
library/LibModels/Wap/Product/DetailData.php
View file @
b7195de
...
...
@@ -29,11 +29,15 @@ class DetailData
* @param int $uid 用户ID
* @return array
*/
public
static
function
baseInfo
(
$productId
,
$uid
)
public
static
function
baseInfo
(
$productId
,
$uid
,
$productSkn
=
null
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'h5.product.data'
;
$param
[
'productId'
]
=
$productId
;
if
(
$productId
!==
null
)
{
$param
[
'productId'
]
=
$productId
;
}
elseif
(
$productSkn
!==
null
)
{
$param
[
'product_skn'
]
=
$productSkn
;
}
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
...
...
library/Plugin/Helpers.php
View file @
b7195de
...
...
@@ -546,8 +546,8 @@ class Helpers
$arr
[
$key
][
'appearDate'
]
=
$vo
[
'expect_arrival_time'
];
}
// 商品链接
if
(
$haveLink
&&
isset
(
$vo
[
'product_id'
]))
{
$arr
[
$key
][
'link'
]
=
self
::
url
(
'/product/pro_'
.
$vo
[
'product_id'
]
.
'_'
.
$vo
[
'goods_id'
]
.
'/'
.
$vo
[
'cn_alphabet'
]
.
'.html'
);
if
(
$haveLink
&&
isset
(
$vo
[
'product_skn'
]))
{
$arr
[
$key
][
'link'
]
=
self
::
url
(
'/product/show_'
.
$vo
[
'product_skn'
]
.
'.html'
);
}
// 累计购买数
$count
+=
intval
(
$vo
[
'buy_number'
]);
...
...
static/js/cart/chose-panel.js
View file @
b7195de
...
...
@@ -18,9 +18,9 @@ var panelTmpl,
$chosePanel
=
$
(
'#chose-panel'
),
$num
,
$chosed
,
re
=
/
\d
+/
,
// re = /\d+/,
leftNum
,
$sizeList
,
confirming
,
hasChooseColor
=
false
,
hasChooseSize
=
false
,
...
...
@@ -98,7 +98,7 @@ function hide() {
$
(
'body'
).
css
(
'overflow'
,
'auto'
);
}
$
(
'.yoho-page'
).
on
(
'touchstart'
,
'.
infos
'
,
function
(
e
)
{
$
(
'.yoho-page'
).
on
(
'touchstart'
,
'.
chose-panel
'
,
function
(
e
)
{
var
$cur
=
$
(
e
.
target
);
if
(
$cur
.
closest
(
'.main'
).
length
>
0
)
{
...
...
@@ -132,6 +132,7 @@ $('.color-list').on('touchstart', '.block', function(e) {
//颜色原来已经是勾选时,要清空剩余件数的提示
$that
.
find
(
'.num .left-num'
).
html
(
''
);
$
(
'#left-num'
).
val
(
0
);
hasChooseColor
=
false
;
// 当前颜色不是选中状态,选中时
...
...
@@ -161,9 +162,11 @@ $('.color-list').on('touchstart', '.block', function(e) {
//如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
if
(
curGoodNum
>
0
)
{
$that
.
find
(
'.num .left-num'
).
html
(
'剩余'
+
curGoodNum
+
'件'
);
$
(
'#left-num'
).
val
(
curGoodNum
);
}
else
{
$
(
curSelectedSizeBlock
).
removeClass
(
'zero-stock'
).
addClass
(
'zero-stock'
);
$that
.
find
(
'.num .left-num'
).
html
(
''
);
$
(
'#left-num'
).
val
(
0
);
}
}
}
...
...
@@ -250,7 +253,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
$that
=
$
(
e
.
target
).
closest
(
'.chose-items'
),
index
,
$colorChosed
,
selectedColorindex
,
curGoodNum
;
var
$siblingBlock
=
$this
.
closest
(
'.block-list'
).
siblings
(
':first'
);
...
...
@@ -259,7 +261,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
index
=
$this
.
index
();
$colorChosed
=
$siblingBlock
.
find
(
'.chosed'
);
selectedColorindex
=
$colorChosed
.
index
();
$curSizeRow
=
$sizeRowList
.
eq
(
index
);
// 当前尺码已经是选中状态,再点击时
...
...
@@ -267,6 +268,7 @@ $('.size-list').on('touchstart', '.block', function(e) {
//尺码原来已经是勾选时,要清空剩余件数的提示
$that
.
find
(
'.num .left-num'
).
html
(
''
);
$
(
'#left-num'
).
val
(
0
);
hasChooseSize
=
false
;
// 去掉已经选中颜色的 数量为0的样式
...
...
@@ -286,11 +288,13 @@ $('.size-list').on('touchstart', '.block', function(e) {
}
// 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数
if
(
curGoodNum
>
0
)
{
if
(
curGoodNum
>
0
&&
hasChooseColor
)
{
$that
.
find
(
'.num .left-num'
).
html
(
'剩余'
+
curGoodNum
+
'件'
);
$
(
'#left-num'
).
val
(
curGoodNum
);
}
else
{
$colorChosed
.
removeClass
(
'zero-stock'
).
addClass
(
'zero-stock'
);
$that
.
find
(
'.num .left-num'
).
html
(
''
);
$
(
'#left-num'
).
val
(
0
);
}
}
...
...
@@ -375,8 +379,9 @@ $('.size-list').on('touchstart', '.block', function(e) {
});
$
(
'.btn-minus'
).
on
(
'touchstart'
,
function
()
{
var
num
=
$num
.
val
(),
leftNum
=
re
.
exec
(
$
(
'.num .left-num'
).
html
());
var
num
=
$num
.
val
();
leftNum
=
$
(
'#left-num'
).
val
();
if
(
!
checkColorSizeNum
())
{
return
;
...
...
@@ -392,12 +397,14 @@ $('.btn-minus').on('touchstart', function() {
$
(
'.btn-plus'
).
on
(
'touchstart'
,
function
()
{
var
num
=
$num
.
val
();
leftNum
=
$
(
'#left-num'
).
val
();
if
(
!
checkColorSizeNum
())
{
return
;
}
leftNum
=
re
.
exec
(
$
(
'.num .left-num'
).
html
());
if
(
num
-
0
===
leftNum
-
0
||
0
===
leftNum
-
0
)
{
if
(
num
-
0
===
leftNum
||
0
===
leftNum
)
{
return
;
}
...
...
@@ -405,7 +412,7 @@ $('.btn-plus').on('touchstart', function() {
$num
.
val
(
num
+
1
);
});
$
(
'#chose-btn-sure'
).
on
(
'touch
end
'
,
function
()
{
$
(
'#chose-btn-sure'
).
on
(
'touch
start
'
,
function
()
{
var
productSku
,
buyNumber
=
$
(
'#good-num'
).
val
()
-
0
,
...
...
@@ -419,7 +426,11 @@ $('#chose-btn-sure').on('touchend', function() {
return
;
}
leftNum
=
re
.
exec
(
$
(
'.num .left-num'
).
html
());
if
(
$
(
'#chose-btn-sure'
).
html
()
===
'已售罄'
)
{
return
;
}
leftNum
=
$
(
'#left-num'
).
val
();
if
(
num
>
leftNum
)
{
tip
.
show
(
'您选择的数量超过了最大库存量~'
);
...
...
@@ -429,7 +440,7 @@ $('#chose-btn-sure').on('touchend', function() {
$chosed
=
$
(
'.block-list>ul>li.chosed'
);
if
(
2
===
$chosed
.
length
&&
0
===
$chosed
.
closest
(
'.zero-stock'
).
length
)
{
productSku
=
$
sizeList
.
closest
(
'.chosed'
)
.
data
(
'skuid'
);
productSku
=
$
curSizeBlock
.
data
(
'skuid'
);
promotionId
=
$
(
'[data-id="'
+
productSku
+
'"]'
).
closest
(
'.advance-block'
).
data
(
'promotion-id'
);
if
(
confirming
)
{
return
false
;
...
...
static/sass/cart/_index.scss
View file @
b7195de
...
...
@@ -116,11 +116,26 @@
color
:
#8f8f8f
;
}
}
.price-compute
{
.activity
{
padding
:
20rem
/
$pxConvertRem
;
border-bottom
:
1px
solid
#e0e0e0
;
font-size
:
26rem
/
$pxConvertRem
;
h1
{
font-size
:
32rem
/
$pxConvertRem
;
}
li
:before
{
content
:
""
;
display
:
inline-block
;
width
:
4px
;
height
:
4px
;
background-color
:
#000
;
border-radius
:
50%
;
margin-right
:
8rem
/
$pxConvertRem
;
}
}
.price-compute
{
padding
:
20rem
/
$pxConvertRem
;
border-top
:
1px
solid
#e0e0e0
;
font-size
:
28rem
/
$pxConvertRem
;
.title
{
display
:
inline-block
;
...
...
template/m.yohobuy.com/partials/cart/cart-content.phtml
View file @
b7195de
...
...
@@ -33,18 +33,21 @@
{{/if}}
</ul>
{{/if}}
<div class="activity">
<h1>以参与活动</h1>
<ul>
{{# promotionInfo}}
<li>{{name}}</li>
{{/ promotionInfo}}
</ul>
</div>
<div class="price-compute">
<p class="sum-price">
<span class="title">总价</span>
<span id="good-totalprice">¥{{price}}</span>
<p>
<span>总价(¥{{price}})<i>-</i></span>
<span>活动价(¥{{activityPrice}})</span>
</p>
<p class="activity-price">
<span class="title">
活动价
<i class="minus">-</i>
</span>
<span id="good-activityPrice">¥{{activityPrice}}</span>
<p>
<span><i>=</i>商品总计金额 (¥{{sumPrice}})</span>
</p>
</div>
...
...
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
View file @
b7195de
...
...
@@ -20,265 +20,270 @@ class DetailModel
/**
* 商品基本信息
*
* @param int $productId 商品ID
* @param int $productId 商品ID
SKN 和 ID 只需要传一个
* @param int $goodsId 某个颜色的商品
* @param int $uid 当前登录用户ID, 未登录为0
* @param int $productSkn SKN 和 ID 只需要传一个
* @return array
*/
public
static
function
getBaseInfo
(
$productId
,
$goodsId
,
$uid
,
$vipLevel
)
public
static
function
getBaseInfo
(
$productId
,
$goodsId
,
$uid
,
$vipLevel
,
$productSkn
=
null
)
{
$result
=
array
();
$baseInfo
=
array
();
// 通过ID获取
if
(
is_numeric
(
$productId
)
&&
is_numeric
(
$goodsId
))
{
// 调用服务
$baseInfo
=
DetailData
::
baseInfo
(
$productId
,
$uid
);
}
// 通过SKN获取
elseif
(
is_numeric
(
$productSkn
))
{
$baseInfo
=
DetailData
::
baseInfo
(
null
,
$uid
,
$productSkn
);
}
// 商品名称
if
(
empty
(
$baseInfo
[
'productName'
]))
{
return
$result
;
}
$result
[
'goodsName'
]
=
$baseInfo
[
'productName'
];
// 商品名称
if
(
empty
(
$baseInfo
[
'productName'
]))
{
return
$result
;
}
$result
[
'goodsName'
]
=
$baseInfo
[
'productName'
];
// 商品促销短语
if
(
!
empty
(
$baseInfo
[
'salesPhrase'
]))
{
$result
[
'goodsSubtitle'
]
=
$baseInfo
[
'salesPhrase'
];
}
// 商品促销短语
if
(
!
empty
(
$baseInfo
[
'salesPhrase'
]))
{
$result
[
'goodsSubtitle'
]
=
$baseInfo
[
'salesPhrase'
];
}
// 商品标签
if
(
!
empty
(
$baseInfo
[
'productTagBoList'
]))
{
foreach
(
$baseInfo
[
'productTagBoList'
]
as
$value
)
{
switch
(
$value
[
'tagLabel'
])
{
case
'is_soon_sold_out'
:
// 即将售磬
$result
[
'tags'
][
'is_soon_sold_out'
]
=
true
;
break
;
case
'is_new'
:
// 新品NEW
$result
[
'tags'
][
'is_new'
]
=
true
;
break
;
case
'is_discount'
:
// SALE
$result
[
'tags'
][
'is_discount'
]
=
true
;
break
;
case
'is_limited'
:
// 限量
$result
[
'tags'
][
'is_limited'
]
=
true
;
break
;
case
'is_yohood'
:
// YOHOOD
$result
[
'tags'
][
'is_yohood'
]
=
true
;
break
;
case
'is_advance'
:
// 再到着
$result
[
'tags'
][
'is_advance'
]
=
true
;
break
;
}
// 商品标签
if
(
!
empty
(
$baseInfo
[
'productTagBoList'
]))
{
foreach
(
$baseInfo
[
'productTagBoList'
]
as
$value
)
{
switch
(
$value
[
'tagLabel'
])
{
case
'is_soon_sold_out'
:
// 即将售磬
$result
[
'tags'
][
'is_soon_sold_out'
]
=
true
;
break
;
case
'is_new'
:
// 新品NEW
$result
[
'tags'
][
'is_new'
]
=
true
;
break
;
case
'is_discount'
:
// SALE
$result
[
'tags'
][
'is_discount'
]
=
true
;
break
;
case
'is_limited'
:
// 限量
$result
[
'tags'
][
'is_limited'
]
=
true
;
break
;
case
'is_yohood'
:
// YOHOOD
$result
[
'tags'
][
'is_yohood'
]
=
true
;
break
;
case
'is_advance'
:
// 再到着
$result
[
'tags'
][
'is_advance'
]
=
true
;
break
;
}
}
}
// 商品价格
if
(
isset
(
$baseInfo
[
'productPriceBo'
]))
{
$result
[
'goodsPrice'
]
=
array
();
$result
[
'goodsPrice'
][
'currentPrice'
]
=
$baseInfo
[
'productPriceBo'
][
'formatSalesPrice'
];
if
(
$baseInfo
[
'productPriceBo'
][
'formatMarketPrice'
]
!==
$baseInfo
[
'productPriceBo'
][
'formatSalesPrice'
])
{
$result
[
'goodsPrice'
][
'previousPrice'
]
=
$baseInfo
[
'productPriceBo'
][
'formatMarketPrice'
];
}
// 商品价格
if
(
isset
(
$baseInfo
[
'productPriceBo'
]))
{
$result
[
'goodsPrice'
]
=
array
();
$result
[
'goodsPrice'
][
'currentPrice'
]
=
$baseInfo
[
'productPriceBo'
][
'formatSalesPrice'
];
if
(
$baseInfo
[
'productPriceBo'
][
'formatMarketPrice'
]
!==
$baseInfo
[
'productPriceBo'
][
'formatSalesPrice'
])
{
$result
[
'goodsPrice'
][
'previousPrice'
]
=
$baseInfo
[
'productPriceBo'
][
'formatMarketPrice'
];
}
// VIP商品价格
if
(
isset
(
$baseInfo
[
'productPriceBo'
][
'vipPrices'
]))
{
$build
=
array
();
foreach
(
$baseInfo
[
'productPriceBo'
][
'vipPrices'
]
as
$value
)
{
$build
[
'level'
]
=
$value
[
'vipLevel'
];
$build
[
'text'
]
=
$value
[
'vipPrice'
];
$build
[
'currentLevel'
]
=
(
$value
[
'vipLevel'
]
==
$vipLevel
)
?
true
:
false
;
$result
[
'vipLevel'
][
'list'
][]
=
$build
;
}
}
// VIP商品价格
if
(
isset
(
$baseInfo
[
'productPriceBo'
][
'vipPrices'
]))
{
$build
=
array
();
foreach
(
$baseInfo
[
'productPriceBo'
][
'vipPrices'
]
as
$value
)
{
$build
[
'level'
]
=
$value
[
'vipLevel'
];
$build
[
'text'
]
=
$value
[
'vipPrice'
];
$build
[
'currentLevel'
]
=
(
$value
[
'vipLevel'
]
==
$vipLevel
)
?
true
:
false
;
$result
[
'vipLevel'
][
'list'
][]
=
$build
;
}
}
// 上市期
if
(
isset
(
$baseInfo
[
'expectArrivalTime'
])
&&
!
empty
(
$baseInfo
[
'expectArrivalTime'
]))
{
$result
[
'periodOfMarket'
]
=
$baseInfo
[
'expectArrivalTime'
]
.
'月'
;
}
// 上市期
if
(
isset
(
$baseInfo
[
'expectArrivalTime'
])
&&
!
empty
(
$baseInfo
[
'expectArrivalTime'
]))
{
$result
[
'periodOfMarket'
]
=
$baseInfo
[
'expectArrivalTime'
]
.
'月'
;
}
// 促销信息
if
(
isset
(
$baseInfo
[
'promotionBoList'
]))
{
$build
=
array
();
foreach
(
$baseInfo
[
'promotionBoList'
]
as
$value
)
{
$build
[
'text'
]
=
'【'
.
$value
[
'promotionType'
]
.
'】'
.
$value
[
'promotionTitle'
];
$result
[
'goodsDiscount'
][
'list'
][]
=
$build
;
}
// 促销信息
if
(
isset
(
$baseInfo
[
'promotionBoList'
]))
{
$build
=
array
();
foreach
(
$baseInfo
[
'promotionBoList'
]
as
$value
)
{
$build
[
'text'
]
=
'【'
.
$value
[
'promotionType'
]
.
'】'
.
$value
[
'promotionTitle'
];
$result
[
'goodsDiscount'
][
'list'
][]
=
$build
;
}
}
$result
[
'feedbacks'
]
=
array
();
// 商品咨询
$result
[
'feedbacks'
][
'consultsNum'
]
=
0
;
if
(
!
empty
(
$baseInfo
[
'consultBoWrapper'
]))
{
$result
[
'feedbacks'
][
'consultsNum'
]
=
$baseInfo
[
'consultBoWrapper'
][
'consultTotal'
];
$result
[
'feedbacks'
][
'consults'
]
=
array
();
$build
=
array
();
foreach
(
$baseInfo
[
'consultBoWrapper'
][
'consultBoList'
]
as
$value
)
{
$build
[
'question'
]
=
$value
[
'ask'
];
$build
[
'time'
]
=
$value
[
'askTime'
];
$build
[
'answer'
]
=
$value
[
'answer'
];
$result
[
'feedbacks'
][
'consults'
][]
=
$build
;
}
$result
[
'feedbacks'
][
'consultsUrl'
]
=
Helpers
::
url
(
'/product/detail/consults'
,
array
(
'product_id'
=>
$productId
,
'total'
=>
$result
[
'feedbacks'
][
'consultsNum'
]));
}
// 暂无咨询
else
{
$result
[
'feedbacks'
][
'consultsUrl'
]
=
Helpers
::
url
(
'/product/detail/consultform'
,
array
(
'product_id'
=>
$productId
));
$result
[
'feedbacks'
]
=
array
();
// 商品咨询
$result
[
'feedbacks'
][
'consultsNum'
]
=
0
;
if
(
!
empty
(
$baseInfo
[
'consultBoWrapper'
]))
{
$result
[
'feedbacks'
][
'consultsNum'
]
=
$baseInfo
[
'consultBoWrapper'
][
'consultTotal'
];
$result
[
'feedbacks'
][
'consults'
]
=
array
();
$build
=
array
();
foreach
(
$baseInfo
[
'consultBoWrapper'
][
'consultBoList'
]
as
$value
)
{
$build
[
'question'
]
=
$value
[
'ask'
];
$build
[
'time'
]
=
$value
[
'askTime'
];
$build
[
'answer'
]
=
$value
[
'answer'
];
$result
[
'feedbacks'
][
'consults'
][]
=
$build
;
}
$result
[
'feedbacks'
][
'consultsUrl'
]
=
Helpers
::
url
(
'/product/detail/consults'
,
array
(
'product_id'
=>
$productId
,
'total'
=>
$result
[
'feedbacks'
][
'consultsNum'
]));
}
// 暂无咨询
else
{
$result
[
'feedbacks'
][
'consultsUrl'
]
=
Helpers
::
url
(
'/product/detail/consultform'
,
array
(
'product_id'
=>
$productId
));
}
// 商品评价
$result
[
'feedbacks'
][
'commentsNum'
]
=
0
;
if
(
!
empty
(
$baseInfo
[
'commentBoWrapper'
]))
{
$result
[
'feedbacks'
][
'commentsNum'
]
=
$baseInfo
[
'commentBoWrapper'
][
'commentTotal'
];
$result
[
'feedbacks'
][
'comments'
]
=
array
();
$build
=
array
();
foreach
(
$baseInfo
[
'commentBoWrapper'
][
'commentBoList'
]
as
$value
)
{
$build
[
'userName'
]
=
$value
[
'nickName'
];
$build
[
'desc'
]
=
$value
[
'colorName'
]
.
'/'
.
$value
[
'sizeName'
];
$build
[
'content'
]
=
isset
(
$value
[
'content'
])
?
$value
[
'content'
]
:
''
;
$build
[
'time'
]
=
$value
[
'createTime'
];
$result
[
'feedbacks'
][
'comments'
][]
=
$build
;
}
$result
[
'feedbacks'
][
'commentsUrl'
]
=
Helpers
::
url
(
'/product/detail/comments'
,
array
(
'product_id'
=>
$productId
,
'total'
=>
$result
[
'feedbacks'
][
'commentsNum'
]));
// 商品评价
$result
[
'feedbacks'
][
'commentsNum'
]
=
0
;
if
(
!
empty
(
$baseInfo
[
'commentBoWrapper'
]))
{
$result
[
'feedbacks'
][
'commentsNum'
]
=
$baseInfo
[
'commentBoWrapper'
][
'commentTotal'
];
$result
[
'feedbacks'
][
'comments'
]
=
array
();
$build
=
array
();
foreach
(
$baseInfo
[
'commentBoWrapper'
][
'commentBoList'
]
as
$value
)
{
$build
[
'userName'
]
=
$value
[
'nickName'
];
$build
[
'desc'
]
=
$value
[
'colorName'
]
.
'/'
.
$value
[
'sizeName'
];
$build
[
'content'
]
=
isset
(
$value
[
'content'
])
?
$value
[
'content'
]
:
''
;
$build
[
'time'
]
=
$value
[
'createTime'
];
$result
[
'feedbacks'
][
'comments'
][]
=
$build
;
}
$result
[
'feedbacks'
][
'commentsUrl'
]
=
Helpers
::
url
(
'/product/detail/comments'
,
array
(
'product_id'
=>
$productId
,
'total'
=>
$result
[
'feedbacks'
][
'commentsNum'
]));
}
// 品牌信息
if
(
!
empty
(
$baseInfo
[
'brand'
]))
{
$result
[
'enterStore'
]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$baseInfo
[
'brand'
][
'brandIco'
],
47
,
47
),
'storeName'
=>
$baseInfo
[
'brand'
][
'brandName'
],
'url'
=>
Helpers
::
url
(
''
,
array
(),
$baseInfo
[
'brand'
][
'brandDomain'
])
);
// 为你优选的链接
$result
[
'preferenceUrl'
]
=
Helpers
::
url
(
'/product/detail/preference'
,
array
(
'productSkn'
=>
$baseInfo
[
'erpProductId'
],
'brandId'
=>
$baseInfo
[
'brand'
][
'id'
]),
''
);
}
// 品牌信息
if
(
!
empty
(
$baseInfo
[
'brand'
]))
{
$result
[
'enterStore'
]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$baseInfo
[
'brand'
][
'brandIco'
],
47
,
47
),
'storeName'
=>
$baseInfo
[
'brand'
][
'brandName'
],
'url'
=>
Helpers
::
url
(
''
,
array
(),
$baseInfo
[
'brand'
][
'brandDomain'
])
);
// 为你优选的链接
$result
[
'preferenceUrl'
]
=
Helpers
::
url
(
'/product/detail/preference'
,
array
(
'productSkn'
=>
$baseInfo
[
'erpProductId'
],
'brandId'
=>
$baseInfo
[
'brand'
][
'id'
]),
''
);
}
// 商品信息
if
(
!
empty
(
$baseInfo
[
'goodsList'
]))
{
$colorGroup
=
array
();
$sizeGroup
=
array
();
$goodsGroup
=
array
();
$sizeList
=
array
();
$thumbImageList
=
array
();
$colorStorageGroup
=
array
();
// 颜色分组的库存总数集合, 多个之间用/分隔
$sizeStorageStr
=
''
;
// 尺码库存总数集合, 多个之间用/分隔
// 商品信息
if
(
!
empty
(
$baseInfo
[
'goodsList'
]))
{
$colorGroup
=
array
();
$sizeGroup
=
array
();
$goodsGroup
=
array
();
$sizeList
=
array
();
$thumbImageList
=
array
();
$colorStorageGroup
=
array
();
// 颜色分组的库存总数集合, 多个之间用/分隔
$sizeStorageStr
=
''
;
// 尺码库存总数集合, 多个之间用/分隔
$colorStorageNum
=
0
;
$totalStorageNum
=
0
;
// 总库存数
foreach
(
$baseInfo
[
'goodsList'
]
as
$value
)
{
$colorStorageNum
=
0
;
$totalStorageNum
=
0
;
// 总库存数
foreach
(
$baseInfo
[
'goodsList'
]
as
$value
)
{
$colorStorageNum
=
0
;
$sizeStorageStr
=
''
;
// 商品分组
if
(
isset
(
$value
[
'goodsImagesList'
]))
{
foreach
(
$value
[
'goodsImagesList'
]
as
$goods
)
{
$goodsGroup
[]
=
array
(
'goodsId'
=>
$goods
[
'goodsId'
],
'img'
=>
$goods
[
'imageUrl'
],
);
}
}
// 商品的尺码列表
if
(
isset
(
$value
[
'goodsSizeBoList'
]))
{
foreach
(
$value
[
'goodsSizeBoList'
]
as
$size
)
{
$sizeList
[
$value
[
'colorId'
]][]
=
array
(
'id'
=>
$size
[
'id'
],
'skuId'
=>
$size
[
'goodsSizeSkuId'
],
'goodsId'
=>
$size
[
'goodsId'
],
'colorId'
=>
$value
[
'colorId'
],
'name'
=>
$size
[
'sizeName'
],
'sizeNum'
=>
$size
[
'goodsSizeStorageNum'
],
);
$colorStorageNum
+=
intval
(
$size
[
'goodsSizeStorageNum'
]);
$sizeStorageStr
.=
$size
[
'goodsSizeStorageNum'
]
.
'/'
;
$colorStorageGroup
[
$size
[
'sizeName'
]][
$value
[
'colorName'
]]
=
$size
[
'goodsSizeStorageNum'
];
}
// 颜色分组
$colorGroup
[]
=
array
(
'id'
=>
$value
[
'colorId'
],
'skcId'
=>
$value
[
'productSkc'
],
'name'
=>
$value
[
'colorName'
],
'goodsName'
=>
$value
[
'goodsName'
],
'colorNum'
=>
$colorStorageNum
,
'sizeNumStr'
=>
rtrim
(
$sizeStorageStr
,
'/'
),
$sizeStorageStr
=
''
;
// 商品分组
if
(
isset
(
$value
[
'goodsImagesList'
]))
{
foreach
(
$value
[
'goodsImagesList'
]
as
$goods
)
{
$goodsGroup
[]
=
array
(
'goodsId'
=>
$goods
[
'goodsId'
],
'img'
=>
$goods
[
'imageUrl'
],
);
}
}
// 缩略图
$thumbImageList
[]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$value
[
'colorImage'
],
60
,
60
));
// 添加尺码对应的各个颜色的库存量
foreach
(
$sizeList
as
$colorId
=>
$sizeArr
)
{
foreach
(
$sizeArr
as
$key
=>
$value
)
{
$sizeList
[
$colorId
][
$key
][
'colorNumStr'
]
=
implode
(
'/'
,
array_values
(
$colorStorageGroup
[
$value
[
'name'
]]));
}
// 商品的尺码列表
if
(
isset
(
$value
[
'goodsSizeBoList'
]))
{
foreach
(
$value
[
'goodsSizeBoList'
]
as
$size
)
{
$sizeList
[
$value
[
'colorId'
]][]
=
array
(
'id'
=>
$size
[
'id'
],
'skuId'
=>
$size
[
'goodsSizeSkuId'
],
'goodsId'
=>
$size
[
'goodsId'
],
'colorId'
=>
$value
[
'colorId'
],
'name'
=>
$size
[
'sizeName'
],
'sizeNum'
=>
$size
[
'goodsSizeStorageNum'
],
);
$colorStorageNum
+=
intval
(
$size
[
'goodsSizeStorageNum'
]);
$sizeStorageStr
.=
$size
[
'goodsSizeStorageNum'
]
.
'/'
;
$colorStorageGroup
[
$size
[
'sizeName'
]][
$value
[
'colorId'
]]
=
$size
[
'goodsSizeStorageNum'
];
}
// 商品库存总数
$totalStorageNum
+=
$colorStorageNum
;
// 颜色分组
$colorGroup
[]
=
array
(
'id'
=>
$value
[
'colorId'
],
'skcId'
=>
$value
[
'productSkc'
],
'name'
=>
$value
[
'colorName'
],
'goodsName'
=>
$value
[
'goodsName'
],
'colorNum'
=>
$colorStorageNum
,
'sizeNumStr'
=>
rtrim
(
$sizeStorageStr
,
'/'
),
);
}
// 格式化尺码对应的各个颜色分组
foreach
(
$colorGroup
as
$value
)
{
$sizeGroup
[][
'size'
]
=
$sizeList
[
$value
[
'id'
]
];
}
// 缩略图
$thumbImageList
[]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$value
[
'colorImage'
],
60
,
60
));
// 商品图: 多个
if
(
isset
(
$goodsGroup
[
1
]))
{
foreach
(
$goodsGroup
as
$value
)
{
$result
[
'bannerTop'
][
'list'
][]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$value
[
'img'
],
450
,
600
)
);
// 添加尺码对应的各个颜色的库存量
foreach
(
$sizeList
as
$colorId
=>
$sizeArr
)
{
foreach
(
$sizeArr
as
$key
=>
$value
)
{
$sizeList
[
$colorId
][
$key
][
'colorNumStr'
]
=
implode
(
'/'
,
array_values
(
$colorStorageGroup
[
$value
[
'name'
]]));
}
}
// 商品图: 单个
elseif
(
isset
(
$goodsGroup
[
0
]))
{
$result
[
'bannerTop'
]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$goodsGroup
[
0
][
'img'
],
450
,
600
)
);
}
// 商品库存总数
$totalStorageNum
+=
$colorStorageNum
;
}
// 悬浮的购物车信息
$result
[
'cartInfo'
]
=
array
(
'cartUrl'
=>
Helpers
::
url
(
'/cart/index/index'
,
null
),
// 购物车链接
'numInCart'
=>
0
,
'goodsInstore'
=>
$baseInfo
[
'storage'
],
// 库存量
);
$soldOut
=
(
$baseInfo
[
'storage'
]
==
0
)
||
(
$baseInfo
[
'status'
]
==
0
);
$notForSale
=
$baseInfo
[
'attribute'
]
==
2
;
// 显示加入购物车链接
if
(
!
$soldOut
&&
!
$notForSale
)
{
$result
[
'cartInfo'
][
'addToCartUrl'
]
=
Helpers
::
url
(
'/product/buy_'
.
$productId
.
'_'
.
$goodsId
.
'.html'
);
$result
[
'cartInfo'
][
'productId'
]
=
$productId
;
$result
[
'cartInfo'
][
'thumbs'
]
=
$thumbImageList
;
$result
[
'cartInfo'
][
'name'
]
=
isset
(
$result
[
'goodsName'
])
?
$result
[
'goodsName'
]
:
''
;
$result
[
'cartInfo'
][
'price'
]
=
isset
(
$result
[
'goodsPrice'
][
'previousPrice'
])
?
$result
[
'goodsPrice'
][
'previousPrice'
]
:
''
;
$result
[
'cartInfo'
][
'salePrice'
]
=
isset
(
$result
[
'goodsPrice'
][
'currentPrice'
])
?
$result
[
'goodsPrice'
][
'currentPrice'
]
:
''
;
$result
[
'cartInfo'
][
'totalNum'
]
=
$totalStorageNum
;
$result
[
'cartInfo'
][
'colors'
]
=
$colorGroup
;
$result
[
'cartInfo'
][
'sizes'
]
=
$sizeGroup
;
// 格式化尺码对应的各个颜色分组
foreach
(
$colorGroup
as
$value
)
{
$sizeGroup
[][
'size'
]
=
$sizeList
[
$value
[
'id'
]
];
}
// 非卖品
elseif
(
$notForSale
)
{
$result
[
'cartInfo'
][
'notForSale'
]
=
true
;
// 商品图: 多个
if
(
isset
(
$goodsGroup
[
1
]))
{
foreach
(
$goodsGroup
as
$value
)
{
$result
[
'bannerTop'
][
'list'
][]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$value
[
'img'
],
450
,
600
)
);
}
}
// 已售磬
elseif
(
$soldOut
)
{
$result
[
'cartInfo'
][
'soldOut'
]
=
true
;
// 商品图: 单个
elseif
(
isset
(
$goodsGroup
[
0
]))
{
$result
[
'bannerTop'
]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$goodsGroup
[
0
][
'img'
],
450
,
600
)
);
}
}
// 是否收藏
$result
[
'isCollect'
]
=
false
;
if
(
isset
(
$baseInfo
[
'isCollect'
])
&&
$baseInfo
[
'isCollect'
]
===
'Y'
)
{
$result
[
'isCollect'
]
=
true
;
}
// 悬浮的购物车信息
$result
[
'cartInfo'
]
=
array
(
'cartUrl'
=>
Helpers
::
url
(
'/cart/index/index'
,
null
),
// 购物车链接
'numInCart'
=>
0
,
'goodsInstore'
=>
$baseInfo
[
'storage'
],
// 库存量
);
$soldOut
=
(
$baseInfo
[
'storage'
]
==
0
)
||
(
$baseInfo
[
'status'
]
==
0
);
$notForSale
=
$baseInfo
[
'attribute'
]
==
2
;
// 显示加入购物车链接
if
(
!
$soldOut
&&
!
$notForSale
)
{
$result
[
'cartInfo'
][
'addToCartUrl'
]
=
Helpers
::
url
(
'/product/buy_'
.
$productId
.
'_'
.
$goodsId
.
'.html'
);
$result
[
'cartInfo'
][
'productId'
]
=
$productId
;
$result
[
'cartInfo'
][
'thumbs'
]
=
$thumbImageList
;
$result
[
'cartInfo'
][
'name'
]
=
isset
(
$result
[
'goodsName'
])
?
$result
[
'goodsName'
]
:
''
;
$result
[
'cartInfo'
][
'price'
]
=
isset
(
$result
[
'goodsPrice'
][
'previousPrice'
])
?
$result
[
'goodsPrice'
][
'previousPrice'
]
:
''
;
$result
[
'cartInfo'
][
'salePrice'
]
=
isset
(
$result
[
'goodsPrice'
][
'currentPrice'
])
?
$result
[
'goodsPrice'
][
'currentPrice'
]
:
''
;
$result
[
'cartInfo'
][
'totalNum'
]
=
$totalStorageNum
;
$result
[
'cartInfo'
][
'colors'
]
=
$colorGroup
;
$result
[
'cartInfo'
][
'sizes'
]
=
$sizeGroup
;
}
// 非卖品
elseif
(
$notForSale
)
{
$result
[
'cartInfo'
][
'notForSale'
]
=
true
;
}
// 已售磬
elseif
(
$soldOut
)
{
$result
[
'cartInfo'
][
'soldOut'
]
=
true
;
}
// 底部简介的URL链接
$result
[
'introUrl'
]
=
Helpers
::
url
(
'/product/intro_'
.
$baseInfo
[
'erpProductId'
]
.
'/'
.
$baseInfo
[
'cnAlphabet'
]
.
'.html'
,
null
,
''
);
$result
[
'id'
]
=
$productId
;
// 是否收藏
$result
[
'isCollect'
]
=
false
;
if
(
isset
(
$baseInfo
[
'isCollect'
])
&&
$baseInfo
[
'isCollect'
]
===
'Y'
)
{
$result
[
'isCollect'
]
=
true
;
}
// 底部简介的URL链接
$result
[
'introUrl'
]
=
Helpers
::
url
(
'/product/intro_'
.
$baseInfo
[
'erpProductId'
]
.
'/'
.
$baseInfo
[
'cnAlphabet'
]
.
'.html'
,
null
,
''
);
$result
[
'id'
]
=
$productId
;
return
$result
;
}
...
...
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Detail.php
View file @
b7195de
...
...
@@ -47,6 +47,39 @@ class DetailController extends AbstractAction
// 渲染模板
$this
->
_view
->
display
(
'index'
,
$data
);
}
/**
* 商品详情 (SKN)
*
* @param int productSkn
*/
public
function
showAction
()
{
$productSkn
=
$this
->
param
(
'productSkn'
);
if
(
!
is_numeric
(
$productSkn
))
{
$this
->
error
();
}
$uid
=
$this
->
getUid
();
$vipLevel
=
0
;
if
(
isset
(
$this
->
_vip
))
{
$vipLevel
=
Helpers
::
getVipLevel
(
$this
->
_vip
);
}
$data
=
\Product\DetailModel
::
getBaseInfo
(
null
,
null
,
$uid
,
$vipLevel
,
$productSkn
);
if
(
array
()
===
$data
)
{
$this
->
error
();
}
$data
[
'goodsDetailPage'
]
=
true
;
$data
[
'pageFooter'
]
=
true
;
if
(
isset
(
$data
[
'goodsName'
]))
{
$this
->
setTitle
(
$data
[
'goodsName'
]);
}
$this
->
setNavHeader
(
'商品详情'
);
// 渲染模板
$this
->
_view
->
display
(
'index'
,
$data
);
}
/**
* 尺码描述信息
...
...
yohobuy/m.yohobuy.com/configs/routes.index.ini
View file @
b7195de
...
...
@@ -147,6 +147,13 @@ routes.productintro.route.controller = Detail
routes.productintro.route.action
=
Intro
routes.productintro.map.1
=
productSkn
routes.productskn.type
=
"regex"
routes.productskn.match
=
"#/product/show_([0-9]+).html#"
routes.productskn.route.module
=
Product
routes.productskn.route.controller
=
Detail
routes.productskn.route.action
=
Show
routes.productskn.map.1
=
productSkn
; 订单相关
routes.cart.type
=
"rewrite"
routes.cart.match
=
"/home/order/detail$"
...
...
yohobuy/m.yohobuy.com/configs/routes.product.ini
View file @
b7195de
...
...
@@ -20,3 +20,10 @@ routes.productintro.route.module = Product
routes.productintro.route.controller
=
Detail
routes.productintro.route.action
=
Intro
routes.productintro.map.1
=
productSkn
routes.productskn.type
=
"regex"
routes.productskn.match
=
"#/product/show_([0-9]+).html#"
routes.productskn.route.module
=
Product
routes.productskn.route.controller
=
Detail
routes.productskn.route.action
=
Show
routes.productskn.map.1
=
productSkn
...
...
Please
register
or
login
to post a comment