From 1947136dc7d1b5ef60f84db7107c1259a5766039 Mon Sep 17 00:00:00 2001 From: gongfuxiang <2499232802@qq.com> Date: Thu, 27 Dec 2018 01:13:50 +0800 Subject: [PATCH] goods --- application/api/controller/Banner.php | 2 +- application/api/controller/Goods.php | 100 ++++++++++++++++++ application/api/controller/Index.php | 2 +- application/api/controller/Navigation.php | 2 +- .../index/view/default/goods/index.html | 4 +- application/service/GoodsService.php | 8 +- .../pages/goods-detail/goods-detail.acss | 10 +- .../pages/goods-detail/goods-detail.axml | 24 +++-- .../alipay/pages/goods-detail/goods-detail.js | 44 +++++--- 9 files changed, 163 insertions(+), 33 deletions(-) create mode 100644 application/api/controller/Goods.php diff --git a/application/api/controller/Banner.php b/application/api/controller/Banner.php index 8b37744b4..39d2d4479 100644 --- a/application/api/controller/Banner.php +++ b/application/api/controller/Banner.php @@ -13,7 +13,7 @@ use app\service\BannerService; class Banner extends Common { /** - * [_initialize 前置操作-继承公共前置方法] + * [__construct 构造方法] * @author Devil * @blog http://gong.gg/ * @version 0.0.1 diff --git a/application/api/controller/Goods.php b/application/api/controller/Goods.php new file mode 100644 index 000000000..8b3a27c49 --- /dev/null +++ b/application/api/controller/Goods.php @@ -0,0 +1,100 @@ +data_post['goods_id'])) + { + return json(DataReturn('参数有误', -1)); + } + + // 获取商品 + $goods_id = intval($this->data_post['goods_id']); + $params = [ + 'where' => [ + 'id' => $goods_id, + 'is_delete_time' => 0, + ], + 'is_photo' => true, + 'is_spec' => true, + 'is_content_app' => true, + ]; + $goods = GoodsService::GoodsList($params); + if(empty($goods[0]) || $goods[0]['is_delete_time'] != 0) + { + return json(DataReturn('商品不存在或已删除', -1)); + } + unset($goods[0]['content_web']); + + // 当前登录用户是否已收藏 + $ret_favor = GoodsService::IsUserGoodsFavor(['goods_id'=>$goods_id, 'user'=>$this->user]); + $goods[0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0; + + // 商品访问统计 + GoodsService::GoodsAccessCountInc(['goods_id'=>$goods_id]); + + // 用户商品浏览 + GoodsService::GoodsBrowseSave(['goods_id'=>$goods_id, 'user'=>$this->user]); + + // 数据返回 + $result = [ + 'goods' => $goods[0], + 'common_order_is_booking' => (int) MyC('common_order_is_booking', 0), + ]; + return json(DataReturn('success', 0, $result)); + } + + /** + * 用户商品收藏 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-07-17 + * @desc description + */ + public function Favor() + { + // 登录校验 + $this->Is_Login(); + + // 开始操作 + $params = $this->data_post; + $params['user'] = $this->user; + $ret = GoodsService::GoodsFavor($params); + return json($ret); + } +} +?> \ No newline at end of file diff --git a/application/api/controller/Index.php b/application/api/controller/Index.php index 342195e9c..e92a99bd6 100755 --- a/application/api/controller/Index.php +++ b/application/api/controller/Index.php @@ -13,7 +13,7 @@ use app\service\GoodsService; class Index extends Common { /** - * [_initialize 前置操作-继承公共前置方法] + * [__construct 构造方法] * @author Devil * @blog http://gong.gg/ * @version 0.0.1 diff --git a/application/api/controller/Navigation.php b/application/api/controller/Navigation.php index c70386346..6dc0c4053 100644 --- a/application/api/controller/Navigation.php +++ b/application/api/controller/Navigation.php @@ -13,7 +13,7 @@ use app\service\AppNavService; class Navigation extends Common { /** - * [_initialize 前置操作-继承公共前置方法] + * [__construct 构造方法] * @author Devil * @blog http://gong.gg/ * @version 0.0.1 diff --git a/application/index/view/default/goods/index.html b/application/index/view/default/goods/index.html index c308fc9a9..95f264409 100755 --- a/application/index/view/default/goods/index.html +++ b/application/index/view/default/goods/index.html @@ -137,8 +137,8 @@