yingzi 2 년 전
부모
커밋
ed6a826f0a
2개의 변경된 파일96개의 추가작업 그리고 24개의 파일을 삭제
  1. 77 5
      app/api/controller/User.php
  2. 19 19
      app/system/controller/Upload.php

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

@@ -665,6 +665,82 @@ class User extends BaseController
         return app('json')->success(["qrcode"=>$res["url"],"bgimg"=>$bgimg]);
     }
     
+    
+//    public function getWxmpInviteQrcode2(Request $request){
+//        
+//        //获取小程序码
+//        $weixinA = new weixina();
+//        $data = $weixinA->getUnlimitedQRCode("pages/index/index","scene=".$request->user["uid"]);
+//        if(empty($data)){
+//            return app('json')->fail("小程序码获取失败".$weixinA->error);
+//        }
+//        $base64 = 'data:'.$data['contentType'].';base64,'.base64_encode($data['buffer']);
+//        $code = "temp";
+//        $sysData = (new SysModel())->where("id",1)->find();
+//        $uploadConfig = config('filesystem');
+//        //验证base64格式
+//        preg_match('/^(data:\s*image\/(\w+);base64,)/',$base64, $result);
+//        if(!$result){
+//            return ["code"=>-1,"msg"=>"base64格式格式错误"];
+//        }
+//        //验证图片后缀
+//        if (!in_array($result[2], $uploadConfig['image']['ext'], true)) {
+//            return ["code"=>-1,"msg"=>"不支持的图片格式"];
+//        }
+//        $rootPath = config('filesystem.disks.resource.root');
+//        $hashName = $code.DIRECTORY_SEPARATOR.date('Ymd') . DIRECTORY_SEPARATOR . md5((string) microtime(true)).".".$result[2];
+//        $filePath = $rootPath. DIRECTORY_SEPARATOR .$hashName;
+//        $path = dirname($filePath);
+//        // 检测目录
+//        if (!is_dir($path)) {
+//            if (!mkdir($path, 0777, true)) {
+//                return ["code"=>-1,"msg"=>"生成目录失败"];
+//            }
+//            return ["code"=>-1,"msg"=>"上传目录不存在"];
+//        }
+//        //重名文件验证
+//        if (is_file($filePath)) {
+//            return ["code"=>-1,"msg"=>"文件已存在"];
+//        }
+//        if(!file_put_contents($filePath, base64_decode(str_replace($result[1], '', $base64)))){
+//            return ["code"=>-1,"msg"=>"文件报错失败"];
+//        }
+//        
+//        //获取海报背景
+//        $inviteData = (new SysModel)->getDataInfo("invite");
+//        if(empty($inviteData["img"])){
+//            return ["code"=>-1,"msg"=>"海报背景不存在"];
+//        }
+//        $bgimg =explode("resource", $inviteData["img"])[1];
+//        if(empty($bgimg)){
+//            return ["code"=>-1,"msg"=>"海报背景不存在"];
+//        }
+//        
+//        $savePath = $rootPath. DIRECTORY_SEPARATOR .$code.DIRECTORY_SEPARATOR.date('Ymd') . DIRECTORY_SEPARATOR . md5((string) microtime(true))."b".".jpg";
+//
+//        
+//        
+//        
+//        $bg = $rootPath.$bgimg;
+//        $bgSize = getimagesize($bg);
+//        $qrcodeSize = getimagesize($filePath);
+//        $handle = Image::open($bg);
+//        $handle->water($filePath,[($bgSize[0]-$qrcodeSize[0])/2,($bgSize[1]-$qrcodeSize[1])/2]);
+//        $handle->save($savePath,"jpg",80);
+//        $qiniu   = new  Qiniu;
+//        $img_url = $qiniu->updateFile('img', $savePath, $savePath);
+//        if (empty($img_url['url'])) {
+//            return ["code"=>-1,"msg"=>"文件报错失败:".$qiniu->getError()];
+//        }
+//        @unlink($filePath);
+//        @unlink($savePath);
+//        return ["code"=>1,"url"=>str_replace("\\", "/", $img_url['url'])];
+//    }
+//    
+//    public function checkImgPath(){
+//        
+//    }
+    
     /**
      * 图片合成
      * @param type $bg
@@ -678,11 +754,7 @@ class User extends BaseController
         
         
         
-        $bgSize = getimagesize($bg);
-        $qrcodeSize = getimagesize($qrcode);
-        $handle = Image::open($bg);
-        $handle->water($qrcode,[($bgSize[0]-$qrcodeSize[0])/2,($bgSize[1]-$qrcodeSize[1])/2]);
-        $handle->save($savePath,"jpg",80);
+        
     }
     
     /**

+ 19 - 19
app/system/controller/Upload.php

@@ -31,25 +31,25 @@ class Upload extends AuthController{
         }
         $code = $request->post("code","");
         //上传到本地
-        if($code=="invite"){
-            $sysData = (new SysModel())->where("id",1)->find();
-            $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]);
-        }
+//        if($code=="invite"){
+//            $sysData = (new SysModel())->where("id",1)->find();
+//            $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);
         $image_size = @getimagesize($rootTmp);