From 7fe0f517e361217c0be77556ca47d9298b29999c Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 15 Sep 2020 16:26:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=95=86=E6=88=B7=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=96=87=E4=BB=B6=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Common/StoreQRCode.php | 122 ------------------------------- 1 file changed, 122 deletions(-) delete mode 100644 app/Admin/Common/StoreQRCode.php diff --git a/app/Admin/Common/StoreQRCode.php b/app/Admin/Common/StoreQRCode.php deleted file mode 100644 index dac7c24..0000000 --- a/app/Admin/Common/StoreQRCode.php +++ /dev/null @@ -1,122 +0,0 @@ -images = new Images(); - // $this->imageManager = new ImageManager(); - } - - /** - * 生成小程序码 永久 还没完成 - * @param $scene 参数 - * @param $optional - */ - public function getUnlimited(string $scene, array $optional = []) - { - $wxCode = Factory::payment(config('wechat.mini_program.default')); - $res = $wxCode->app_code->getUnlimited($scene,$optional); - - } - - /** - * 生成店铺的微信小程序码 - */ - public function SetStoreWeChatCode($id) - { - $codeStore = $this->images->createQrCode($id,'zh_cjdianc/pages/takeout/takeoutindex'); - $storeImgPath = 'QR_code/code_store_img/wx_store_'.$id.'.jpg'; - $res = $this->images->uploadOss($codeStore,$storeImgPath); - if($res){ - return ['status' => true ,'path' => $storeImgPath]; - }else{ - return ['status' => false ,'path' => '']; - } - } - /** - * 生成店铺收银的微信二维码 - */ - public function SetPayWeChatCode($id) - { - // $isCREATE = env('IS_CREATE_WECHAT_MINI_QR_CODE',1); - // if($isCREATE == 0){ - $codeStore = $this->images->createQrCode($id,'zh_cjdianc/pages/seller/fukuan'); - $storeImgPath = 'QR_code/code_minipay_img/wx_minipay_'.$id.'.jpg'; - // }else{ - // $codeStore = $this->images->createWeChatQrCode('?scene='.$id,'zh_cjdianc/pages/seller/fukuan'); - // $storeImgPath = 'QR_code/code_pay_img/wx_pay_'.$id.'.jpg'; - // // 裁剪 - - // } - - // 裁剪测试 - // $this->imageManager->make()->resize(270,270)->insert($codeStore); - - $res = $this->images->uploadOss($codeStore,$storeImgPath); - if($res){ - return ['status' => true ,'path' => $storeImgPath]; - }else{ - return ['status' => false ,'path' => '']; - } - } - - /** - * 店铺收银码裁剪 - */ - public function setStoreCodeImg($file_path,$storeId){ - - $save_path = './QR_code/wx_store_pay_cut/wx_pay_'.$storeId.'.jpg'; - - if(!file_exists($save_path)){ - //将图片进行裁剪 - if(file_exists($file_path)){ - $save_width = 270; - $start_spot_x = 5; - $start_spot_y = 5; - $width = 270; - $height = 270; - - $this->tailoringImg($save_path,$file_path,$save_width,$start_spot_x,$start_spot_y,$width,$height,1); - }else{ - return ''; - } - } - return $save_path; - } - - /** - * 裁剪图片 - */ - public function tailoringImg($save_path,$file_path,$save_width,$start_spot_x,$start_spot_y,$width,$height,$display=1) - { - if(file_exists($file_path) && is_readable($file_path)){ - //从字符串中的图像流新建一图像 - $src = imagecreatefromstring(file_get_contents($file_path)); - - //保存图片的高 - $save_height = round($save_width*$height/$width); - - //根据要保存的宽和高创建图片 - $new_image = imagecreatetruecolor($save_width, $save_height); - - //生成最后的图片 - imagecopyresampled($new_image, $src, 0, 0, $start_spot_x, $start_spot_y, $save_width, $save_height, $width, $height); - - // header('Content-Type: image/jpeg'); - imagejpeg($new_image,$save_path); - imagedestroy($src); - imagedestroy($new_image); - } - } - -} From 23de30234b700ffcde1c36ca0f130eb60841124c Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 15 Sep 2020 16:27:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=95=86=E6=88=B7=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=96=87=E4=BB=B6=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Common/StoreQrCode.php | 122 +++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 app/Admin/Common/StoreQrCode.php diff --git a/app/Admin/Common/StoreQrCode.php b/app/Admin/Common/StoreQrCode.php new file mode 100644 index 0000000..dac7c24 --- /dev/null +++ b/app/Admin/Common/StoreQrCode.php @@ -0,0 +1,122 @@ +images = new Images(); + // $this->imageManager = new ImageManager(); + } + + /** + * 生成小程序码 永久 还没完成 + * @param $scene 参数 + * @param $optional + */ + public function getUnlimited(string $scene, array $optional = []) + { + $wxCode = Factory::payment(config('wechat.mini_program.default')); + $res = $wxCode->app_code->getUnlimited($scene,$optional); + + } + + /** + * 生成店铺的微信小程序码 + */ + public function SetStoreWeChatCode($id) + { + $codeStore = $this->images->createQrCode($id,'zh_cjdianc/pages/takeout/takeoutindex'); + $storeImgPath = 'QR_code/code_store_img/wx_store_'.$id.'.jpg'; + $res = $this->images->uploadOss($codeStore,$storeImgPath); + if($res){ + return ['status' => true ,'path' => $storeImgPath]; + }else{ + return ['status' => false ,'path' => '']; + } + } + /** + * 生成店铺收银的微信二维码 + */ + public function SetPayWeChatCode($id) + { + // $isCREATE = env('IS_CREATE_WECHAT_MINI_QR_CODE',1); + // if($isCREATE == 0){ + $codeStore = $this->images->createQrCode($id,'zh_cjdianc/pages/seller/fukuan'); + $storeImgPath = 'QR_code/code_minipay_img/wx_minipay_'.$id.'.jpg'; + // }else{ + // $codeStore = $this->images->createWeChatQrCode('?scene='.$id,'zh_cjdianc/pages/seller/fukuan'); + // $storeImgPath = 'QR_code/code_pay_img/wx_pay_'.$id.'.jpg'; + // // 裁剪 + + // } + + // 裁剪测试 + // $this->imageManager->make()->resize(270,270)->insert($codeStore); + + $res = $this->images->uploadOss($codeStore,$storeImgPath); + if($res){ + return ['status' => true ,'path' => $storeImgPath]; + }else{ + return ['status' => false ,'path' => '']; + } + } + + /** + * 店铺收银码裁剪 + */ + public function setStoreCodeImg($file_path,$storeId){ + + $save_path = './QR_code/wx_store_pay_cut/wx_pay_'.$storeId.'.jpg'; + + if(!file_exists($save_path)){ + //将图片进行裁剪 + if(file_exists($file_path)){ + $save_width = 270; + $start_spot_x = 5; + $start_spot_y = 5; + $width = 270; + $height = 270; + + $this->tailoringImg($save_path,$file_path,$save_width,$start_spot_x,$start_spot_y,$width,$height,1); + }else{ + return ''; + } + } + return $save_path; + } + + /** + * 裁剪图片 + */ + public function tailoringImg($save_path,$file_path,$save_width,$start_spot_x,$start_spot_y,$width,$height,$display=1) + { + if(file_exists($file_path) && is_readable($file_path)){ + //从字符串中的图像流新建一图像 + $src = imagecreatefromstring(file_get_contents($file_path)); + + //保存图片的高 + $save_height = round($save_width*$height/$width); + + //根据要保存的宽和高创建图片 + $new_image = imagecreatetruecolor($save_width, $save_height); + + //生成最后的图片 + imagecopyresampled($new_image, $src, 0, 0, $start_spot_x, $start_spot_y, $save_width, $save_height, $width, $height); + + // header('Content-Type: image/jpeg'); + imagejpeg($new_image,$save_path); + imagedestroy($src); + imagedestroy($new_image); + } + } + +}