Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
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
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
33b77abf5c895ad67d945038033c4f0073be3112
1 parent
ed0ae0ee
添加商品详情限购码有关逻辑(包括对上部获取限购码按钮以及下部购买按钮状态的处理)
Code Review By Rock Zhang
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
5 deletions
template/m.yohobuy.com/actions/product/detail/index.phtml
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
template/m.yohobuy.com/actions/product/detail/index.phtml
View file @
33b77ab
...
...
@@ -43,7 +43,19 @@
</div>
{
{/
goodsPrice
}
}
<button
class=
"limit-sale"
id='limit-sale'>获取限购码</button>
{
{^
noLimitGoodsBtn
}
}
{
{#if
canGetLimitCode
}
}
<button
class=
"limit-sale"
id='limit-sale'>获取限购码</button>
{
{/if
}
}
{
{#if
codeEmpty
}
}
<button
class=
"got-limit-sale"
>限购码已被抢光</button>
{
{/if
}
}
{
{#if
gotCode
}
}
<button
class=
"got-limit-sale"
>已获限购码</button>
{
{/if
}
}
{
{/noLimitGoodsBtn
}
}
{
{!--
<button
class=
"got-limit-sale"
>已获限购码</button>
}}
...
...
@@ -127,16 +139,29 @@
{
{#if
addToCartUrl
}
}
<!--
<a
id=
"addtoCart"
href=
"{{addToCartUrl}}"
class=
"addto-cart"
>加入购物车</a>
-->
<a
id=
"addtoCart"
href=
"javascript:;"
class=
"addto-cart"
>加入购物车</a>
<a
id=
"addtoCart"
href=
"javascript:;"
class=
"addto-cart"
>加入购物车</a>
{
{/if
}
}
{
{#if
soldOut
}
}
<a
href=
"javascript:;"
class=
"sold-out"
>已售罄</a>
<a
href=
"javascript:;"
class=
"sold-out"
>已售罄</a>
{
{/if
}
}
{
{#if
notForSale
}
}
<a
href=
"javascript:;"
class=
"sold-out"
>非卖品</a>
<a
href=
"javascript:;"
class=
"sold-out"
>非卖品</a>
{
{/if
}
}
{
{#if
limitNotForSale
}
}
<a
href=
"javascript:;"
class=
"sold-out"
>即将开售</a>
{
{/if
}
}
{
{#if
canBuyLimit
}
}
<a
href=
"javascript:;"
class=
"addto-cart"
>立即购买</a>
{
{/if
}
}
{
{#if
noLimitCode
}
}
<a
href=
"javascript:;"
class=
"sold-out"
>立即购买</a>
{
{/if
}
}
<input
type=
"hidden"
name=
"limitCodeUrl"
value=
"{{limitCodeUrl}}"
>
<a
href=
"javascript:;"
id=
"likeBtn"
class=
"favorite iconfont {{#isCollect}}liked{{/isCollect}}"
>
605
;</a>
</div>
...
...
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
View file @
33b77ab
...
...
@@ -23,6 +23,7 @@ class DetailModel
* @param int $productId 商品ID SKN 和 ID 只需要传一个
* @param int $goodsId 某个颜色的商品
* @param int $uid 当前登录用户ID, 未登录为0
* @param int $vipLevel 用户VIP等级
* @param int $productSkn SKN 和 ID 只需要传一个
* @return array
*/
...
...
@@ -288,8 +289,14 @@ class DetailModel
);
$soldOut
=
(
$baseInfo
[
'storage'
]
==
0
)
||
(
$baseInfo
[
'status'
]
==
0
||
$totalStorageNum
===
0
);
$notForSale
=
$baseInfo
[
'attribute'
]
==
2
;
// 是否为限购商品
$isLimited
=
(
$baseInfo
[
'isLimitBuy'
]
===
'Y'
);
// 显示加入购物车链接
if
(
!
$soldOut
&&
!
$notForSale
)
{
if
(
!
$soldOut
&&
!
$notForSale
&&
!
$isLimited
)
{
ksort
(
$colorGroup
,
SORT_NUMERIC
);
$result
[
'cartInfo'
][
'addToCartUrl'
]
=
Helpers
::
url
(
'/product/buy_'
.
$productId
.
'_'
.
$goodsId
.
'.html'
);
...
...
@@ -310,6 +317,21 @@ class DetailModel
elseif
(
$soldOut
)
{
$result
[
'cartInfo'
][
'soldOut'
]
=
true
;
}
// 限购商品
elseif
(
$isLimited
)
{
// 是否开售
$isBeginSale
=
(
isset
(
$baseInfo
[
'saleStatus'
])
&&
$baseInfo
[
'saleStatus'
]
==
1
);
// 限购商品有关的展示状态
$showStatus
=
1
;
if
(
isset
(
$baseInfo
[
'showStatus'
]))
{
$showStatus
=
intval
(
$baseInfo
[
'showStatus'
]);
}
// 处理限购商品有关的按钮状态
self
::
procShowStatus
(
$result
,
$showStatus
,
$isBeginSale
);
$result
[
'cartInfo'
][
'limitCodeUrl'
]
=
'yohobuy://'
.
Helpers
::
url
(
'/product'
,
array
(
'skn'
=>
$baseInfo
[
'erpProductId'
]));
}
// 是否收藏
$result
[
'isCollect'
]
=
false
;
...
...
@@ -715,4 +737,49 @@ class DetailModel
return
$result
;
}
/**
* 处理限购商品的有关按钮状态(或取现购买以及底部商品购买按钮)
*
* @param array $data 需要处理的数据
* @param int $showStatus 限购商品的关联状态
* @param boolean $isBeginSale 限购商品是否已开售
*/
private
static
function
procShowStatus
(
&
$data
,
$showStatus
,
$isBeginSale
)
{
switch
(
$showStatus
)
{
case
1
:
// 开售前/后,立即分享获得限购码(用户未领取限购码)
// 显示获取限购码按钮
$data
[
'canGetLimitCode'
]
=
true
;
if
(
$isBeginSale
)
{
// 开售后
$data
[
'cartInfo'
][
'noLimitCode'
]
=
true
;
}
else
{
$data
[
'cartInfo'
][
'limitNotForSale'
]
=
true
;
}
break
;
case
2
:
// 开售后,限购码已抢光(用户未领取限购码)
$data
[
'codeEmpty'
]
=
true
;
$data
[
'cartInfo'
][
'noLimitCode'
]
=
true
;
break
;
case
3
:
// 开售后,商品已经售罄
$data
[
'noLimitGoodsBtn'
]
=
true
;
$data
[
'cartInfo'
][
'soldOut'
]
=
true
;
break
;
case
4
:
// 开售后,立即购买(用户已领取限购码)
$data
[
'gotCode'
]
=
true
;
$data
[
'cartInfo'
][
'canBuyLimit'
]
=
true
;
break
;
case
5
:
// 开售前,限购码已被抢光(用户未领取限购码)
$data
[
'codeEmpty'
]
=
true
;
$data
[
'cartInfo'
][
'limitNotForSale'
]
=
true
;
break
;
case
6
:
// 开售前,即将开售(用户已领取限购码)
$data
[
'gotCode'
]
=
true
;
$data
[
'cartInfo'
][
'limitNotForSale'
]
=
true
;
break
;
default
:
break
;
}
}
}
...
...
Please
register
or
login
to post a comment