From 64fbd655722607fba443424416f282f3618ea6a1 Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Sat, 12 Feb 2022 18:03:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81url=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Goods.php | 8 ++++---- app/layout/service/BaseLayout.php | 2 +- app/service/BuyService.php | 2 +- app/service/GoodsService.php | 18 ++++++++++++++++-- app/service/OrderService.php | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 0fd3f865c..b2cd2b292 100755 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -53,7 +53,8 @@ class Goods extends Common public function Detail() { // 参数 - if(empty($this->data_post['goods_id'])) + $goods_id = empty($this->data_post['id']) ? (empty($this->data_post['goods_id']) ? 0 : intval($this->data_post['goods_id'])) : intval($this->data_post['id']); + if(empty($goods_id)) { $ret = DataReturn('参数有误', -1); } else { @@ -61,11 +62,10 @@ class Goods extends Common $is_use_mobile_detail = intval(MyC('common_app_is_use_mobile_detail')); // 获取商品 - $goods_id = intval($this->data_post['goods_id']); $params = [ 'where' => [ - 'id' => $goods_id, - 'is_delete_time' => 0, + 'id' => $goods_id, + 'is_delete_time' => 0, ], 'is_photo' => true, 'is_spec' => true, diff --git a/app/layout/service/BaseLayout.php b/app/layout/service/BaseLayout.php index a872264aa..be49d8b7c 100644 --- a/app/layout/service/BaseLayout.php +++ b/app/layout/service/BaseLayout.php @@ -578,7 +578,7 @@ class BaseLayout case 'goods' : if(!empty($value) && !empty($value['id'])) { - $url = ($client_type == 'pc') ? MyUrl('index/goods/index', ['id'=>$value['id']]) : '/pages/goods-detail/goods-detail?goods_id='.$value['id']; + $url = GoodsService::GoodsUrlCreate($value['id']); } break; diff --git a/app/service/BuyService.php b/app/service/BuyService.php index 78d271c0e..5d2412c6d 100755 --- a/app/service/BuyService.php +++ b/app/service/BuyService.php @@ -275,7 +275,7 @@ class BuyService } // 基础信息 - $v['goods_url'] = MyUrl('index/goods/index', ['id'=>$v['goods_id']]); + $v['goods_url'] = GoodsService::GoodsUrlCreate($v['goods_id']); $v['images_old'] = $v['images']; $v['images'] = ResourcesService::AttachmentPathViewHandle($v['images']); $v['total_price'] = PriceNumberFormat($v['stock']* $v['price']); diff --git a/app/service/GoodsService.php b/app/service/GoodsService.php index 08fad5c8f..fe8442bac 100755 --- a/app/service/GoodsService.php +++ b/app/service/GoodsService.php @@ -614,7 +614,7 @@ class GoodsService // 商品url地址 if(!empty($data_id)) { - $v['goods_url'] = MyUrl('index/goods/index', ['id'=>$data_id]); + $v['goods_url'] = self::GoodsUrlCreate($data_id); } // 获取相册 @@ -2978,11 +2978,25 @@ class GoodsService $params = [ 'path' => DS.$path, 'filename' => $filename, - 'content' => MyUrl('index/goods/index', ['id'=>$goods_id], true, true), + 'content' => MyUrl('index/goods/index', ['id'=>$goods_id]), ]; // 创建二维码 return (new \base\Qrcode())->Create($params); } + + /** + * 商品url生成 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2022-02-12 + * @desc description + * @param [int] $goods_id [商品id] + */ + public static function GoodsUrlCreate($goods_id) + { + return (APPLICATION_CLIENT_TYPE == 'pc') ? MyUrl('index/goods/index', ['id'=>$goods_id]) : '/pages/goods-detail/goods-detail?id='.$goods_id; + } } ?> \ No newline at end of file diff --git a/app/service/OrderService.php b/app/service/OrderService.php index 3224ac3a8..56695df9d 100755 --- a/app/service/OrderService.php +++ b/app/service/OrderService.php @@ -1544,7 +1544,7 @@ class OrderService // 商品信息 $vs['images'] = ResourcesService::AttachmentPathViewHandle($vs['images']); - $vs['goods_url'] = MyUrl('index/goods/index', ['id'=>$vs['goods_id']]); + $vs['goods_url'] = GoodsService::GoodsUrlCreate($vs['goods_id']); $vs['total_price'] = PriceNumberFormat($vs['buy_number']*$vs['price']); // 规格