Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHO-ACTIVITY-PHP
·
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
Plain Diff
Browse Files
Authored by
梁志锋
9 years ago
Commit
81660dbc976c88b2c04e9de752216f9a8fb70daf
2 parents
74e6399b
a207ac2c
Merge branch 'develop' of
http://git.dev.yoho.cn/web/yohobuy
into develop
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
85 additions
and
52 deletions
library/Api/Yohobuy.php
library/Plugin/Helpers.php
static/js/cart/order-ensure.js
static/sass/cart/_order-ensure.scss
template/m.yohobuy.com/actions/cart/index/order-ensure.phtml
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
library/Api/Yohobuy.php
View file @
81660db
...
...
@@ -29,9 +29,9 @@ class Yohobuy
const
YOHOBUY_URL
=
'http://www.yohobuy.com/'
;
// /* 测试环境 */
// const API_URL = 'http://testapi.yoho.cn:28078/';
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_URL = 'http://testapi.yoho.cn:28078/';
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
/**
* 私钥列表
...
...
library/Plugin/Helpers.php
View file @
81660db
...
...
@@ -561,9 +561,10 @@ class Helpers
*
* @param array $cartGoods 购物车商品列表
* @param boolean $isValid 是否是可用商品(非失效商品),默认是
* @param bool $isAdvanceCart 是否是预售购物车(和上市期有关)
* @return array 处理之后的购物车商品数据
*/
public
static
function
formatCartGoods
(
$cartGoods
,
$isValid
=
true
)
public
static
function
formatCartGoods
(
$cartGoods
,
$is
AdvanceCart
,
$is
Valid
=
true
)
{
$arr
=
array
();
...
...
@@ -592,7 +593,7 @@ class Helpers
$oneGoods
[
'isAdvanceBuy'
]
=
true
;
}
// 上市期
if
(
!
empty
(
$value
[
'expect_arrival_time'
]))
{
if
(
$isAdvanceCart
&&
!
empty
(
$value
[
'expect_arrival_time'
]))
{
$oneGoods
[
'appearDate'
]
=
$value
[
'expect_arrival_time'
];
}
// 商品链接
...
...
@@ -628,7 +629,6 @@ class Helpers
$oneGoods
[
'id'
]
=
$single
[
'product_skn'
];
$oneGoods
[
'name'
]
=
$single
[
'product_name'
];
$oneGoods
[
'thumb'
]
=
!
empty
(
$single
[
'goods_images'
])
?
Images
::
getImageUrl
(
$single
[
'goods_images'
],
120
,
160
)
:
''
;
$oneGoods
[
'appearDate'
]
=
'12月'
;
// 目前app接口没有返回该数据
$oneGoods
[
'price'
]
=
self
::
transPrice
(
$single
[
'last_price'
]);
$oneGoods
[
'marketPrice'
]
=
self
::
transPrice
(
$single
[
'market_price'
]);
$oneGoods
[
'count'
]
=
$single
[
'storage_number'
];
...
...
static/js/cart/order-ensure.js
View file @
81660db
...
...
@@ -16,6 +16,7 @@ var dispatchModeHammer,
dispatchTimeHammer
,
$invoice
=
$
(
'.invoice'
),
$price
=
$
(
'.price-cal'
),
$couponUse
=
$
(
'.coupon-use.used'
),
payType
,
priceTmpl
=
Handlebars
.
compile
(
$
(
'#tmpl-price'
).
html
()),
queryString
=
$
.
queryString
(),
...
...
@@ -27,6 +28,11 @@ if (window.getUid() !== orderInfo('uid')) {
order
.
init
();
}
if
(
$couponUse
.
data
(
'value'
)
!==
orderInfo
(
'couponValue'
))
{
orderInfo
(
'couponCode'
,
null
);
orderInfo
(
'couponValue'
,
null
);
}
function
dispacthTapEvt
(
e
)
{
var
$cur
=
$
(
e
.
target
).
closest
(
'li'
);
...
...
@@ -110,9 +116,24 @@ function orderCompute() {
}
function
submitOrder
()
{
if
(
orderInfo
(
'invoice'
)
&&
!
orderInfo
(
'invoiceText'
))
{
tip
.
show
(
'请输入发票抬头'
);
return
;
var
invoiceText
=
$invoice
.
find
(
'[name="invoice-title"]'
).
val
()
||
orderInfo
(
'invoiceText'
),
msg
=
$
(
'#msg'
).
find
(
'input'
).
val
()
||
orderInfo
(
'msg'
);
if
(
orderInfo
(
'invoice'
))
{
if
(
!
invoiceText
)
{
tip
.
show
(
'请输入发票抬头'
);
return
;
}
if
(
invoiceText
.
length
>
30
)
{
tip
.
show
(
'发票抬头不得超过30个汉字'
);
return
;
}
}
if
(
msg
)
{
if
(
msg
.
length
>
40
)
{
tip
.
show
(
'留言不得超过40个汉字'
);
return
;
}
}
loading
.
showLoadingMask
();
$
.
ajax
({
...
...
@@ -123,9 +144,9 @@ function submitOrder() {
cartType
:
queryString
.
cartType
||
queryString
.
carttype
||
'ordinary'
,
deliveryId
:
orderInfo
(
'deliveryId'
),
deliveryTimeId
:
orderInfo
(
'deliveryTimeId'
),
invoiceText
:
$invoice
.
find
(
'[name="invoice-title"]'
).
val
()
||
orderInfo
(
'invoiceText'
)
,
invoiceText
:
invoiceText
,
invoiceType
:
$invoice
.
find
(
'.invoice-type'
).
val
()
||
orderInfo
(
'invoiceType'
),
msg
:
$
(
'#msg'
).
find
(
'input'
).
val
()
||
orderInfo
(
'msg'
)
,
msg
:
msg
,
paymentTypeId
:
orderInfo
(
'paymentTypeId'
),
paymentType
:
orderInfo
(
'paymentType'
),
//支付方式
couponCode
:
orderInfo
(
'couponCode'
),
...
...
@@ -198,7 +219,7 @@ $invoice.find('[name="invoice-title"]').on('blur', function() {
orderInfo
(
'invoiceType'
,
$
(
this
).
val
());
});
$
(
'#msg'
).
find
(
'
input
'
).
on
(
'blur'
,
function
()
{
$
(
'#msg'
).
find
(
'
textarea
'
).
on
(
'blur'
,
function
()
{
orderInfo
(
'msg'
,
$
(
this
).
val
());
});
...
...
static/sass/cart/_order-ensure.scss
View file @
81660db
...
...
@@ -166,19 +166,26 @@
}
}
.block
input
{
box-sizing
:
border-box
;
margin
:
pxToRem
(
20px
)
0
;
padding
:
0
pxToRem
(
12px
);
width
:
100%
;
height
:
pxToRem
(
60px
);
color
:
#444
;
background
:
#efefef
;
font-size
:
pxToRem
(
16px
);
line-height
:
1
;
outline
:
0
;
border
:
0
;
@include
border-radius
(
4px
);
.block
{
input
,
textarea
{
box-sizing
:
border-box
;
margin
:
pxToRem
(
20px
)
0
;
padding
:
0
pxToRem
(
12px
);
width
:
100%
;
height
:
pxToRem
(
60px
);
color
:
#444
;
background
:
#efefef
;
font-size
:
pxToRem
(
16px
);
line-height
:
1
;
outline
:
0
;
border
:
0
;
@include
border-radius
(
4px
);
}
textarea
{
padding
:
pxToRem
(
12px
);
height
:
auto
;
resize
:
none
;
}
}
#invoice
{
...
...
template/m.yohobuy.com/actions/cart/index/order-ensure.phtml
View file @
81660db
...
...
@@ -50,7 +50,7 @@
</span>
{
{#if
value
}
}
<span
class=
"used coupon-use"
>
<span
class=
"used coupon-use"
data-value=
"{{value}}"
>
-¥
{
{value
}
}
<i
class=
"iconfont"
>
614
;</i>
</span>
...
...
@@ -77,7 +77,7 @@
<span
class=
"title"
>发票</span>
<span
class=
"iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"
></span>
<form
id=
"invoice"
>
<input
type=
"text"
name=
"invoice-title"
value=
"{{invoiceText}}"
placeholder=
"发票抬头"
>
<input
type=
"text"
name=
"invoice-title"
value=
"{{invoiceText}}"
maxlength=
"30"
placeholder=
"发票抬头"
>
<label>
发票类型
<select
class=
"invoice-type"
name=
"invoice-type"
>
...
...
@@ -92,7 +92,7 @@
</ul>
<form
id=
"msg"
action=
""
method=
"post"
>
<
input
type=
"text"
name=
"msg"
value=
"{{msg}}"
placeholder=
"留言"
>
<
textarea
name=
"msg"
rows=
"2"
maxlength=
"40"
placeholder=
"留言"
>
{
{msg
}
}</textarea
>
</form>
</section>
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
81660db
...
...
@@ -103,7 +103,7 @@ class CartModel
/* 普通购物车 */
$result
[
'commonGoodsCount'
]
=
$ordinaryCount
;
$result
[
'commonCart'
]
=
self
::
procCartData
(
$cart
[
'ordinary_cart_data'
],
$onlyGift
,
$onlyAdvanceBuy
);
$result
[
'commonCart'
]
=
self
::
procCartData
(
$cart
[
'ordinary_cart_data'
],
$onlyGift
,
$onlyAdvanceBuy
,
false
);
/* 预售购物车 */
$result
[
'presellGoodsCount'
]
=
$advanceCount
;
$result
[
'preSellCart'
]
=
self
::
procCartData
(
$cart
[
'advance_cart_data'
],
$onlyGift
,
$onlyAdvanceBuy
);
...
...
@@ -722,15 +722,16 @@ class CartModel
* @param array $data 不同类型购物车数据
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @param bool $isAdvanceCart 是否是预售购物车,默认是,(和上市期有关)
* @return array $result 处理之后的不同类型购物车数据
*/
private
static
function
procCartData
(
$data
,
$onlyGift
=
false
,
$onlyAdvanceBuy
=
false
)
private
static
function
procCartData
(
$data
,
$onlyGift
=
false
,
$onlyAdvanceBuy
=
false
,
$isAdvanceCart
=
true
)
{
$result
=
array
();
do
{
// 数据为空时返回空的标志
if
(
empty
(
$data
))
{
if
(
empty
(
$data
[
'goods_list'
]
))
{
break
;
}
...
...
@@ -746,13 +747,13 @@ class CartModel
}
// 购买的可用商品列表
$validGoods
=
Helpers
::
formatCartGoods
(
$data
[
'goods_list'
]);
$validGoods
=
Helpers
::
formatCartGoods
(
$data
[
'goods_list'
]
,
$isAdvanceCart
);
if
(
!
empty
(
$validGoods
))
{
$result
[
'goods'
]
=
$validGoods
;
}
// 失效商品列表
$notValidGoods
=
Helpers
::
formatCartGoods
(
$data
[
'sold_out_goods_list'
],
false
);
$notValidGoods
=
Helpers
::
formatCartGoods
(
$data
[
'sold_out_goods_list'
],
$isAdvanceCart
,
false
);
if
(
!
empty
(
$notValidGoods
))
{
$result
[
'notValidGoods'
]
=
$notValidGoods
;
}
...
...
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
View file @
81660db
...
...
@@ -34,10 +34,12 @@ class DetailModel
$baseInfo
=
DetailData
::
baseInfo
(
$productId
,
$uid
);
// 商品名称
if
(
isset
(
$baseInfo
[
'productName'
]))
{
$result
[
'goodsName'
]
=
$baseInfo
[
'productName'
];
if
(
empty
(
$baseInfo
[
'productName'
]))
{
return
$result
;
}
$result
[
'goodsName'
]
=
$baseInfo
[
'productName'
];
// 商品促销短语
if
(
!
empty
(
$baseInfo
[
'salesPhrase'
]))
{
$result
[
'goodsSubtitle'
]
=
$baseInfo
[
'salesPhrase'
];
...
...
@@ -159,12 +161,12 @@ class DetailModel
$thumbImageList
=
array
();
$colorStorageGroup
=
array
();
// 颜色分组的库存总数集合, 多个之间用/分隔
$sizeStorageStr
=
''
;
// 尺码库存总数集合, 多个之间用/分隔
$colorStorageNum
=
0
;
$colorStorageNum
=
0
;
$totalStorageNum
=
0
;
// 总库存数
foreach
(
$baseInfo
[
'goodsList'
]
as
$value
)
{
$colorStorageNum
=
0
;
$sizeStorageStr
=
''
;
// 商品分组
if
(
isset
(
$value
[
'goodsImagesList'
]))
{
foreach
(
$value
[
'goodsImagesList'
]
as
$goods
)
{
...
...
@@ -178,7 +180,7 @@ class DetailModel
// 商品的尺码列表
if
(
isset
(
$value
[
'goodsSizeBoList'
]))
{
foreach
(
$value
[
'goodsSizeBoList'
]
as
$size
)
{
$sizeList
[
$value
[
'colorId'
]
][]
=
array
(
$sizeList
[
$value
[
'colorId'
]
][]
=
array
(
'id'
=>
$size
[
'id'
],
'skuId'
=>
$size
[
'goodsSizeSkuId'
],
'goodsId'
=>
$size
[
'goodsId'
],
...
...
@@ -188,9 +190,9 @@ class DetailModel
);
$colorStorageNum
+=
intval
(
$size
[
'goodsSizeStorageNum'
]);
$sizeStorageStr
.=
$size
[
'goodsSizeStorageNum'
]
.
'/'
;
$colorStorageGroup
[
$size
[
'sizeName'
]
][
$value
[
'colorName'
]
]
=
$size
[
'goodsSizeStorageNum'
];
$colorStorageGroup
[
$size
[
'sizeName'
]][
$value
[
'colorName'
]
]
=
$size
[
'goodsSizeStorageNum'
];
}
// 颜色分组
$colorGroup
[]
=
array
(
'id'
=>
$value
[
'colorId'
],
...
...
@@ -201,21 +203,24 @@ class DetailModel
'sizeNumStr'
=>
rtrim
(
$sizeStorageStr
,
'/'
),
);
}
// 缩略图
$thumbImageList
[]
=
array
(
'img'
=>
Helpers
::
getImageUrl
(
$value
[
'colorImage'
],
60
,
60
)
);
foreach
(
$sizeList
as
&
$sizeArr
)
{
$sizeArr
[
'colorNumStr'
]
=
implode
(
'/'
,
array_values
(
$colorStorageGroup
[
$sizeArr
[
'name'
]
])
);
$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'
]]));
}
}
// 商品库存总数
$totalStorageNum
+=
$colorStorageNum
;
}
// 统计尺码对应的各个颜色的库存量
// 格式化尺码对应的各个颜色分组
foreach
(
$colorGroup
as
$value
)
{
$sizeGroup
[][
'size'
]
=
$sizeList
[
$value
[
'
colorI
d'
]
];
$sizeGroup
[][
'size'
]
=
$sizeList
[
$value
[
'
i
d'
]
];
}
// 商品图: 多个
...
...
@@ -360,10 +365,9 @@ class DetailModel
foreach
(
$sizeInfo
[
'sizeInfoBo'
][
'sizeBoList'
]
as
$value
)
{
$item
=
array
();
$sizeNameList
[]
=
array
(
'param'
=>
$value
[
'sizeName'
]);
if
(
$boyReference
&&
(
$gender
==
1
||
$gender
==
3
)
)
{
if
(
$boyReference
&&
(
$gender
==
1
||
$gender
==
3
))
{
$referenceList
[]
=
array
(
'param'
=>
empty
(
$value
[
'boyReferSize'
][
'referenceName'
])
?
' '
:
$value
[
'boyReferSize'
][
'referenceName'
]);
}
elseif
(
$girlReference
&&
(
$gender
==
2
||
$gender
==
3
)
)
{
}
elseif
(
$girlReference
&&
(
$gender
==
2
||
$gender
==
3
))
{
$referenceList
[]
=
array
(
'param'
=>
empty
(
$value
[
'girlReferSize'
][
'referenceName'
])
?
' '
:
$value
[
'girlReferSize'
][
'referenceName'
]);
}
foreach
(
$value
[
'sortAttributes'
]
as
$attr
)
{
...
...
Please
register
or
login
to post a comment