isMobile()) { $layout = 'h5'; } $this->view->assign('android_apkUrl', config("site.android_apkUrl")); $this->view->assign('ios_downurl', config('site.ios_downurl')); //手机端二维码 $url = config('website_url').'/index/appdown'; $qrcode = $this->inviteimage($url); $this->view->assign('qrcode',$qrcode); return $this->view->fetch($layout); } private function inviteimage($text) { $params['text'] = $text; $qrcode_service = \addons\qrcode\library\Service::qrcode($params); // $mimetype = 'image/png'; // $response = Response::create()->header("Content-Type", $mimetype); // 直接显示二维码 // header('Content-Type: ' . $qrcode_service->getContentType()); // $response->content($qrcode_service->writeString()); $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/'; if (!is_dir($qrcodePath)) { @mkdir($qrcodePath); } if (is_really_writable($qrcodePath)) { $filename = md5(implode('', $params)) . '.png'; $filePath = $qrcodePath . $filename; $qrcode_service->writeFile($filePath); } return '/uploads/qrcode/' . $filename; } }