123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\index\controller;
- use think\Controller;
- class Appdown extends Controller
- {
- /**
- * app下载页
- * 判断是安卓还是ios
- */
- public function index() {
- $layout = 'index';
- if(request()->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;
- }
- }
|