You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Services\WeChatMiniProgramService;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
|
|
|
|
|
|
|
|
|
class SigninQrController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function show(Request $request, WeChatMiniProgramService $wechat): Response|SymfonyResponse
|
|
|
|
|
{
|
|
|
|
|
$data = $request->validate([
|
|
|
|
|
'code' => ['required', 'string', 'max:32'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$page = (string) config('services.wechat.mini_program.checkin_page', 'subpkg/checkin/index');
|
|
|
|
|
$png = $wechat->getUnlimitedWxaCode($page, $data['code']);
|
|
|
|
|
|
|
|
|
|
return response($png, 200, [
|
|
|
|
|
'Content-Type' => 'image/png',
|
|
|
|
|
'Cache-Control' => 'private, max-age=300',
|
|
|
|
|
]);
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
'message' => $e->getMessage() ?: '生成小程序码失败',
|
|
|
|
|
], 422);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|