Browse Source

测试qrcode

lizhen_gitee 1 year ago
parent
commit
421d4fc17f
2 changed files with 22 additions and 0 deletions
  1. 21 0
      application/api/controller/UserCoupons.php
  2. 1 0
      application/common.php

+ 21 - 0
application/api/controller/UserCoupons.php

@@ -95,4 +95,25 @@ class UserCoupons extends Api
             $this->error($e->getMessage());
         }
     }
+
+    public function newtest()
+    {
+            $id = 5;
+            $text = 'hexiaocoupon_'.$id;
+            $logo = '';
+            $filRoute = '/uploads/temp/';
+            $saveDir = ROOT_PATH.'public\uploads\temp'.DS;
+            $fileStr = md5('coupon_'.$id);
+            $localpng = $saveDir.$fileStr.'.png';
+            //验证存在直接返回
+            $userCouponsUrl = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$filRoute.$fileStr.'.png';
+            if (!file_exists($localpng)) {
+                build_qrcode($text, $logo, $saveDir,$fileStr);
+            }
+            $result = [
+                'url' => $userCouponsUrl,
+            ];
+            $this->success('获取成功',$result);
+
+    }
 }

+ 1 - 0
application/common.php

@@ -1026,6 +1026,7 @@ if(!function_exists('build_qrcode')) {
         }
         //输出图片
         $res = imagepng($QR, $filename);
+        dump($res);
         imagedestroy($QR);
         if($res === false) {
             return $res;