From 8588d1787b7a3aa8914afef3a2c07b223f2528e3 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Tue, 26 Oct 2021 12:08:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=9B=BE=E7=89=87=E6=B0=B4?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/StoreBargainServices.php | 2 ++ .../activity/StoreCombinationServices.php | 2 ++ .../activity/StoreSeckillServices.php | 2 ++ .../product/product/StoreProductServices.php | 2 ++ crmeb/crmeb/basic/BaseUpload.php | 18 ++++++++++++++- crmeb/crmeb/services/upload/storage/Cos.php | 3 ++- crmeb/crmeb/services/upload/storage/Local.php | 9 +++++++- crmeb/crmeb/services/upload/storage/Oss.php | 3 ++- crmeb/crmeb/services/upload/storage/Qiniu.php | 3 ++- crmeb/public/install/crmeb.sql | 22 +++++++++++++++++-- 10 files changed, 59 insertions(+), 7 deletions(-) diff --git a/crmeb/app/services/activity/StoreBargainServices.php b/crmeb/app/services/activity/StoreBargainServices.php index 9d1c09514..5829df47e 100644 --- a/crmeb/app/services/activity/StoreBargainServices.php +++ b/crmeb/app/services/activity/StoreBargainServices.php @@ -448,6 +448,8 @@ class StoreBargainServices extends BaseServices } $data['bargain'] = get_thumb_water($bargain); + $bargainNew = get_thumb_water($bargain, 'small'); + $data['bargain']['small_image'] = $bargainNew['image']; /** @var StoreOrderServices $orderService */ $orderService = app()->make(StoreOrderServices::class); diff --git a/crmeb/app/services/activity/StoreCombinationServices.php b/crmeb/app/services/activity/StoreCombinationServices.php index d77e017c4..049e29f4e 100644 --- a/crmeb/app/services/activity/StoreCombinationServices.php +++ b/crmeb/app/services/activity/StoreCombinationServices.php @@ -387,6 +387,8 @@ class StoreCombinationServices extends BaseServices $qrcodeService = app()->make(QrcodeServices::class); $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']); + $storeInfoNew = get_thumb_water($storeInfo, 'small'); + $data['storeInfo']['small_image'] = $storeInfoNew['image']; /** @var StorePinkServices $pinkService */ $pinkService = app()->make(StorePinkServices::class); diff --git a/crmeb/app/services/activity/StoreSeckillServices.php b/crmeb/app/services/activity/StoreSeckillServices.php index 31c890d48..11bd3f4a7 100644 --- a/crmeb/app/services/activity/StoreSeckillServices.php +++ b/crmeb/app/services/activity/StoreSeckillServices.php @@ -483,6 +483,8 @@ class StoreSeckillServices extends BaseServices //商品详情 $data['storeInfo'] = get_thumb_water($storeInfo, 'big', ['image', 'images']); + $storeInfoNew = get_thumb_water($storeInfo, 'small'); + $data['storeInfo']['small_image'] = $storeInfoNew['image']; /** @var StoreProductReplyServices $storeProductReplyService */ $storeProductReplyService = app()->make(StoreProductReplyServices::class); diff --git a/crmeb/app/services/product/product/StoreProductServices.php b/crmeb/app/services/product/product/StoreProductServices.php index 3066a2b96..8421f9556 100644 --- a/crmeb/app/services/product/product/StoreProductServices.php +++ b/crmeb/app/services/product/product/StoreProductServices.php @@ -1306,6 +1306,8 @@ class StoreProductServices extends BaseServices $data['productAttr'] = $productAttr; $data['productValue'] = $productValue; $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 */ $memberCardService = app()->make(MemberCardServices::class); diff --git a/crmeb/crmeb/basic/BaseUpload.php b/crmeb/crmeb/basic/BaseUpload.php index 90d8be4a9..8e307e08d 100644 --- a/crmeb/crmeb/basic/BaseUpload.php +++ b/crmeb/crmeb/basic/BaseUpload.php @@ -11,7 +11,6 @@ namespace crmeb\basic; -use crmeb\services\SystemConfigService; use think\facade\Config; /** @@ -85,6 +84,12 @@ abstract class BaseUpload extends BaseStorage */ protected $path = ''; + /** + * 是否自动裁剪 + * @var bool + */ + protected $authThumb = true; + protected function initialize(array $config) { $this->fileInfo = $this->downFileInfo = new \StdClass(); @@ -103,6 +108,17 @@ abstract class BaseUpload extends BaseStorage return $this; } + /** + * 是否自动裁剪 + * @param bool $auth + * @return $this + */ + public function setAuthThumb(bool $auth) + { + $this->authThumb = $auth; + return $this; + } + /** * 上传文件路径 * @param string $path diff --git a/crmeb/crmeb/services/upload/storage/Cos.php b/crmeb/crmeb/services/upload/storage/Cos.php index 5d5f33df5..e3e0d6216 100644 --- a/crmeb/crmeb/services/upload/storage/Cos.php +++ b/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->fileName = $key; $this->fileInfo->filePathWater = $this->water($this->fileInfo->filePath); - $this->thumb($this->fileInfo->filePath); + $this->authThumb && $this->thumb($this->fileInfo->filePath); return $this->fileInfo; } catch (UploadException $e) { return $this->setError($e->getMessage()); @@ -173,6 +173,7 @@ class Cos extends BaseUpload /** * 文件上传 * @param string $file + * @param bool $realName * @return array|bool|mixed|\StdClass */ public function move(string $file = 'file', $realName = false) diff --git a/crmeb/crmeb/services/upload/storage/Local.php b/crmeb/crmeb/services/upload/storage/Local.php index f5fadb58f..0a6ea1874 100644 --- a/crmeb/crmeb/services/upload/storage/Local.php +++ b/crmeb/crmeb/services/upload/storage/Local.php @@ -170,7 +170,7 @@ class Local extends BaseUpload $this->fileInfo->realName = $key; $this->fileInfo->fileName = $key; $this->fileInfo->filePath = $this->defaultPath . '/' . $this->path . '/' . $key; - if ($this->checkImage('.' . $this->fileInfo->filePath)) { + if ($this->checkImage('.' . $this->fileInfo->filePath) && $this->authThumb) { try { $this->thumb($this->fileInfo->filePath); } catch (\Throwable $e) { @@ -351,6 +351,13 @@ class Local extends BaseUpload try { if (!file_exists($savePath)) { $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); } } catch (\Throwable $e) { diff --git a/crmeb/crmeb/services/upload/storage/Oss.php b/crmeb/crmeb/services/upload/storage/Oss.php index e02201cb2..13e1b80e1 100644 --- a/crmeb/crmeb/services/upload/storage/Oss.php +++ b/crmeb/crmeb/services/upload/storage/Oss.php @@ -111,6 +111,7 @@ class Oss extends BaseUpload /** * 上传文件 * @param string $file + * @param bool $realName * @return array|bool|mixed|\StdClass */ public function move(string $file = 'file', $realName = false) @@ -143,7 +144,7 @@ class Oss extends BaseUpload $this->fileInfo->filePath = $this->uploadUrl . '/' . $key; $this->fileInfo->fileName = $key; $this->fileInfo->filePathWater = $this->water($this->fileInfo->filePath); - $this->thumb($this->fileInfo->filePath); + $this->authThumb && $this->thumb($this->fileInfo->filePath); return $this->fileInfo; } catch (UploadException $e) { return $this->setError($e->getMessage()); diff --git a/crmeb/crmeb/services/upload/storage/Qiniu.php b/crmeb/crmeb/services/upload/storage/Qiniu.php index 5f8ad88b0..066822647 100644 --- a/crmeb/crmeb/services/upload/storage/Qiniu.php +++ b/crmeb/crmeb/services/upload/storage/Qiniu.php @@ -109,6 +109,7 @@ class Qiniu extends BaseUpload /** * 上传文件 * @param string $file + * @param bool $realName * @return array|bool|mixed|\StdClass|string */ public function move(string $file = 'file', $realName = false) @@ -143,7 +144,7 @@ class Qiniu extends BaseUpload $this->fileInfo->filePath = $this->uploadUrl . '/' . $key; $this->fileInfo->fileName = $key; $this->fileInfo->filePathWater = $this->water($this->fileInfo->filePath); - $this->thumb($this->fileInfo->filePath); + $this->authThumb && $this->thumb($this->fileInfo->filePath); return $this->fileInfo; } catch (UploadException $e) { return $this->setError($e->getMessage()); diff --git a/crmeb/public/install/crmeb.sql b/crmeb/public/install/crmeb.sql index 454ff841c..a2bec475e 100644 --- a/crmeb/public/install/crmeb.sql +++ b/crmeb/public/install/crmeb.sql @@ -6859,7 +6859,7 @@ INSERT INTO `eb_system_config` (`id`, `menu_name`, `type`, `input_type`, `config (88, 'store_brokerage_statu', 'radio', '', 72, '1=>指定分销\n2=>人人分销\n3=>满额分销', 0, '', 0, 0, '1', '分销模式', '人人分销”默认每个人都可以分销,“指定分销”仅可后台手动设置推广员,“满额分销”指用户购买商品满足消费金额后自动开启分销', 95, 1), (98, 'wechat_avatar', 'upload', 'input', 2, '', 1, '', 0, 0, '\"\"', 'H5登录logo', 'H5登录logo', 0, 0), (99, 'user_extract_bank', 'textarea', '', 74, '', 0, '', 100, 5, '\"\\u4e2d\\u56fd\\u94f6\\u884c\"', '提现银行卡', '配置提现银行卡类型,每个银行换行', 0, 1), -(108, 'upload_type', 'radio', '', 31, '1=>本地存储\n2=>七牛云存储\n3=>阿里云OSS\n4=>腾讯COS', 1, '', 0, 0, '1', '上传类型', '文件储存配置,注意:一旦配置就不要轻易修改,会导致文件不能使用', 0, 1), +(108, 'upload_type', 'radio', '', 31, '1=>本地存储\n2=>七牛云存储\n3=>阿里云OSS\n4=>腾讯COS', 1, '', 0, 0, '1', '上传类型', '文件储存配置,注意:一旦配置就不要轻易修改,会导致文件不能使用', 100, 1), (109, 'uploadUrl', 'text', 'input', 32, '', 0, 'url:true', 100, 0, '\"\"', '空间域名 Domain', '空间域名 Domain', 0, 1), (110, 'accessKey', 'text', 'input', 32, '', 0, '', 100, 0, '\"\"', 'accessKey', 'accessKey', 0, 1), (111, 'secretKey', 'text', 'input', 32, '', 0, '', 100, 0, '\"\"', 'secretKey', 'secretKey', 0, 1), @@ -6976,7 +6976,25 @@ INSERT INTO `eb_system_config` (`id`, `menu_name`, `type`, `input_type`, `config (355, 'statistic_script', 'textarea', 'input', 78, '', 0, '', 100, 10, '\"(function() {\\n_s = document.createElement(\'script\');\\n_s.src=\\\"https:\\/\\/chat.crmeb.net\\/customerServer.js\\\"\\n_s.onload = function(){\\nvar option = {\\n openUrl: \'https:\\/\\/chat.crmeb.net\',\\n token: \'e8bcc017f50e55c63b5352c4257c8904\'\\n };\\n var canCustomerServer = new initCustomerServer(option);\\n canCustomerServer.init();\\n\\n}\\ndocument.head.appendChild(_s)\\n})();\"', '统计代码', '统计代码', 0, 1), (356, 'admin_port', 'text', 'input', 24, '', 1, '', 100, 0, '\"\"', '后台监听域名+端口', '后台监听域名+端口(注:不用填写http)', 10, 1), (358, 'channel_port', 'text', 'input', 24, '', 1, '', 100, 0, '\"\"', '内部通讯监听域名+端口', '内部通讯监听域名+端口(注:不用填写http)', 8, 1), -(359, 'weixin_ckeck_file', 'upload', 'input', 2, '', 3, '', 0, 0, '\"\"', '微信校验文件', '微信校验文件', 0, 1); +(359, 'weixin_ckeck_file', 'upload', 'input', 2, '', 3, '', 0, 0, '\"\"', '微信校验文件', '微信校验文件', 0, 1), +(360, 'thumb_big_width', 'text', 'input', 31, '', 0, '', 100, 0, '\"\"', '缩略大图(单位:px):宽', '缩略大图(单位:px):宽', 99, 1), +(361, 'thumb_big_height', 'text', 'input', 31, '', 0, '', 100, 0, '\"\"', '缩略大图(单位:px):高', '缩略大图(单位:px):高', 98, 1), +(362, 'thumb_mid_width', 'text', 'input', 31, '', 0, '', 50, 0, '\"\"', '缩略中图(单位:px):宽', '缩略中图(单位:px):宽', 97, 1), +(363, 'thumb_mid_height', 'text', 'input', 31, '', 0, '', 50, 0, '\"\"', '缩略中图(单位:px):高', '缩略中图(单位:px):高', 96, 1), +(364, 'thumb_small_width', 'text', 'input', 31, '', 0, '', 50, 0, '\"\"', '缩略小图(单位:px): 宽', '缩略小图(单位:px): 宽', 95, 1), +(365, 'thumb_small_height', 'text', 'input', 31, '', 0, '', 50, 0, '\"\"', '缩略小图(单位:px): 高', '缩略小图(单位:px): 高', 94, 1), +(366, 'image_watermark_status', 'radio', '', 31, '1=>开启\n0=>关闭', 0, '', 0, 0, '0', '是否开启水印', '图片水印是否开服', 80, 1), +(367, 'watermark_type', 'radio', '', 31, '1=>图片\n2=>文字', 0, '', 0, 0, '1', '水印类型', '水印类型:图片、文字', 29, 1), +(368, 'watermark_image', 'upload', '', 31, '', 1, '', 0, 0, '\"\\/uploads\\/system\\/f817d3954ffc65e14991ccb1ff2f9107.png\"', '水印图片', '水印图片链接', 28, 1), +(369, 'watermark_position', 'radio', '', 31, '1=>左上\n2=>上中\n3=>右上\n4=>左中\n5=>中\n6=>右中\n7=>左下\n8=>下中\n9=>右下', 0, '', 0, 0, '9', '水印位置', 'watermark_position', 27, 1), +(370, 'watermark_opacity', 'text', 'input', 31, '', 0, '', 100, 0, '\"80\"', '水印图片透明度', '水印图片透明度', 25, 1), +(371, 'watermark_rotate', 'text', 'input', 31, '', 0, '', 100, 0, '\"2\"', '水印图片倾斜度', '水印图片倾斜度', 24, 1), +(372, 'watermark_text', 'text', 'input', 31, '', 0, '', 100, 0, '\"love\"', '水印文字', '水印文字', 28, 1), +(373, 'watermark_text_size', 'text', 'input', 31, '', 0, '', 100, 0, '\"20\"', '水印文字大小(单位:px)', '水印文字大小(px)', 27, 1), +(374, 'watermark_text_color', 'text', 'input', 31, '', 0, '', 100, 0, '\"#666666\"', '水印字体颜色', '水印字体颜色', 25, 1), +(375, 'watermark_text_angle', 'text', 'input', 31, '', 0, '', 100, 0, '\"1\"', '水印字体旋转角度', '水印字体旋转角度', 24, 1), +(376, 'watermark_x', 'text', 'input', 31, '', 0, '', 100, 0, '\"10\"', '水印横坐标偏移量(单位:px)', '水印横坐标偏移量(单位:px)', 23, 1), +(377, 'watermark_y', 'text', 'input', 31, '', 0, '', 100, 0, '\"10\"', '水印纵坐标偏移量(单位:px)', '水印纵坐标偏移量(单位:px)', 22, 1); -- --------------------------------------------------------