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
Plain Diff
Browse Files
Authored by
毕凯
9 years ago
Commit
6e07cb767c691680a2cfc9343fdff3dd00e1abe8
2 parents
79c2d2bf
6696759b
增加 cookie 操作
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
33 deletions
static/js/shopping-cart/order-ensure.js
static/js/shopping-cart/order-info.js
static/js/shopping-cart/select-coupon.js
static/sass/shopping-cart/_select-coupon.scss
template/m.yohobuy.com/actions/index/shoppingCart/order-ensure.phtml
template/m.yohobuy.com/actions/index/shoppingCart/select-address.phtml
template/m.yohobuy.com/actions/index/shoppingCart/select-coupon.phtml
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
static/js/shopping-cart/order-ensure.js
View file @
6e07cb7
...
...
@@ -6,9 +6,12 @@
var
$
=
require
(
'jquery'
),
lazyLoad
=
require
(
'yoho.lazyload'
),
Hammer
=
require
(
'yoho.hammer'
);
Hammer
=
require
(
'yoho.hammer'
),
orderInfo
=
require
(
'./order-info'
).
orderInfo
;
var
dispatchModeHammer
,
dispatchTimeHammer
;
var
dispatchModeHammer
,
dispatchTimeHammer
,
$invoice
=
$
(
'.invoice'
);
lazyLoad
();
...
...
@@ -51,3 +54,42 @@ $('.invoice').on('touchend', '.checkbox', function() {
$
(
'.invoice'
).
removeClass
(
'focus'
);
}
});
// 界面点击,状态存 cookie
$
(
'.dispatch-mode'
).
on
(
'touchend'
,
'li'
,
function
()
{
orderInfo
(
'deliveryId'
,
$
(
this
).
data
(
'id'
));
});
$
(
'.dispatch-time'
).
on
(
'touchend'
,
'li'
,
function
()
{
orderInfo
(
'deliveryTimeId'
,
$
(
this
).
data
(
'id'
));
});
$
(
'.coin'
).
on
(
'touchend'
,
function
()
{
var
$this
=
$
(
this
);
if
(
$this
.
find
(
'.checkbox'
).
hasClass
(
'icon-cb-checked'
))
{
orderInfo
(
'yohoCoin'
,
$this
.
data
(
'yoho-coin'
));
}
else
{
orderInfo
(
'yohoCoin'
,
0
);
}
});
$invoice
.
on
(
'touchend'
,
function
()
{
var
$this
=
$
(
this
);
orderInfo
(
'invoice'
,
$this
.
find
(
'.checkbox'
).
hasClass
(
'icon-cb-checked'
));
});
$invoice
.
find
(
'[name="invoice-title"]'
).
on
(
'blur'
,
function
()
{
orderInfo
(
'invoiceText'
,
$
(
this
).
val
());
}).
end
().
find
(
'.invoice-type'
).
on
(
'change'
,
function
()
{
orderInfo
(
'invoiceType'
,
$
(
this
).
val
());
});
$
(
'#msg'
).
find
(
'input'
).
on
(
'blur'
,
function
()
{
orderInfo
(
'msg'
,
$
(
this
).
val
());
});
$
(
'.pay-mode'
).
on
(
'click'
,
'li'
,
function
()
{
orderInfo
(
'paymentTypeId'
,
$
(
this
).
data
(
'pay-id'
));
});
...
...
static/js/shopping-cart/order-info.js
View file @
6e07cb7
...
...
@@ -3,12 +3,11 @@
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var
info
=
window
.
cookie
(
'order-info'
),
orderInfo
;
var
info
=
window
.
cookie
(
'order-info'
);
// info 必须是 JSON 字符串
try
{
info
=
JSON
.
parse
(
orderI
nfo
);
info
=
JSON
.
parse
(
i
nfo
);
}
catch
(
e
)
{
info
=
{};
}
...
...
static/js/shopping-cart/select-coupon.js
View file @
6e07cb7
...
...
@@ -16,14 +16,15 @@ var page = 1,
isGetData
;
var
conponTmpl
=
Handlebars
.
compile
(
$
(
'#tmpl-coupon'
).
html
()),
conponNotAvaliableTmpl
=
Handlebars
.
compile
(
$
(
'#tmpl-coupon-not-avaliable'
).
html
());
conponNotAvaliableTmpl
=
Handlebars
.
compile
(
$
(
'#tmpl-coupon-not-avaliable'
).
html
()),
$newCoupon
=
$
(
'#new-coupon'
);
ellipsis
.
init
();
$
(
'#search-coupon'
)
.
on
(
'submit'
,
function
()
{
$
newCoupon
.
on
(
'submit'
,
function
()
{
$
.
ajax
({
method
:
'POST'
,
url
:
'/shoppingCart/coupon'
,
url
:
'/shoppingCart/coupon
Search
'
,
data
:
$
(
this
).
serialize
()
}).
then
(
function
(
res
)
{
if
(
res
.
code
===
200
)
{
...
...
@@ -39,8 +40,19 @@ $('#search-coupon').on('submit', function() {
return
false
;
});
$
(
'#coupon-list'
).
on
(
'touchend'
,
'employ-main'
,
function
()
{
orderInfo
(
'couponCode'
,
$
(
this
).
data
(
'coupon-code'
));
$
(
'#coupon-list'
).
on
(
'touchend'
,
'.employ-main'
,
function
()
{
var
$this
=
$
(
this
);
orderInfo
(
'couponCode'
,
$this
.
data
(
'coupon-code'
));
orderInfo
(
'couponValue'
,
$this
.
data
(
'coupon-value'
));
});
$newCoupon
.
find
(
'input'
).
on
(
'input'
,
function
()
{
if
(
$
(
this
).
val
()
!==
''
)
{
$newCoupon
.
find
(
'.submit'
).
css
(
'background'
,
'#444'
);
}
else
{
$newCoupon
.
find
(
'.submit'
).
css
(
'background'
,
'#b0b0b0'
);
}
});
function
getCouponHandle
(
coupons
)
{
...
...
@@ -117,7 +129,7 @@ function getCouponDate() {
$
.
ajax
({
type
:
'POST'
,
url
:
'/
home/couponData
'
,
url
:
'/
shoppingCart/couponList
'
,
dataType
:
'json'
,
data
:
{
page
:
page
...
...
static/sass/shopping-cart/_select-coupon.scss
View file @
6e07cb7
...
...
@@ -2,7 +2,7 @@
margin-top
:
pxToRem
(
30px
);
margin-bottom
:
pxToRem
(
30px
);
#
search
-coupon
{
#
new
-coupon
{
margin-bottom
:
pxToRem
(
30px
);
padding-left
:
pxToRem
(
30px
);
padding-right
:
pxToRem
(
30px
);
...
...
template/m.yohobuy.com/actions/index/shoppingCart/order-ensure.phtml
View file @
6e07cb7
...
...
@@ -5,7 +5,7 @@
<p
class=
"infos"
>
收货地址
<span
class=
"per-info"
>
{
{name
}
}
{
{phoneNum
}
}</span>
<span
class=
"address"
>
{
{address
}
}</span>
<span
class=
"address"
>
{
{a
rea
}
}
{
{a
ddress
}
}</span>
</p>
<span
class=
"iconfont"
>
614
;</span>
</a>
...
...
@@ -15,7 +15,7 @@
<h
3
class=
"title"
>配送方式</h
3
>
<ul
class=
"dispatch-mode clearfix"
>
{
{#each
dispatchMode
}
}
<li
{
{#if
@first
}
}class=
"chosed"
{
{/if
}
}
data-id=
"{{id}}"
>
{
{name
}
}</li>
<li
{
{#if
isSelected
}
}class=
"chosed"
{
{/if
}
}
data-id=
"{{id}}"
>
{
{name
}
}</li>
{
{/each
}
}
</ul>
</div>
...
...
@@ -24,7 +24,7 @@
<h
3
class=
"title"
>送货时间</h
3
>
<ul
class=
"dispatch-time clearfix"
>
{
{#each
dispatchTime
}
}
<li
{
{#if
@first
}
}class=
"chosed"
{
{/if
}
}
data-id=
"{{id}}"
>
{
{name
}
}</li>
<li
{
{#if
isSelected
}
}class=
"chosed"
{
{/if
}
}
data-id=
"{{id}}"
>
{
{name
}
}</li>
{
{/each
}
}
</ul>
</div>
...
...
@@ -52,14 +52,14 @@
</span>
{
{/if
}
}
{
{#if
notUsed
}
}
<span
class=
"not-used coupon-use"
>
未使用
{
{#if
value
}
}
<span
class=
"used coupon-use"
>
-¥
{
{value
}
}
<i
class=
"iconfont"
>
614
;</i>
</span>
{
{^
}
}
<span
class=
"used coupon-use"
>
-¥
{
{value
}
}
<span
class=
"not-used coupon-use"
>
未使用
<i
class=
"iconfont"
>
614
;</i>
</span>
{
{/if
}
}
...
...
@@ -68,7 +68,7 @@
{
{/
coupon
}
}
{
{#
yohoCoin
}
}
<li
class=
"coin"
>
<li
class=
"coin"
data-yoho-coin=
"{{.}}"
>
<span
class=
"title"
>YOHO币</span>
<span
class=
"desc"
>可抵用¥
{
{.
}
}</span>
<span
class=
"coin-check"
>
...
...
template/m.yohobuy.com/actions/index/shoppingCart/select-address.phtml
View file @
6e07cb7
...
...
@@ -2,7 +2,7 @@
<div
class=
"my-address-page select-address-page yoho-page"
>
<div
class=
"page-wrap"
>
{
{#
address
}
}
<a
class=
"address-item"
data-address-id=
"{{address_id}}"
href=
"/shoppingCart/orderEnsure
?address_id={{address_id}}
"
>
<a
class=
"address-item"
data-address-id=
"{{address_id}}"
href=
"/shoppingCart/orderEnsure"
>
<span
class=
"name"
>
{
{consignee
}
}</span>
<span
class=
"tel"
>
{
{mobile
}
}</span>
<p
class=
"address-info"
>
{
{area
}
}
{
{address
}
}</p>
...
...
template/m.yohobuy.com/actions/index/shoppingCart/select-coupon.phtml
View file @
6e07cb7
{
{>
layout/header
}
}
<div
class=
"yoho-page select-coupon-page my-coupon-page"
>
<form
id=
"
search
-coupon"
method=
"POST"
action=
""
>
<form
id=
"
new
-coupon"
method=
"POST"
action=
""
>
<input
type=
"text"
name=
"couponCode"
value=
""
placeholder=
"输入优惠券码"
>
<button
type=
"submit"
class=
"submit"
>确定</button>
</form>
...
...
@@ -11,9 +11,9 @@
<script
id=
"tmpl-coupon"
type=
"text/tmpl"
>
\
{
{#coupons
}
}
\
{
{^
notAvailable
}
}
<a
class=
"employ-main"
data-coupon-code=
"{{ coupon_code}}"
href=
"/shoppingCart/orderEnsure?coupon_code={{ coupon_code}}"
>
<span>\
{
{
money
}
}</span>
<p
class=
"coupon-name"
>\
{
{
coupon_name
}
}</p>
<a
class=
"employ-main"
data-coupon-code=
"\{{ couponCode}}"
data-coupon-value=
"\{{ couponValue}}"
href=
"/shoppingCart/orderEnsure"
>
<span>\
{
{
couponValue
}
}</span>
<p
class=
"coupon-name"
>\
{
{
couponDetailInfomation
}
}</p>
<p>有效期:\
{
{
couponValidity
}
}</p>
</a>
\
{
{/
notAvailable
}
}
...
...
@@ -22,8 +22,8 @@
<script
id=
"tmpl-coupon-not-avaliable"
type=
"text/tmpl"
>
\
{
{#
notAvailableCoupons
}
}
<div
class=
"employ-main not-avaliable"
>
<span>\
{
{
money
}
}</span>
<p
class=
"coupon-name"
>\
{
{
coupon_name
}
}</p>
<span>\
{
{
couponValue
}
}</span>
<p
class=
"coupon-name"
>\
{
{
couponDetailInfomation
}
}</p>
<p>有效期:\
{
{
couponValidity
}
}</p>
</div>
\
{
{/
notAvailableCoupons
}
}
...
...
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
View file @
6e07cb7
...
...
@@ -149,7 +149,7 @@ class ShoppingCartController extends AbstractAction
$this
->
setNavHeader
(
'购物车'
);
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
$cookieData
=
$this
->
getCookie
(
'order
I
nfo'
,
null
);
$cookieData
=
$this
->
getCookie
(
'order
-i
nfo'
,
null
);
$uid
=
$this
->
getUid
(
true
);
$data
=
array
(
'orderEnsurePage'
=>
true
,
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
6e07cb7
...
...
@@ -319,7 +319,8 @@ class CartModel
$result
[
'addressId'
]
=
isset
(
$address
[
'address_id'
])
?
$address
[
'address_id'
]
:
$payReturn
[
'delivery_address'
][
'address_id'
];
$result
[
'name'
]
=
isset
(
$address
[
'consignee'
])
?
$address
[
'consignee'
]
:
$payReturn
[
'delivery_address'
][
'consignee'
];
$result
[
'phoneNum'
]
=
isset
(
$address
[
'mobile'
])
?
$address
[
'mobile'
]
:
$payReturn
[
'delivery_address'
][
'mobile'
];
$result
[
'address'
]
=
isset
(
$address
[
'address'
])
?
$address
[
'address'
]
:
$payReturn
[
'delivery_address'
][
'address'
];
$result
[
'area'
]
=
isset
(
$address
[
'area'
])
?
$address
[
'area'
]
:
$payReturn
[
'delivery_address'
][
'area'
];
$result
[
'address'
]
=
isset
(
$address
[
'address'
])
?
$address
[
'address'
]
:
$payReturn
[
'delivery_address'
][
'address'
];
$result
[
'isSupport'
]
=
(
$payReturn
[
'delivery_address'
][
'is_support'
]
===
'Y'
);
}
...
...
@@ -330,9 +331,11 @@ class CartModel
$oneDeliv
=
array
();
$oneDeliv
[
'id'
]
=
$val
[
'delivery_way_id'
];
$oneDeliv
[
'name'
]
=
$val
[
'delivery_way_name'
];
$oneDeliv
[
'default'
]
=
(
$val
[
'default'
]
===
'Y'
);
isset
(
$orderInfo
[
'deliveryId'
])
&&
$orderInfo
[
'deliveryId'
]
===
$oneDeliv
[
'id'
]
&&
$oneDeliv
[
'isSelected'
]
=
true
;
!
isset
(
$oneDeliv
[
'isSelected'
])
&&
$oneDeliv
[
'isSelected'
]
=
(
$val
[
'default'
]
===
'Y'
);
$result
[
'dispatchMode'
][]
=
$oneDeliv
;
}
}
...
...
@@ -411,7 +414,7 @@ class CartModel
// 优惠券数据
$coupons
=
array
(
'notUsed'
=>
true
);
!
empty
(
$orderCompute
[
'coupon_amount'
])
&&
$coupons
[
'
notUsed'
]
=
$orderInfo
[
'couponNam
e'
];
!
empty
(
$orderCompute
[
'coupon_amount'
])
&&
$coupons
[
'
value'
]
=
$orderInfo
[
'couponValu
e'
];
$coupons
+=
self
::
getCouponList
(
$uid
,
0
,
1
,
true
);
$result
[
'coupon'
]
=
$coupons
;
}
...
...
@@ -491,7 +494,7 @@ class CartModel
$val
[
'notAvailable'
]
=
true
;
}
}
!
empty
(
$couponArr
)
&&
$result
[
'coupons'
]
=
$couponArr
;
!
empty
(
$couponArr
)
&&
$result
=
$couponArr
;
}
}
...
...
Please
register
or
login
to post a comment