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
hf
9 years ago
Commit
fc0e3df628557de450993a948706ea30cdeb087f
1 parent
eefba98d
format shopping cart
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
99 deletions
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
yohobuy/m.yohobuy.com/configs/application.preview.ini
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
View file @
fc0e3df
...
...
@@ -9,100 +9,101 @@ use Plugin\Helpers;
*/
class
ShoppingCartController
extends
AbstractAction
{
protected
$_uid
;
/**
* 初始化
*/
public
function
init
()
{
// 检查用户是否登录, 未登录则跳转到登录页
$this
->
_uid
=
$this
->
getUid
();
if
(
!
$this
->
_uid
)
{
$this
->
go
(
Helpers
::
url
(
'/signin.html'
));
}
parent
::
init
();
}
/*
* 首页
*/
protected
$_uid
;
/**
* 通过当前用户审判是否跳到登录
*
* @param int $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
* @return void
*/
protected
function
auditJumpLogin
(
$useSession
=
true
)
{
$uid
=
$this
->
getUid
(
$useSession
);
if
(
!
$uid
)
{
$this
->
go
(
Helpers
::
url
(
'/signin.html'
,
array
(
'refer'
=>
$this
->
server
(
'HTTP_REFERER'
,
SITE_MAIN
))));
}
}
/*
* 首页
*/
public
function
indexAction
()
{
$this
->
setTitle
(
'购物车'
);
$this
->
setNavHeader
(
'购物车'
);
$this
->
setTitle
(
'购物车'
);
$this
->
setNavHeader
(
'购物车'
);
$data
=
array
(
'shoppingCartPage'
=>
true
,
'shoppingCart'
=>
CartModel
::
getCartData
(
$this
->
_uid
)
'shoppingCartPage'
=>
true
,
'shoppingCart'
=>
CartModel
::
getCartData
(
$this
->
_uid
)
);
// 渲染模板
$this
->
_view
->
display
(
'index'
,
$data
);
}
/**
* 移出购物车
*/
public
function
delAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$productId
=
$this
->
post
(
'id'
,
0
);
$result
=
CartModel
::
removeFromCart
(
$this
->
_uid
,
$productId
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 移入收藏夹
*/
public
function
colAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$productId
=
$this
->
post
(
'id'
,
0
);
$result
=
CartModel
::
addToFav
(
$this
->
_uid
,
$productId
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 修改购物车商品数据
*/
public
function
modifyAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$params
=
array
();
$params
[
'old_product_sku'
]
=
$this
->
post
(
'old_product_sku'
,
0
);
$params
[
'new_product_sku'
]
=
$this
->
post
(
'new_product_sku'
,
0
);
$params
[
'buy_number'
]
=
$this
->
post
(
'buy_number'
,
0
);
$params
[
'selected'
]
=
$this
->
post
(
'selected'
,
null
);
$result
=
CartModel
::
modifyCartProduct
(
$this
->
_uid
,
$params
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 移出购物车
*/
public
function
delAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$productId
=
$this
->
post
(
'id'
,
0
);
$result
=
CartModel
::
removeFromCart
(
$this
->
_uid
,
$productId
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 移入收藏夹
*/
public
function
colAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$productId
=
$this
->
post
(
'id'
,
0
);
$result
=
CartModel
::
addToFav
(
$this
->
_uid
,
$productId
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 修改购物车商品数据
*/
public
function
modifyAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$params
=
array
();
$params
[
'old_product_sku'
]
=
$this
->
post
(
'old_product_sku'
,
0
);
$params
[
'new_product_sku'
]
=
$this
->
post
(
'new_product_sku'
,
0
);
$params
[
'buy_number'
]
=
$this
->
post
(
'buy_number'
,
0
);
$params
[
'selected'
]
=
$this
->
post
(
'selected'
,
null
);
$result
=
CartModel
::
modifyCartProduct
(
$this
->
_uid
,
$params
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
public
function
giftAdvanceAction
()
{
...
...
@@ -146,10 +147,11 @@ class ShoppingCartController extends AbstractAction
);
$this
->
_view
->
display
(
'gift-advance'
,
array
(
'giftAdvancePage'
=>
true
,
'pageHeader'
=>
array
(
'navBack'
=>
true
,
'navTitle'
=>
'加价购'
),
'shoppingCart'
=>
$data
));
'navBack'
=>
true
,
'navTitle'
=>
'加价购'
),
'shoppingCart'
=>
$data
));
}
public
function
orderEnsureAction
()
{
public
function
orderEnsureAction
()
{
$data
=
array
(
'orderEnsurePage'
=>
true
,
'orderEnsure'
=>
array
(
...
...
@@ -216,13 +218,13 @@ class ShoppingCartController extends AbstractAction
$this
->
_view
->
display
(
'order-ensure'
,
$data
);
}
/**
* 读取chose-panel内容
*/
public
function
tplAction
()
{
if
(
$this
->
isAjax
())
{
if
(
$this
->
isAjax
())
{
$data
=
file_get_contents
(
'../../../template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml'
);
echo
(
$data
);
...
...
@@ -231,19 +233,20 @@ class ShoppingCartController extends AbstractAction
public
function
goodinfoAction
()
{
$result
=
array
();
$result
=
array
();
if
(
$this
->
isAjax
())
{
$num
=
$this
->
get
(
'buy_num'
,
1
);
$skn
=
$this
->
get
(
'id'
,
1
);
$result
=
CartModel
::
cartProductData
(
$this
->
_uid
,
$skn
,
$num
);
// 测试skn的ID为51172055
$result
[
'num'
]
=
$num
;
$num
=
$this
->
get
(
'buy_num'
,
1
);
$skn
=
$this
->
get
(
'id'
,
1
);
$result
=
CartModel
::
cartProductData
(
$this
->
_uid
,
$skn
,
$num
);
// 测试skn的ID为51172055
$result
[
'num'
]
=
$num
;
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
}
...
...
yohobuy/m.yohobuy.com/configs/application.preview.ini
View file @
fc0e3df
s
[common]
[common]
;;默认项目
application.directory
=
APPLICATION_PATH "/application"
;;website library
...
...
Please
register
or
login
to post a comment