|
|
|
|
@ -3,11 +3,15 @@
|
|
|
|
|
namespace App\Http\Controllers\Customer;
|
|
|
|
|
|
|
|
|
|
use App\Customer;
|
|
|
|
|
use App\Helpers\ResponseCode;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use EasyWeChat\Factory;
|
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
|
use Tymon\JWTAuth\Facades\JWTAuth;
|
|
|
|
|
|
|
|
|
|
class AuthController extends Controller
|
|
|
|
|
@ -241,4 +245,38 @@ class AuthController extends Controller
|
|
|
|
|
$token = $this->guard()->login($user);
|
|
|
|
|
return $this->respondWithToken($token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Post(
|
|
|
|
|
* path="/customer/mobile",
|
|
|
|
|
* tags={"用户端用户相关"},
|
|
|
|
|
* summary="V2-通过code获取手机号",
|
|
|
|
|
* description="",
|
|
|
|
|
* @OA\Parameter(name="code", in="query", @OA\Schema(type="string"), required=true, description="code"),
|
|
|
|
|
* @OA\Parameter(name="openid", in="query", @OA\Schema(type="string"), required=true, description="openid"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description=""
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function mobile()
|
|
|
|
|
{
|
|
|
|
|
$code = request('code');
|
|
|
|
|
$config = [
|
|
|
|
|
'app_id' => $this->appid,
|
|
|
|
|
'secret' => $this->appsecret
|
|
|
|
|
];
|
|
|
|
|
$app = Factory::miniProgram($config);
|
|
|
|
|
$result = $app->phone_number->getUserPhoneNumber($code);
|
|
|
|
|
$mobile = $result['phone_info']['purePhoneNumber'] ?? '';
|
|
|
|
|
$user = $this->authModel->firstOrCreate([
|
|
|
|
|
"mobile" => $mobile
|
|
|
|
|
]);
|
|
|
|
|
$user->openid = $mobile;
|
|
|
|
|
$user->save();
|
|
|
|
|
$token = $this->guard()->login($user);
|
|
|
|
|
return $this->respondWithToken($token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|