Browse Source

改详情图上传方式

牟新芬 4 years ago
parent
commit
710b4279e7

+ 1 - 0
app/api/controller/v1/Index.php

@@ -66,6 +66,7 @@ class Index extends BaseController
     {
         if (!$id || !($storeInfo = Product::getValidProduct($id))) return app('json')->fail('商品不存在或已下架');
         $storeInfo['slider_image'] = json_decode($storeInfo['slider_image'], true);
+        $storeInfo['detail_image'] = json_decode($storeInfo['detail_image'], true);
         $storeInfo['code_base'] = QrcodeService::getWechatQrcodePath($id . '_product_detail_wap.jpg', '/h5/pages/product/detail?id=' . $id);
         //替换windows服务器下正反斜杠问题导致图片无法显示
         $storeInfo['description'] = preg_replace_callback('#<img.*?src="([^"]*)"[^>]*>#i', function ($imagsSrc) {

+ 1 - 1
app/model/api/Product.php

@@ -52,7 +52,7 @@ class Product extends Model
         return $list;
     }
 
-    public static function getValidProduct($productId, $field = 'add_time,browse,cate_id,code_path,cost,ficti,id,image,is_sub,is_best,is_del,is_hot,is_show,keyword,ot_price,postage,price,(price-ot_price) as commission,sales,slider_image,sort,stock,store_info,store_name,unit_name,vip_price,spec_type,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,video_link,description')
+    public static function getValidProduct($productId, $field = 'add_time,browse,cate_id,code_path,cost,ficti,id,image,is_sub,is_best,is_del,is_hot,is_show,keyword,ot_price,postage,price,(price-ot_price) as commission,sales,slider_image,detail_image,sort,stock,store_info,store_name,unit_name,vip_price,spec_type,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,video_link,description')
     {
         $Product = self::where('is_del', 0)->where('is_show', 1)->where('id', $productId)->field($field)->find();
         if ($Product) return $Product->toArray();

+ 4 - 0
app/system/controller/v1/Product.php

@@ -180,6 +180,7 @@ class Product extends BaseController
             }
             $productInfo['postage'] = floatval($productInfo['postage']);
             $productInfo['slider_image'] = is_string($productInfo['slider_image']) ? json_decode($productInfo['slider_image'], true) : [];
+            $productInfo['detail_image'] = is_string($productInfo['detail_image']) ? json_decode($productInfo['detail_image'], true) : [];
             if ($productInfo['spec_type'] == 1) {
                 $result = ProductAttrResult::getResult($id);
                 foreach ($result['value'] as $k => $v) {
@@ -237,10 +238,12 @@ class Product extends BaseController
             ['image', []],
             ['slider_image', []],
             ['video_link', ''],
+            ['detail_image', []],
             ['spec_type', 0],
             ['ficti', 100],
             ['sales', 0],
             ['sort', 0],
+            'label',
             ['is_show', 0],
             ['packet', 0],
             ['issuing', 0],
@@ -266,6 +269,7 @@ class Product extends BaseController
         if (empty($data['image'])) return app('json')->fail('请上传商品图片');
         if (count($data['slider_image']) < 1) return app('json')->fail('请上传商品轮播图');
         $data['slider_image'] = json_encode($data['slider_image']);
+        $data['detail_image'] = json_encode($data['detail_image']);
         $data['stock'] = array_sum(array_column($detail, 'stock'));
         ProductModel::beginTrans();
         foreach ($detail as &$item) {