Bläddra i källkod

更新图片水印

evoxwht 4 år sedan
förälder
incheckning
8588d1787b

+ 2 - 0
crmeb/app/services/activity/StoreBargainServices.php

@@ -448,6 +448,8 @@ class StoreBargainServices extends BaseServices
         }
         }
 
 
         $data['bargain'] = get_thumb_water($bargain);
         $data['bargain'] = get_thumb_water($bargain);
+        $bargainNew = get_thumb_water($bargain, 'small');
+        $data['bargain']['small_image'] = $bargainNew['image'];
 
 
         /** @var StoreOrderServices $orderService */
         /** @var StoreOrderServices $orderService */
         $orderService = app()->make(StoreOrderServices::class);
         $orderService = app()->make(StoreOrderServices::class);

+ 2 - 0
crmeb/app/services/activity/StoreCombinationServices.php

@@ -387,6 +387,8 @@ class StoreCombinationServices extends BaseServices
         $qrcodeService = app()->make(QrcodeServices::class);
         $qrcodeService = app()->make(QrcodeServices::class);
         $storeInfo['code_base'] = $qrcodeService->getWechatQrcodePath($id . '_product_combination_detail_wap.jpg', '/pages/activity/goods_combination_details/index?id=' . $id);
         $storeInfo['code_base'] = $qrcodeService->getWechatQrcodePath($id . '_product_combination_detail_wap.jpg', '/pages/activity/goods_combination_details/index?id=' . $id);
         $data['storeInfo'] = get_thumb_water($storeInfo, 'big', ['image', 'images']);
         $data['storeInfo'] = get_thumb_water($storeInfo, 'big', ['image', 'images']);
+        $storeInfoNew = get_thumb_water($storeInfo, 'small');
+        $data['storeInfo']['small_image'] = $storeInfoNew['image'];
 
 
         /** @var StorePinkServices $pinkService */
         /** @var StorePinkServices $pinkService */
         $pinkService = app()->make(StorePinkServices::class);
         $pinkService = app()->make(StorePinkServices::class);

+ 2 - 0
crmeb/app/services/activity/StoreSeckillServices.php

@@ -483,6 +483,8 @@ class StoreSeckillServices extends BaseServices
 
 
         //商品详情
         //商品详情
         $data['storeInfo'] = get_thumb_water($storeInfo, 'big', ['image', 'images']);
         $data['storeInfo'] = get_thumb_water($storeInfo, 'big', ['image', 'images']);
+        $storeInfoNew = get_thumb_water($storeInfo, 'small');
+        $data['storeInfo']['small_image'] = $storeInfoNew['image'];
 
 
         /** @var StoreProductReplyServices $storeProductReplyService */
         /** @var StoreProductReplyServices $storeProductReplyService */
         $storeProductReplyService = app()->make(StoreProductReplyServices::class);
         $storeProductReplyService = app()->make(StoreProductReplyServices::class);

+ 2 - 0
crmeb/app/services/product/product/StoreProductServices.php

@@ -1306,6 +1306,8 @@ class StoreProductServices extends BaseServices
         $data['productAttr'] = $productAttr;
         $data['productAttr'] = $productAttr;
         $data['productValue'] = $productValue;
         $data['productValue'] = $productValue;
         $data['storeInfo'] = get_thumb_water($storeInfo, 'big', ['image', 'slider_image']);
         $data['storeInfo'] = get_thumb_water($storeInfo, 'big', ['image', 'slider_image']);
+        $storeInfoNew = get_thumb_water($storeInfo, 'small', ['image']);
+        $data['storeInfo']['small_image'] = $storeInfoNew['image'];
 
 
         /** @var MemberCardServices $memberCardService */
         /** @var MemberCardServices $memberCardService */
         $memberCardService = app()->make(MemberCardServices::class);
         $memberCardService = app()->make(MemberCardServices::class);

+ 17 - 1
crmeb/crmeb/basic/BaseUpload.php

@@ -11,7 +11,6 @@
 
 
 namespace crmeb\basic;
 namespace crmeb\basic;
 
 
-use crmeb\services\SystemConfigService;
 use think\facade\Config;
 use think\facade\Config;
 
 
 /**
 /**
@@ -85,6 +84,12 @@ abstract class BaseUpload extends BaseStorage
      */
      */
     protected $path = '';
     protected $path = '';
 
 
+    /**
+     * 是否自动裁剪
+     * @var bool
+     */
+    protected $authThumb = true;
+
     protected function initialize(array $config)
     protected function initialize(array $config)
     {
     {
         $this->fileInfo = $this->downFileInfo = new \StdClass();
         $this->fileInfo = $this->downFileInfo = new \StdClass();
@@ -103,6 +108,17 @@ abstract class BaseUpload extends BaseStorage
         return $this;
         return $this;
     }
     }
 
 
+    /**
+     * 是否自动裁剪
+     * @param bool $auth
+     * @return $this
+     */
+    public function setAuthThumb(bool $auth)
+    {
+        $this->authThumb = $auth;
+        return $this;
+    }
+
     /**
     /**
      * 上传文件路径
      * 上传文件路径
      * @param string $path
      * @param string $path

+ 2 - 1
crmeb/crmeb/services/upload/storage/Cos.php

@@ -149,7 +149,7 @@ class Cos extends BaseUpload
             $this->fileInfo->realName = isset($fileHandle) ? $fileHandle->getOriginalName() : $key;
             $this->fileInfo->realName = isset($fileHandle) ? $fileHandle->getOriginalName() : $key;
             $this->fileInfo->fileName = $key;
             $this->fileInfo->fileName = $key;
             $this->fileInfo->filePathWater = $this->water($this->fileInfo->filePath);
             $this->fileInfo->filePathWater = $this->water($this->fileInfo->filePath);
-            $this->thumb($this->fileInfo->filePath);
+            $this->authThumb && $this->thumb($this->fileInfo->filePath);
             return $this->fileInfo;
             return $this->fileInfo;
         } catch (UploadException $e) {
         } catch (UploadException $e) {
             return $this->setError($e->getMessage());
             return $this->setError($e->getMessage());
@@ -173,6 +173,7 @@ class Cos extends BaseUpload
     /**
     /**
      * 文件上传
      * 文件上传
      * @param string $file
      * @param string $file
+     * @param bool $realName
      * @return array|bool|mixed|\StdClass
      * @return array|bool|mixed|\StdClass
      */
      */
     public function move(string $file = 'file', $realName = false)
     public function move(string $file = 'file', $realName = false)

+ 8 - 1
crmeb/crmeb/services/upload/storage/Local.php

@@ -170,7 +170,7 @@ class Local extends BaseUpload
         $this->fileInfo->realName = $key;
         $this->fileInfo->realName = $key;
         $this->fileInfo->fileName = $key;
         $this->fileInfo->fileName = $key;
         $this->fileInfo->filePath = $this->defaultPath . '/' . $this->path . '/' . $key;
         $this->fileInfo->filePath = $this->defaultPath . '/' . $this->path . '/' . $key;
-        if ($this->checkImage('.' . $this->fileInfo->filePath)) {
+        if ($this->checkImage('.' . $this->fileInfo->filePath) && $this->authThumb) {
             try {
             try {
                 $this->thumb($this->fileInfo->filePath);
                 $this->thumb($this->fileInfo->filePath);
             } catch (\Throwable $e) {
             } catch (\Throwable $e) {
@@ -351,6 +351,13 @@ class Local extends BaseUpload
         try {
         try {
             if (!file_exists($savePath)) {
             if (!file_exists($savePath)) {
                 $Image = Image::open(app()->getRootPath() . 'public' . $filePath);
                 $Image = Image::open(app()->getRootPath() . 'public' . $filePath);
+                if (strlen($waterConfig['watermark_text_color']) < 7) {
+                    $waterConfig['watermark_text_color'] = substr($waterConfig['watermark_text_color'], 1);
+                    $waterConfig['watermark_text_color'] = '#' . $waterConfig['watermark_text_color'] . $waterConfig['watermark_text_color'];
+                }
+                if (strlen($waterConfig['watermark_text_color']) > 7) {
+                    $waterConfig['watermark_text_color'] = substr($waterConfig['watermark_text_color'], 0, 7);
+                }
                 $Image->text($waterConfig['watermark_text'], $waterConfig['watermark_text_font'], $waterConfig['watermark_text_size'], $waterConfig['watermark_text_color'], $waterConfig['watermark_position'], [$waterConfig['watermark_x'], $waterConfig['watermark_y'], $waterConfig['watermark_text_angle']])->save(root_path() . 'public' . $savePath);
                 $Image->text($waterConfig['watermark_text'], $waterConfig['watermark_text_font'], $waterConfig['watermark_text_size'], $waterConfig['watermark_text_color'], $waterConfig['watermark_position'], [$waterConfig['watermark_x'], $waterConfig['watermark_y'], $waterConfig['watermark_text_angle']])->save(root_path() . 'public' . $savePath);
             }
             }
         } catch (\Throwable $e) {
         } catch (\Throwable $e) {

+ 2 - 1
crmeb/crmeb/services/upload/storage/Oss.php

@@ -111,6 +111,7 @@ class Oss extends BaseUpload
     /**
     /**
      * 上传文件
      * 上传文件
      * @param string $file
      * @param string $file
+     * @param bool $realName
      * @return array|bool|mixed|\StdClass
      * @return array|bool|mixed|\StdClass
      */
      */
     public function move(string $file = 'file', $realName = false)
     public function move(string $file = 'file', $realName = false)
@@ -143,7 +144,7 @@ class Oss extends BaseUpload
             $this->fileInfo->filePath = $this->uploadUrl . '/' . $key;
             $this->fileInfo->filePath = $this->uploadUrl . '/' . $key;
             $this->fileInfo->fileName = $key;
             $this->fileInfo->fileName = $key;
             $this->fileInfo->filePathWater = $this->water($this->fileInfo->filePath);
             $this->fileInfo->filePathWater = $this->water($this->fileInfo->filePath);
-            $this->thumb($this->fileInfo->filePath);
+            $this->authThumb && $this->thumb($this->fileInfo->filePath);
             return $this->fileInfo;
             return $this->fileInfo;
         } catch (UploadException $e) {
         } catch (UploadException $e) {
             return $this->setError($e->getMessage());
             return $this->setError($e->getMessage());

+ 2 - 1
crmeb/crmeb/services/upload/storage/Qiniu.php

@@ -109,6 +109,7 @@ class Qiniu extends BaseUpload
     /**
     /**
      * 上传文件
      * 上传文件
      * @param string $file
      * @param string $file
+     * @param bool $realName
      * @return array|bool|mixed|\StdClass|string
      * @return array|bool|mixed|\StdClass|string
      */
      */
     public function move(string $file = 'file', $realName = false)
     public function move(string $file = 'file', $realName = false)
@@ -143,7 +144,7 @@ class Qiniu extends BaseUpload
             $this->fileInfo->filePath = $this->uploadUrl . '/' . $key;
             $this->fileInfo->filePath = $this->uploadUrl . '/' . $key;
             $this->fileInfo->fileName = $key;
             $this->fileInfo->fileName = $key;
             $this->fileInfo->filePathWater = $this->water($this->fileInfo->filePath);
             $this->fileInfo->filePathWater = $this->water($this->fileInfo->filePath);
-            $this->thumb($this->fileInfo->filePath);
+            $this->authThumb && $this->thumb($this->fileInfo->filePath);
             return $this->fileInfo;
             return $this->fileInfo;
         } catch (UploadException $e) {
         } catch (UploadException $e) {
             return $this->setError($e->getMessage());
             return $this->setError($e->getMessage());

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 20 - 2
crmeb/public/install/crmeb.sql