Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
a047ee34
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
17
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a047ee34
编写于
2月 25, 2018
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
apphtml5: 购物车勾选产品切换active状态
上级
46f7de0e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
180 addition
and
12 deletion
+180
-12
app/appfront/theme/base/front/checkout/cart/index.php
app/appfront/theme/base/front/checkout/cart/index.php
+5
-8
app/apphtml5/modules/Checkout/controllers/CartController.php
app/apphtml5/modules/Checkout/controllers/CartController.php
+49
-0
app/apphtml5/theme/base/html5/checkout/cart/index.php
app/apphtml5/theme/base/html5/checkout/cart/index.php
+76
-4
app/appserver/modules/Checkout/controllers/CartController.php
...appserver/modules/Checkout/controllers/CartController.php
+50
-0
未找到文件。
app/appfront/theme/base/front/checkout/cart/index.php
浏览文件 @
a047ee34
...
...
@@ -303,9 +303,6 @@ $(document).ready(function(){
}
}
$
(
"
.cart_select_all
"
).
attr
(
"
checked
"
,
selectAllChecked
);
currentUrl
=
"
<?=
Yii
::
$service
->
url
->
getUrl
(
'checkout/cart'
)
?>
"
;
updateCartInfoUrl
=
"
<?=
Yii
::
$service
->
url
->
getUrl
(
'checkout/cart/updateinfo'
)
?>
"
;
selectOneProductUrl
=
"
<?=
Yii
::
$service
->
url
->
getUrl
(
'checkout/cart/selectone'
)
?>
"
;
...
...
@@ -341,7 +338,7 @@ $(document).ready(function(){
item_id
:
$item_id
,
up_type
:
"
add_one
"
};
jQuery
.
ajax
({
$
.
ajax
({
async
:
true
,
timeout
:
6000
,
dataType
:
'
json
'
,
...
...
@@ -365,7 +362,7 @@ $(document).ready(function(){
item_id
:
$item_id
,
up_type
:
"
remove
"
};
jQuery
.
ajax
({
$
.
ajax
({
async
:
true
,
timeout
:
6000
,
dataType
:
'
json
'
,
...
...
@@ -390,7 +387,7 @@ $(document).ready(function(){
item_id
:
$item_id
,
checked
:
checked
};
jQuery
.
ajax
({
$
.
ajax
({
async
:
true
,
timeout
:
6000
,
dataType
:
'
json
'
,
...
...
@@ -414,7 +411,7 @@ $(document).ready(function(){
checked
:
checked
};
selectCurrentUrl
=
currentUrl
+
'
?selectall=
'
+
checked
;
jQuery
.
ajax
({
$
.
ajax
({
async
:
true
,
timeout
:
6000
,
dataType
:
'
json
'
,
...
...
@@ -443,7 +440,7 @@ $(document).ready(function(){
alert
(
"
coupon can not empty!
"
);
}
//coupon_url = $("#discount-coupon-form").attr("action");
jQuery
.
ajax
({
$
.
ajax
({
async
:
true
,
timeout
:
6000
,
dataType
:
'
json
'
,
...
...
app/apphtml5/modules/Checkout/controllers/CartController.php
浏览文件 @
a047ee34
...
...
@@ -221,4 +221,53 @@ class CartController extends AppfrontController
$innerTransaction
->
rollBack
();
}
}
public
function
actionSelectone
()
{
$item_id
=
Yii
::
$app
->
request
->
get
(
'item_id'
);
$checked
=
Yii
::
$app
->
request
->
get
(
'checked'
);
$checked
=
$checked
==
1
?
true
:
false
;
$innerTransaction
=
Yii
::
$app
->
db
->
beginTransaction
();
try
{
$status
=
Yii
::
$service
->
cart
->
selectOneItem
(
$item_id
,
$checked
);
if
(
$status
)
{
echo
json_encode
([
'status'
=>
'success'
,
]);
$innerTransaction
->
commit
();
}
else
{
echo
json_encode
([
'status'
=>
'fail'
,
'content'
=>
Yii
::
$service
->
helper
->
errors
->
get
(
','
)
]);
$innerTransaction
->
rollBack
();
}
}
catch
(
Exception
$e
)
{
$innerTransaction
->
rollBack
();
}
}
public
function
actionSelectall
()
{
$checked
=
Yii
::
$app
->
request
->
get
(
'checked'
);
$checked
=
$checked
==
1
?
true
:
false
;
$innerTransaction
=
Yii
::
$app
->
db
->
beginTransaction
();
try
{
$status
=
Yii
::
$service
->
cart
->
selectAllItem
(
$checked
);
if
(
$status
)
{
echo
json_encode
([
'status'
=>
'success'
,
]);
$innerTransaction
->
commit
();
}
else
{
echo
json_encode
([
'status'
=>
'fail'
,
'content'
=>
Yii
::
$service
->
helper
->
errors
->
get
(
','
)
]);
$innerTransaction
->
rollBack
();
}
}
catch
(
Exception
$e
)
{
$innerTransaction
->
rollBack
();
}
}
}
app/apphtml5/theme/base/html5/checkout/cart/index.php
浏览文件 @
a047ee34
...
...
@@ -33,7 +33,7 @@ use fecshop\app\apphtml5\helper\Format;
<?php
foreach
(
$cart_info
[
'products'
]
as
$product_one
)
:
?>
<div
class=
"row"
>
<div
class=
"col-20"
>
<input
<?=
(
$product_one
[
'active'
]
==
Yii
::
$service
->
cart
->
quoteItem
->
activeStatus
)
?
'checked="checked"'
:
''
?>
type=
"checkbox"
name=
"cart_select_item"
class=
"cart_select cart_select_item"
>
<input
rel=
"
<?=
$product_one
[
'item_id'
];
?>
"
<?=
(
$product_one
[
'active'
]
==
Yii
::
$service
->
cart
->
quoteItem
->
activeStatus
)
?
'checked="checked"'
:
''
?>
type=
"checkbox"
name=
"cart_select_item"
class=
"cart_select cart_select_item"
>
<a
external
href=
"
<?=
$product_one
[
'url'
]
?>
"
title=
"
<?=
$product_one
[
'name'
]
?>
"
class=
"product-image"
>
<img
src=
"
<?=
Yii
::
$service
->
product
->
image
->
getResize
(
$product_one
[
'image'
],[
150
,
150
],
false
)
?>
"
alt=
"
<?=
$product_one
[
'name'
]
?>
"
width=
"75"
height=
"75"
>
</a>
...
...
@@ -179,8 +179,32 @@ use fecshop\app\apphtml5\helper\Format;
// add to cart js
<?php
$this
->
beginBlock
(
'changeCartInfo'
)
?>
$
(
document
).
ready
(
function
(){
currentUrl
=
"
<?=
Yii
::
$service
->
url
->
getUrl
(
'checkout/cart'
)
?>
"
updateCartInfoUrl
=
"
<?=
Yii
::
$service
->
url
->
getUrl
(
'checkout/cart/updateinfo'
)
?>
"
// set select all checkbox
selectall
=
"
<?=
Yii
::
$app
->
request
->
get
(
'selectall'
)
?>
"
;
selectAllChecked
=
false
;
if
(
selectall
==
1
)
{
selectAllChecked
=
true
;
}
else
{
item_select_all
=
1
;
$
(
"
.cart_select_item
"
).
each
(
function
(){
checked
=
$
(
this
).
is
(
'
:checked
'
);
if
(
checked
==
false
)
{
item_select_all
=
0
;
}
});
if
(
item_select_all
==
1
)
{
selectAllChecked
=
true
;
}
}
if
(
selectAllChecked
)
{
$
(
"
.cart_select_all
"
).
attr
(
"
checked
"
,
selectAllChecked
);
}
else
{
$
(
"
.cart_select_all
"
).
removeAttr
(
"
checked
"
);
}
currentUrl
=
"
<?=
Yii
::
$service
->
url
->
getUrl
(
'checkout/cart'
)
?>
"
;
updateCartInfoUrl
=
"
<?=
Yii
::
$service
->
url
->
getUrl
(
'checkout/cart/updateinfo'
)
?>
"
;
selectOneProductUrl
=
"
<?=
Yii
::
$service
->
url
->
getUrl
(
'checkout/cart/selectone'
)
?>
"
;
selectAllProductUrl
=
"
<?=
Yii
::
$service
->
url
->
getUrl
(
'checkout/cart/selectall'
)
?>
"
;
$
(
"
.cartqtydown
"
).
click
(
function
(){
$item_id
=
$
(
this
).
attr
(
"
rel
"
);
num
=
$
(
this
).
attr
(
"
num
"
);
...
...
@@ -251,8 +275,56 @@ $(document).ready(function(){
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
){}
});
});
});
$
(
"
.cart_select_item
"
).
click
(
function
(){
$item_id
=
$
(
this
).
attr
(
"
rel
"
);
checked
=
$
(
this
).
is
(
'
:checked
'
);
checked
=
checked
?
1
:
0
;
$data
=
{
item_id
:
$item_id
,
checked
:
checked
};
$
.
ajax
({
async
:
true
,
timeout
:
6000
,
dataType
:
'
json
'
,
type
:
'
get
'
,
data
:
$data
,
url
:
selectOneProductUrl
,
success
:
function
(
data
,
textStatus
){
if
(
data
.
status
==
'
success
'
){
window
.
location
.
href
=
currentUrl
;
}
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
){}
});
});
$
(
"
.cart_select_all
"
).
click
(
function
(){
checked
=
$
(
this
).
is
(
'
:checked
'
);
checked
=
checked
?
1
:
0
;
$data
=
{
checked
:
checked
};
selectCurrentUrl
=
currentUrl
+
'
?selectall=
'
+
checked
;
$
.
ajax
({
async
:
true
,
timeout
:
6000
,
dataType
:
'
json
'
,
type
:
'
get
'
,
data
:
$data
,
url
:
selectAllProductUrl
,
success
:
function
(
data
,
textStatus
){
if
(
data
.
status
==
'
success
'
){
window
.
location
.
href
=
selectCurrentUrl
;
}
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
){}
});
});
$
(
"
.add_coupon_submit
"
).
click
(
function
(){
coupon_code
=
$
(
"
#coupon_code
"
).
val
();
coupon_type
=
$
(
"
.couponType
"
).
val
();
...
...
app/appserver/modules/Checkout/controllers/CartController.php
浏览文件 @
a047ee34
...
...
@@ -362,4 +362,54 @@ class CartController extends AppserverController
return
$reponseData
;
}
public
function
actionSelectone
()
{
$item_id
=
Yii
::
$app
->
request
->
get
(
'item_id'
);
$checked
=
Yii
::
$app
->
request
->
get
(
'checked'
);
$checked
=
$checked
==
1
?
true
:
false
;
$innerTransaction
=
Yii
::
$app
->
db
->
beginTransaction
();
try
{
$status
=
Yii
::
$service
->
cart
->
selectOneItem
(
$item_id
,
$checked
);
if
(
$status
)
{
echo
json_encode
([
'status'
=>
'success'
,
]);
$innerTransaction
->
commit
();
}
else
{
echo
json_encode
([
'status'
=>
'fail'
,
'content'
=>
Yii
::
$service
->
helper
->
errors
->
get
(
','
)
]);
$innerTransaction
->
rollBack
();
}
}
catch
(
Exception
$e
)
{
$innerTransaction
->
rollBack
();
}
}
public
function
actionSelectall
()
{
$checked
=
Yii
::
$app
->
request
->
get
(
'checked'
);
$checked
=
$checked
==
1
?
true
:
false
;
$innerTransaction
=
Yii
::
$app
->
db
->
beginTransaction
();
try
{
$status
=
Yii
::
$service
->
cart
->
selectAllItem
(
$checked
);
if
(
$status
)
{
echo
json_encode
([
'status'
=>
'success'
,
]);
$innerTransaction
->
commit
();
}
else
{
echo
json_encode
([
'status'
=>
'fail'
,
'content'
=>
Yii
::
$service
->
helper
->
errors
->
get
(
','
)
]);
$innerTransaction
->
rollBack
();
}
}
catch
(
Exception
$e
)
{
$innerTransaction
->
rollBack
();
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录