You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use Illuminate\Http\Request;
  4. use App\Common\ReturnData;
  5. use App\Common\Helper;
  6. //二维码,如果输出乱码就转成base64输出
  7. class QrcodeController extends BaseController
  8. {
  9. public function __construct()
  10. {
  11. parent::__construct();
  12. }
  13. public function createSimpleQrcode(Request $request)
  14. {
  15. //参数
  16. $url = $request->input('url','');
  17. $size = $request->input('size', 150);
  18. $is_binary = $request->input('is_binary',0); //0表示不是二进制,1表示二进制流base64
  19. if($url=='')
  20. {
  21. return ReturnData::create(ReturnData::PARAMS_ERROR);
  22. }
  23. if($is_binary==1){return Helper::qrcode($url,$size);}
  24. return '<img src="'.Helper::qrcode($url,$size).'">';
  25. }
  26. //二维码
  27. public function qrcode()
  28. {
  29. $url = $_REQUEST['url'];
  30. $url = str_replace("%26","&",$url);
  31. $url = str_replace("%3F","?",$url);
  32. $url = str_replace("%3D","=",$url);
  33. require_once(resource_path('org/phpqrcode/phpqrcode.php'));
  34. return \QRcode::png($url,false,"H",6);
  35. }
  36. }