appId = $appId; } /** * 获取 */ public function getImage() { // 判断二维码文件存在则直接返回url if (file_exists($this->getPosterPath())) { return $this->getPosterUrl(); } $qrcode = new QrCode(base_url().'h5/pages2/login/mplogin?app_id=' . $this->appId); $qrcode = $this->saveMpQrcode($qrcode, $this->appId, '', 'image_mplogin'); return $this->getPosterUrl(); } /** * 二维码文件路径 */ private function getPosterPath() { $web_path = $_SERVER['DOCUMENT_ROOT']; // 保存路径 $tempPath = $web_path . "/temp/{$this->appId}/image_mplogin/"; !is_dir($tempPath) && mkdir($tempPath, 0755, true); return $tempPath . $this->getPosterName(); } /** * 二维码文件名称 */ private function getPosterName() { return 'qrcode_' . md5("{$this->appId}") . '.png'; } /** * 二维码url */ private function getPosterUrl() { return \base_url() . "temp/{$this->appId}/image_mplogin/{$this->getPosterName()}" . '?t=' . time(); } }