商品url地址优化

This commit is contained in:
gongfuxiang 2022-02-12 18:03:29 +08:00
parent 1e83d63860
commit 64fbd65572
5 changed files with 23 additions and 9 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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']);

View File

@ -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;
}
}
?>

View File

@ -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']);
// 规格