yingzi 2 gadi atpakaļ
vecāks
revīzija
24fb6a0693
2 mainītis faili ar 36 papildinājumiem un 5 dzēšanām
  1. 15 5
      app/api/controller/User.php
  2. 21 0
      app/system/controller/Upload.php

+ 15 - 5
app/api/controller/User.php

@@ -665,14 +665,24 @@ class User extends BaseController
         return app('json')->success(["qrcode"=>$res["url"],"bgimg"=>$bgimg]);
         return app('json')->success(["qrcode"=>$res["url"],"bgimg"=>$bgimg]);
     }
     }
     
     
-    
-    public function createImg($bg,$qrcode){
+    /**
+     * 图片合成
+     * @param type $bg
+     * @param type $qrcode
+     * @param type $savePath
+     */
+    public function createPosterImg($bg,$qrcode,$savePath){
+        
+        
+        
+        
+        
+        
         $bgSize = getimagesize($bg);
         $bgSize = getimagesize($bg);
         $qrcodeSize = getimagesize($qrcode);
         $qrcodeSize = getimagesize($qrcode);
         $handle = Image::open($bg);
         $handle = Image::open($bg);
-       
-        $handle->water($qrcode);
-        $handle->save($savePath);
+        $handle->water($qrcode,[($bgSize[0]-$qrcodeSize[0])/2,($bgSize[1]-$qrcodeSize[1])/2]);
+        $handle->save($savePath,"jpg",80);
     }
     }
     
     
     /**
     /**

+ 21 - 0
app/system/controller/Upload.php

@@ -29,6 +29,27 @@ class Upload extends AuthController{
         if (empty($file)) {
         if (empty($file)) {
             return app('json')->fail("未上传文件");
             return app('json')->fail("未上传文件");
         }
         }
+        $code = $request->post("code","");
+        //上传到本地
+        if($code=="invite"){
+            $size = $file->getSize();
+            if(!empty($size) && $size>2*1024*1024){
+                return app('json')->fail("图片不能超过{$uploadConfig["image"]["size"]}M");
+            }
+
+            $ext = $file->extension();
+            if(!in_array($ext, ["jpg","jpeg","png"])){
+                return app('json')->fail("图片类型错误");
+            }
+            $upPath = \think\facade\Filesystem::disk('resource')->putFile( $code, $file);
+            if(!$upPath){
+                return app('json')->fail("图片上传失败01");
+            }
+            $savePath = $sysData['system_url'].'/resource/' . $upPath;
+            $imgUrl = str_replace("\\", "/", $savePath);
+            return app('json')->success(['img'=>$imgUrl]);
+        }
+        
         $rootTmp    = config('filesystem.disks.local.root') . '/' . \think\facade\Filesystem::putFile('tmp', $file);
         $rootTmp    = config('filesystem.disks.local.root') . '/' . \think\facade\Filesystem::putFile('tmp', $file);
         $image_size = @getimagesize($rootTmp);
         $image_size = @getimagesize($rootTmp);
         if ($image_size[0] > 1000) {
         if ($image_size[0] > 1000) {