Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
刘传洋
8 years ago
Commit
1ffa0aa6d55dc0f463fea7da58619fe7bf537337
2 parents
c448918d
a6b83570
Merge branch 'feature/shoppingCart' of
http://git.yoho.cn/fe/yohobuy-node
into feature/shoppingCart
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
91 additions
and
11 deletions
apps/cart/models/order-ensure-api.js
apps/cart/models/order-ensure-handle.js
apps/cart/models/order-ensure.js
apps/cart/views/action/order-ensure2016.hbs
apps/cart/views/partial/ensure-tpl.hbs
public/js/cart/ensure.page.js
public/js/cart/order-new/invoice.js
public/scss/cart/_order-ensure2016.css
apps/cart/models/order-ensure-api.js
View file @
1ffa0aa
...
...
@@ -8,6 +8,15 @@
const
api
=
global
.
yoho
.
API
;
/**
* 获取用户信息API
* @param uid [number] uid
*/
const
getUserProfileAsync
=
(
uid
)
=>
api
.
get
(
''
,
{
method
:
'app.passport.profile'
,
uid
:
uid
});
/**
* 购物车结算API
* @param uid [number] uid
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
...
...
@@ -161,6 +170,7 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p
};
module
.
exports
=
{
getUserProfileAsync
,
getOrderPaymentAsync
,
getUesrCouponAsync
,
getOrderComputeAsync
,
...
...
apps/cart/models/order-ensure-handle.js
View file @
1ffa0aa
...
...
@@ -76,10 +76,18 @@ const handlePaymentInfo = (d, address) => {
d
.
shopping_cart_data
.
hasCoin
=
_
.
round
(
d
.
yoho_coin
*
100
);
// 有货币稀释
let
pskn
=
[],
psku
=
[];
let
pnum
=
0
;
_
.
forEach
(
d
.
goods_list
,
g
=>
{
// link to goods
g
.
linkToGoods
=
helper
.
urlFormat
(
`
/
product
/
pro_$
{
g
.
product_id
}
_$
{
g
.
goods_id
}
/${g.cn_alphabet}.html`
,
''
,
'item'
);
// yas 统计数据
pskn
.
push
(
g
.
product_skn
);
psku
.
push
(
g
.
product_sku
);
pnum
+=
g
.
buy_number
*
1
;
});
resData
.
goodsList
=
d
.
goods_list
;
...
...
@@ -95,7 +103,12 @@ const handlePaymentInfo = (d, address) => {
redEnvelopes
:
d
.
red_envelopes
,
useRedEnvelopes
:
d
.
use_red_envelopes
}),
invoices
:
d
.
invoices
invoices
:
d
.
invoices
,
countData
:
{
pnum
:
pnum
,
pskn
:
pskn
.
join
(
','
),
psku
:
psku
.
join
(
','
)
}
});
return
resData
;
...
...
apps/cart/models/order-ensure.js
View file @
1ffa0aa
...
...
@@ -24,13 +24,18 @@ const index = (uid, cartType) => {
return
Promise
.
all
([
ensureApi
.
getOrderPaymentAsync
(
uid
,
cartType
,
0
),
addressApi
.
getAddressListAsync
(
uid
)
addressApi
.
getAddressListAsync
(
uid
),
ensureApi
.
getUserProfileAsync
(
uid
)
]).
then
(
result
=>
{
let
data
=
_
.
get
(
result
,
'[0].data'
,
false
);
let
address
=
_
.
get
(
result
,
'[1].data'
,
[]);
let
receiver
=
_
.
get
(
result
,
'[2].data.mobile'
,
''
);
if
(
data
)
{
Object
.
assign
(
resData
,
ensureHandle
.
handlePaymentInfo
(
data
,
address
));
Object
.
assign
(
resData
,
ensureHandle
.
handlePaymentInfo
(
data
,
address
),
{
receiverMobile
:
receiver
,
hideReceiverMobile
:
_
.
replace
(
receiver
,
/
(\d{3})\d{4}(\d{4,9})
/
,
'$1****$2'
)
});
}
return
resData
;
...
...
@@ -74,6 +79,7 @@ const submit = (uid, cartType, p) => {
ordercode
:
d
.
order_code
});
}
return
result
;
}
);
...
...
apps/cart/views/action/order-ensure2016.hbs
View file @
1ffa0aa
...
...
@@ -76,7 +76,7 @@
</div>
<div
class=
"goods-wrap"
>
<div
class=
"block-title"
>
订单商品信息
<a
href=
"/cart/cart"
id=
"go-cart-btn"
class=
"right"
>
返回购物车修改
>
</a></div>
<div
class=
"block-title"
>
订单商品信息
<a
href=
"/cart/cart"
class=
"right"
><span
id=
"go-cart-btn"
>
返回购物车修改 >
</span
></a></div>
{{#
with
shoppingCartData
}}
{{#
isY
is_multi_package
}}
<div
class=
"multi-package-row"
>
...
...
@@ -126,7 +126,7 @@
</thead>
<tbody>
{{#
each
goodsList
}}
<tr>
<tr
class=
"goods-item"
>
<td
{{#if
@first
}}
class=
"border-top"
{{/if}}
></td>
<td
class=
"border-top"
>
<a
class=
"image"
href=
"
{{
linkToGoods
}}
"
>
...
...
@@ -260,6 +260,10 @@
</div>
{{/
shoppingCartData
}}
{{#
countData
}}
<p
id=
"hide-count-data"
data-pnum=
"
{{
pnum
}}
"
data-pskn=
"
{{
pskn
}}
"
data-psku=
"
{{
psku
}}
"
></p>
{{/
countData
}}
{{>
ensure-tpl
}}
{{/
content
}}
</div>
...
...
apps/cart/views/partial/ensure-tpl.hbs
View file @
1ffa0aa
...
...
@@ -124,7 +124,7 @@
{{/
each
}}
</div>
</li>
<
li
class
=
"receiver invoice-row"
>
<li class="receiver invoice-row"
data-full="
{{
receiverMobile
}}
" data-hide="
{{
hideReceiverMobile
}}
"
>
<span class="
row
-
title
">
<em>*</em>
手机号码:
...
...
public/js/cart/ensure.page.js
View file @
1ffa0aa
...
...
@@ -33,9 +33,28 @@ var address = require('./order-new/address'),
var
coinTpl
=
Hbs
.
compile
(
$
(
'#yoho-coin-tpl'
).
html
());
var
promotionTpl
=
Hbs
.
compile
(
$
(
'#promotion-list-tpl'
).
html
());
var
yasCountData
=
$
(
'#hide-count-data'
).
data
();
$
(
'#hide-count-data'
).
remove
();
require
(
'../common'
);
require
(
'../simple-header'
);
if
(
!
$
(
'.goods-item'
).
length
)
{
new
dialog
.
Dialog
({
content
:
'暂无可结算商品,请返回购物车重新选择'
,
className
:
'ensure-back-alert'
,
btns
:
[{
id
:
'back-sure'
,
btnClass
:
[
'back-sure'
],
name
:
'返回购物车'
,
cb
:
function
()
{
$
(
'#go-cart-btn'
).
trigger
(
'click'
);
}
}]
}).
show
();
}
order
.
cartType
=
window
.
queryString
().
type
||
1
;
// FE Helper
...
...
@@ -669,12 +688,14 @@ $('#order-submit').click(function() {
content
:
subTip
,
className
:
'ensure-hint-confirm'
,
btns
:
[{
id
:
'hint-sure'
,
btnClass
:
[
'confirm-sure'
],
name
:
'重新选择商品'
,
cb
:
function
()
{
$
(
'#go-cart-btn'
).
trigger
(
'click'
);
}
},
{
id
:
'hint-cancel'
,
btnClass
:
[
'confirm-cancel'
],
name
:
'继续结算'
,
cb
:
function
()
{
...
...
@@ -685,7 +706,10 @@ $('#order-submit').click(function() {
}).
show
();
}
else
{
location
.
href
=
data
.
data
.
url
;
yas
.
givePoint
(
'YB_SC_TOPAY_CLICK'
,
{
ORDER_CODE
:
rdata
.
order_code
,
PRD_NUM
:
yasCountData
.
pnum
,
ORDER_AMOUNT
:
rdata
.
order_amount
,
PRO_SKN
:
yasCountData
.
pskn
,
PRO_SKU
:
yasCountData
.
psku
,
UNIONCOOKIE
:
encodeURIComponent
(
rdata
.
unionKey
+
''
)
||
''
});
location
.
href
=
rdata
.
url
;
}
}
else
if
(
data
.
message
)
{
new
dialog
.
Alert
(
data
.
message
).
show
();
...
...
@@ -699,6 +723,5 @@ multiPackage.init();
coupon
.
init
();
yohoCoin
.
init
();
// 订单确认页默认埋点
yas
.
givePoint
(
'YB_SC_ORDER_ENSURE'
);
...
...
public/js/cart/order-new/invoice.js
View file @
1ffa0aa
...
...
@@ -13,7 +13,8 @@ var $invoiceRadio = $('#invoice-radio');
var
invoiceTpl
=
$
(
'#invoice-chose-tpl'
).
html
();
var
invoiceInfo
=
{};
var
invoiceInfo
=
{},
defaultReceiver
=
{};
function
validateInvoice
(
$el
,
info
)
{
var
pass
=
true
;
...
...
@@ -34,6 +35,8 @@ function validateInvoice($el, info) {
if
(
!
info
.
receiver
)
{
$receiverTip
.
removeClass
(
'hide'
).
find
(
'em'
).
html
(
'请填写手机号码'
);
pass
=
false
;
}
else
if
(
info
.
receiver
===
defaultReceiver
.
hide
)
{
$receiverTip
.
addClass
(
'hide'
);
}
else
if
(
!
/^
[
0-9
]{11}
$/
.
test
(
info
.
receiver
))
{
$receiverTip
.
removeClass
(
'hide'
).
find
(
'em'
).
html
(
'手机号码不正确'
);
pass
=
false
;
...
...
@@ -119,7 +122,7 @@ function bindInvoiceInfo($el, info) {
$
(
'.rbc-'
+
info
.
contentId
,
$el
).
trigger
(
'click'
);
}
$
(
'#receiver-phone'
,
$el
).
val
(
info
.
receiver
||
''
);
$
(
'#receiver-phone'
,
$el
).
val
(
info
.
receiver
||
defaultReceiver
.
hide
||
''
);
}
function
packInvoiceInfo
(
$el
)
{
...
...
@@ -212,6 +215,10 @@ function invoiceEditDialog(baseInfo) {
]
});
if
(
!
defaultReceiver
.
full
)
{
defaultReceiver
=
invoice
.
$el
.
find
(
'.receiver'
).
data
();
}
bindInvoiceEvent
(
invoice
.
$el
);
bindInvoiceInfo
(
invoice
.
$el
,
baseInfo
);
...
...
@@ -247,6 +254,6 @@ exports.getInvoice = function() {
invoicesType
:
invoiceInfo
.
invocesType
,
invoicesTitle
:
invoiceInfo
.
titleName
,
invoicesContent
:
invoiceInfo
.
contentId
,
receiver
:
invoiceInfo
.
receiver
receiver
:
invoiceInfo
.
receiver
===
defaultReceiver
.
hide
?
defaultReceiver
.
full
:
invoiceInfo
.
receiver
};
};
...
...
public/scss/cart/_order-ensure2016.css
View file @
1ffa0aa
...
...
@@ -1101,6 +1101,23 @@
}
}
.ensure-back-alert
{
>
.close
{
display
:
none
;
}
.content
{
padding
:
40px
0
;
}
.back-sure
{
width
:
100px
;
color
:
#fff
;
background-color
:
#000
;
cursor
:
pointer
;
}
}
.ope-address-dialog
{
$
red
:
#d0021b
;
width
:
450px
;
...
...
Please
register
or
login
to post a comment