Files
fast_response/front/application/index/controller/Login.php
Your Name dce091da91 t
2025-03-27 07:52:44 +00:00

63 lines
1.4 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*
* description
* authorwh
* email
* createTime{2023/11/19} {22:32}
*/
namespace app\index\controller;
use think\Controller;
use wanghua\general_utility_tools_php\tool\Tools;
use wanghua\general_utility_tools_php\wechat\TmpWexinauth;
use wanghua\general_utility_tools_php\wechat\UserAuth;
use wanghua\general_utility_tools_php\wechat\WechatLogic;
/**
*
*/
class Login extends Controller
{
function login()
{
$username = input('username');
$password = input('password');
return json(Tools::set_res(200,'ok',['username'=>$username]));
}
/**
* desc微信授权
* authorwh
*/
function wxauth()
{
try {
$code = input('code');
if(empty($code)){
return Tools::set_fail('CODE参数错误');
}
$wxconfig = get_boom_union_wechat_config();
$res = (new UserAuth($wxconfig,$wxconfig['access_token_path']))->usrAccessTokenApplet($code);
//绑定客户端ID和用户openid
return json(Tools::set_ok('ok',$res));
}catch (\Exception $e){
Tools::log_to_write_text([
'error'=>'微信授权异常。'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail('请求异常'));
}
}
}