Browse Source

商品详情

lizhen_gitee 4 months ago
parent
commit
a2f6e8cce7

+ 4 - 1
addons/shopro/controller/goods/Goods.php

@@ -52,6 +52,8 @@ class Goods extends Common
 
 //        $goods = $service->paginate();
         $goods = $service->select_autopage();
+        $goods = collection($goods)->toArray();
+        $goods = list_domain_image($goods,['image']);
 
         $this->success('获取成功', $goods);
     }
@@ -109,7 +111,7 @@ class Goods extends Common
             return $goods;
         });
 
-        $goods = $service->show()->activity($activity_id)->with(['max_sku_price' => function ($query) {      // 计算价格区间用(不知道为啥 with 必须再 show 后面)
+        $goods = $service->field('*,price as pricemin')->show()->activity($activity_id)->with(['max_sku_price' => function ($query) {      // 计算价格区间用(不知道为啥 with 必须再 show 后面)
             $query->where('status', 'up');
         }, 'favorite'])->where('id', $id)->find();
         if (!$goods) {
@@ -123,6 +125,7 @@ class Goods extends Common
         $skuPrices = $goods['new_sku_prices'];
         $content = $goods['content'];
         $goods = $goods->toArray();
+        $goods['image'] = localpath_to_netpath($goods['image']);
         $goods['images'] = array_domain_image($goods['images']);
         $goods['sku_prices'] = $skuPrices;
         $goods['content'] = $content;

+ 4 - 2
addons/shopro/service/goods/GoodsService.php

@@ -239,7 +239,7 @@ class GoodsService
         // 默认排序
         $this->order();
 
-        $goods = $this->query->field('id,image,title,price as pricemin,is_sku,status,type,dispatch_type')
+        $goods = $this->query->field('id,image,title,price,price as pricemin,is_sku,status,type,dispatch_type')
 //                    ->cache($this->getCacheKey($is_cache), (200 + mt_rand(0, 100)))
                     ->autopage()
                     ->select();
@@ -296,7 +296,9 @@ class GoodsService
     public function find($is_cache = false)
     {
         $this->md5s[] = 'find';
-        $goods = $this->query->cache($this->getCacheKey($is_cache), (200 + mt_rand(0, 100)))->find();
+        $goods = $this->query
+//            ->cache($this->getCacheKey($is_cache), (200 + mt_rand(0, 100)))
+            ->find();
 
         if ($goods && $this->format instanceof \Closure) {
             // 格式化数据

+ 0 - 4
application/admin/model/shopro/goods/Goods.php

@@ -119,10 +119,6 @@ class Goods extends Common
         return isset($list[$value]) ? $list[$value] : '';
     }
 
-    public function getImageAttr($value, $data)
-    {
-        return localpath_to_netpath($value);
-    }
 
     //最低价格,金钱格式,而不是数组格式
     public function getPriceminAttr($value, $data)