app_code->getUnlimit($scene, [ 'page' => $page, ]); if(is_array($response) && 41030 === $response['errcode']){ //开启错误提示,小程序未发布和页面不存在,返回提示 if (41030 === $response['errcode']) { throw new Exception('所传page页面不存在,或者小程序没有发布'); } throw new Exception($response['errmsg']); } $contents = $response->getBody()->getContents(); switch ($type){ case 'file': if ($response instanceof StreamResponse) { $file_name = $response->saveAs($save_dir, $file_name); $contents = $save_dir . $file_name; } break; case 'base64': $mp_base64 = chunk_split(base64_encode($contents)); $contents = 'data:image/png;base64,' . $mp_base64; } return data_success('',['qr_code'=>$contents, 'extra' => $extra]); } catch (\EasyWeChat\Kernel\Exceptions\Exception $e){ return data_error($e->getMessage()); } } }