<?php

namespace App\Http\Controllers\Platform;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Redis;
use App\Services\UtilService;
use App\Models\AldGift;
use App\Models\User;
use App\Models\UserExtra;

class HomeController extends Controller
{
    public function showLoginForm(Request $request)
    {
        if($request->session()->get("uid")) return redirect(route("index"));
        $isWx = UtilService::getIsWx($_SERVER['HTTP_USER_AGENT']);
        if(!$isWx) return redirect(route("wxIndex"));
        $data['isWx'] = $isWx;
        return view("home.login",$data);
    }

    public function showRegisterForm(Request $request)
    {
        if($request->session()->get("uid")) return redirect(route("index"));
        $isWx = UtilService::getIsWx($_SERVER['HTTP_USER_AGENT']);
        if(!$isWx) return redirect(route("wxIndex"));
        $data['isWx'] = $isWx;
        return view("home.register",$data);
    }

    public function showFindPasswordForm(Request $request)
    {
        if($request->session()->get("uid")) return redirect(route("index"));
        $viewData['kefuURL'] = '';
        $isWx = UtilService::getIsWx($_SERVER['HTTP_USER_AGENT']);
        if(!$isWx) return redirect(route("wxIndex"));
        $viewData['isWx'] = $isWx;

        return view("home.findPassword", $viewData);
    }

    public function showAldLoginForm(Request $request)
    {
        if($request->session()->get("uid")) return redirect(route("index"));
        $isWx = UtilService::getIsWx($_SERVER['HTTP_USER_AGENT']);
        if(!$isWx) return redirect(route("wxIndex"));
        $data['isWx'] = $isWx;
        return view("home.ald_login",$data);
    }


}
