切换导航条
此项目
正在载入...
登录
anyv
/
xkeasy
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
anyv
6 years ago
提交
49357af1320e1d5a9f027dc7bb2724a669c23d7e
1 个父辈
d81a8a05
1 个管道 的构建
通过
耗费 0 秒
5
变更
2
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
33 行增加
和
4 行删除
app/portal/controller/ShopcartController.php
public/themes/simpleboot3/portal/goodsdetails/goods_details.html
app/portal/controller/ShopcartController.php
查看文件 @
49357af
...
...
@@ -22,7 +22,28 @@ class ShopcartController extends WeChatBaseController{
}
/**
* 添加购物车
*/
public
function
add_cart
(){
$goods_id
=
$_POST
[
'goods_id'
];
$uid
=
cmf_get_current_user_id
();
$data
=
Db
::
name
(
'shopping_cart'
)
->
where
(
"uid = "
.
$uid
.
" and goods_id = "
.
$goods_id
)
->
find
();
if
(
$data
){
return
2
;
}
else
{
$arr
[
'goods_id'
]
=
$goods_id
;
$arr
[
'uid'
]
=
$uid
;
$insert
=
Db
::
name
(
'shopping_cart'
)
->
insert
(
$arr
);
if
(
$insert
){
return
1
;
}
else
{
return
3
;
}
}
}
...
...
public/themes/simpleboot3/portal/goodsdetails/goods_details.html
查看文件 @
49357af
...
...
@@ -128,7 +128,7 @@
</div>
</div>
<div
class=
"de_footerRight"
>
<div
class=
"de_footerRight1"
onclick=
"add_cart()"
>
加入购物车
</div>
<div
class=
"de_footerRight1"
onclick=
"add_cart(
{$data.id}
)"
>
加入购物车
</div>
<a
href=
"order_confirm.html"
>
<div
class=
"de_footerRight2"
>
立即购买
</div>
</a>
...
...
@@ -154,8 +154,16 @@
/**
*点击加入购物车
*/
function
add_cart
(){
function
add_cart
(
id
){
$
.
post
(
"{:url('Shopcart/add_cart')}"
,{
goods_id
:
id
},
function
(
data
){
if
(
data
==
2
){
alert
(
'已添加购物车'
);
}
else
if
(
data
==
3
){
alert
(
'添加失败'
);
}
else
if
(
data
==
1
){
alert
(
'添加成功'
);
}
});
}
</script>
</body>
...
...
请
注册
或
登录
后发表评论