diff --git a/service/Application/Admin/Controller/CommonController.class.php b/service/Application/Admin/Controller/CommonController.class.php
index c1bc560d2..4941b8290 100755
--- a/service/Application/Admin/Controller/CommonController.class.php
+++ b/service/Application/Admin/Controller/CommonController.class.php
@@ -73,34 +73,12 @@ class CommonController extends Controller
*/
protected function ajaxReturn($msg = '', $code = 0, $data = '')
{
- // ajax的时候,success和error错误由当前方法接收
- if(IS_AJAX)
- {
- if(isset($msg['info']))
- {
- // success模式下code=0, error模式下code参数-1
- $result = array('msg'=>$msg['info'], 'code'=>-1, 'data'=>'');
- }
- }
-
- // 默认情况下,手动调用当前方法
- if(empty($result))
- {
- $result = array('msg'=>$msg, 'code'=>$code, 'data'=>$data);
- }
-
- // 错误情况下,防止提示信息为空
- if($result['code'] != 0 && empty($result['msg']))
- {
- $result['msg'] = L('common_operation_error');
- }
-
//清除缓冲区中的内容
ob_clean();
// 输出json
header('Content-Type:application/json; charset=utf-8');
- exit(json_encode($result));
+ exit(json_encode(DataReturn($msg, $code, $data)));
}
/**
diff --git a/service/Application/Common/Common/function.php b/service/Application/Common/Common/function.php
index 665d6e597..2831e0b8d 100755
--- a/service/Application/Common/Common/function.php
+++ b/service/Application/Common/Common/function.php
@@ -8,6 +8,43 @@
* @datetime 2016-12-01T21:51:08+0800
*/
+/**
+ * [DataReturn 公共返回数据]
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 0.0.1
+ * @datetime 2016-12-07T22:03:40+0800
+ * @param [string] $msg [提示信息]
+ * @param [int] $code [状态码]
+ * @param [mixed] $data [数据]
+ * @return [json] [json数据]
+ */
+function DataReturn($msg = '', $code = 0, $data = '')
+{
+ // ajax的时候,success和error错误由当前方法接收
+ if(IS_AJAX)
+ {
+ if(isset($msg['info']))
+ {
+ // success模式下code=0, error模式下code参数-1
+ $result = array('msg'=>$msg['info'], 'code'=>-1, 'data'=>'');
+ }
+ }
+
+ // 默认情况下,手动调用当前方法
+ if(empty($result))
+ {
+ $result = array('msg'=>$msg, 'code'=>$code, 'data'=>$data);
+ }
+
+ // 错误情况下,防止提示信息为空
+ if($result['code'] != 0 && empty($result['msg']))
+ {
+ $result['msg'] = L('common_operation_error');
+ }
+
+ return $result;
+}
/**
* 生成前台页面url地址
diff --git a/service/Application/Common/Conf/config.php b/service/Application/Common/Conf/config.php
index f2e0fcb44..1dd3011f1 100755
--- a/service/Application/Common/Conf/config.php
+++ b/service/Application/Common/Conf/config.php
@@ -14,7 +14,7 @@ return array(
'IS_DEVELOP' => true,
// 显示页面Trace信息
- 'SHOW_PAGE_TRACE' => true,
+ 'SHOW_PAGE_TRACE' => false,
// 允许访问的模块列表
'MODULE_ALLOW_LIST' => array('Admin', 'Api', 'Home'),
diff --git a/service/Application/Common/Lang/zh-cn.php b/service/Application/Common/Lang/zh-cn.php
index 3b9f41338..4758c4b22 100755
--- a/service/Application/Common/Lang/zh-cn.php
+++ b/service/Application/Common/Lang/zh-cn.php
@@ -200,6 +200,8 @@ return array(
'common_confirm_error' => '确认失败',
'common_favor_success' => '收藏成功',
'common_favor_error' => '收藏失败',
+ 'common_join_success' => '加入成功',
+ 'common_join_error' => '加入失败',
'common_value_not_change' => '数据未改变',
'common_gender_tips' => '性别值范围不正确',
@@ -283,6 +285,9 @@ return array(
'common_express_name' => '快递公司',
'common_background_color' => '背景色',
+ 'common_favor_ok_text' => '已收藏',
+ 'common_favor_not_text' => '收藏',
+
// 性别
'common_gender_list' => array(
0 => array('id' => 0, 'name' => '保密', 'checked' => true),
diff --git a/service/Application/Home/Controller/CartController.class.php b/service/Application/Home/Controller/CartController.class.php
index 85c2f5635..27d93bf96 100644
--- a/service/Application/Home/Controller/CartController.class.php
+++ b/service/Application/Home/Controller/CartController.class.php
@@ -2,8 +2,7 @@
namespace Home\Controller;
-use Service\SearchService;
-use Service\BrandService;
+use Service\BuyService;
/**
* 购物车
@@ -25,6 +24,9 @@ class CartController extends CommonController
{
// 调用父类前置方法
parent::_initialize();
+
+ // 是否登录
+ $this->Is_Login();
}
/**
@@ -38,5 +40,21 @@ class CartController extends CommonController
{
$this->display('Index');
}
+
+ /**
+ * 购物车保存
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2018-09-13
+ * @desc description
+ */
+ public function Save()
+ {
+ $params = $_POST;
+ $params['user'] = $this->user;
+ $ret = BuyService::CartAdd($params);
+ $this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
+ }
}
?>
\ No newline at end of file
diff --git a/service/Application/Home/Controller/CommonController.class.php b/service/Application/Home/Controller/CommonController.class.php
index 23f37f768..9c6ce66ec 100755
--- a/service/Application/Home/Controller/CommonController.class.php
+++ b/service/Application/Home/Controller/CommonController.class.php
@@ -65,34 +65,12 @@ class CommonController extends Controller
*/
protected function ajaxReturn($msg = '', $code = 0, $data = '')
{
- // ajax的时候,success和error错误由当前方法接收
- if(IS_AJAX)
- {
- if(isset($msg['info']))
- {
- // success模式下code=0, error模式下code参数-1
- $result = array('msg'=>$msg['info'], 'code'=>-1, 'data'=>'');
- }
- }
-
- // 默认情况下,手动调用当前方法
- if(empty($result))
- {
- $result = array('msg'=>$msg, 'code'=>$code, 'data'=>$data);
- }
-
- // 错误情况下,防止提示信息为空
- if($result['code'] != 0 && empty($result['msg']))
- {
- $result['msg'] = L('common_operation_error');
- }
-
//清除缓冲区中的内容
ob_clean();
// 输出json
header('Content-Type:application/json; charset=utf-8');
- exit(json_encode($result));
+ exit(json_encode(DataReturn($msg, $code, $data)));
}
/**
@@ -149,6 +127,10 @@ class CommonController extends Controller
$this->assign('nav_header', $this->nav_header);
$this->assign('nav_footer', $this->nav_footer);
+ // 导航/底部默认显示
+ $this->assign('is_header', 1);
+ $this->assign('is_footer', 1);
+
// 当前页面选择导航状态
$nav_pid = 0;
$nav_id = 0;
diff --git a/service/Application/Home/Controller/GoodsController.class.php b/service/Application/Home/Controller/GoodsController.class.php
index e52995f5e..47a7bf55d 100755
--- a/service/Application/Home/Controller/GoodsController.class.php
+++ b/service/Application/Home/Controller/GoodsController.class.php
@@ -45,6 +45,11 @@ class GoodsController extends CommonController
'is_attribute' => true,
];
$goods = GoodsService::GoodsList($params);
+
+ // 当前登录用户是否已收藏
+ $ret_favor = GoodsService::IsUserGoodsFavor(['goods_id'=>$id, 'user'=>$this->user]);
+ $goods[0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0;
+
$this->assign('goods', $goods[0]);
$this->assign('home_seo_site_title', $goods[0]['title']);
@@ -78,5 +83,25 @@ class GoodsController extends CommonController
$this->display('Index');
}
+
+ /**
+ * 商品收藏
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2018-09-13
+ * @desc description
+ */
+ public function Favor()
+ {
+ // 是否登录
+ $this->Is_Login();
+
+ // 开始处理
+ $params = $_POST;
+ $params['user'] = $this->user;
+ $ret = GoodsService::GoodsFavor($params);
+ $this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
+ }
}
?>
\ No newline at end of file
diff --git a/service/Application/Home/Controller/UserController.class.php b/service/Application/Home/Controller/UserController.class.php
index b1055dceb..f19bf709f 100755
--- a/service/Application/Home/Controller/UserController.class.php
+++ b/service/Application/Home/Controller/UserController.class.php
@@ -175,6 +175,35 @@ class UserController extends CommonController
}
}
+ /**
+ * modal弹窗登录
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2018-09-13
+ * @desc description
+ */
+ public function ModalLoginInfo()
+ {
+ $this->assign('is_header', 0);
+ $this->assign('is_footer', 0);
+
+ if(MyC('home_user_login_state') == 1)
+ {
+ if(empty($this->user))
+ {
+ $this->assign('referer_url', $this->GetrefererUrl());
+ $this->display('ModalLoginInfo');
+ } else {
+ $this->assign('msg', L('common_login_already_had_tips'));
+ $this->display('/Public/TipsError');
+ }
+ } else {
+ $this->assign('msg', L('common_close_user_login_tips'));
+ $this->display('/Public/TipsError');
+ }
+ }
+
/**
* [Reg 用户注册-数据添加]
* @author Devil
diff --git a/service/Application/Home/View/Default/Goods/Index.html b/service/Application/Home/View/Default/Goods/Index.html
index a4cca52f4..6ad8c3150 100755
--- a/service/Application/Home/View/Default/Goods/Index.html
+++ b/service/Application/Home/View/Default/Goods/Index.html
@@ -12,7 +12,7 @@