Appdown.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\index\controller;
  3. use think\Controller;
  4. class Appdown extends Controller
  5. {
  6. /**
  7. * app下载页
  8. * 判断是安卓还是ios
  9. */
  10. public function index() {
  11. $layout = 'index';
  12. if(request()->isMobile())
  13. {
  14. $layout = 'h5';
  15. }
  16. $this->view->assign('android_apkUrl', config("site.android_apkUrl"));
  17. $this->view->assign('ios_downurl', config('site.ios_downurl'));
  18. //手机端二维码
  19. $url = config('website_url').'/index/appdown';
  20. $qrcode = $this->inviteimage($url);
  21. $this->view->assign('qrcode',$qrcode);
  22. return $this->view->fetch($layout);
  23. }
  24. private function inviteimage($text) {
  25. $params['text'] = $text;
  26. $qrcode_service = \addons\qrcode\library\Service::qrcode($params);
  27. // $mimetype = 'image/png';
  28. // $response = Response::create()->header("Content-Type", $mimetype);
  29. // 直接显示二维码
  30. // header('Content-Type: ' . $qrcode_service->getContentType());
  31. // $response->content($qrcode_service->writeString());
  32. $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/';
  33. if (!is_dir($qrcodePath)) {
  34. @mkdir($qrcodePath);
  35. }
  36. if (is_really_writable($qrcodePath)) {
  37. $filename = md5(implode('', $params)) . '.png';
  38. $filePath = $qrcodePath . $filename;
  39. $qrcode_service->writeFile($filePath);
  40. }
  41. return '/uploads/qrcode/' . $filename;
  42. }
  43. }