erp_old/app/api/controller/LoginController.php

69 lines
1.7 KiB
PHP
Raw Normal View History

2024-04-26 11:26:12 +08:00
<?php
namespace app\api\controller;
use app\api\logic\LoginLogic;
2024-04-29 16:36:12 +08:00
use app\api\validate\{LoginAccountValidate, RegisterValidate, WebScanLoginValidate, WechatLoginValidate};
2024-04-26 11:26:12 +08:00
class LoginController extends BaseApiController
{
2024-04-29 16:36:12 +08:00
public $notNeedLogin = ['account','logout'];
2024-04-26 11:26:12 +08:00
2024-04-29 16:36:12 +08:00
/**
* @notes 账号登录
*/
2024-04-26 11:26:12 +08:00
public function account()
{
$params=$this->request->post();
$params = (new LoginAccountValidate())->post()->goCheck();
$result = LoginLogic::login($params);
if (false === $result) {
return $this->fail(LoginLogic::getError());
}
return $this->data($result);
}
2024-04-29 16:36:12 +08:00
/**
* @notes 退出登录
*/
public function logout()
{
LoginLogic::logout($this->userInfo);
return $this->success();
}
/**
* @notes 小程序-登录接口
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 19:48
*/
public function mnpLogin()
{
$params = (new WechatLoginValidate())->post()->goCheck('mnpLogin');
$res = LoginLogic::mnpLogin($params);
if (false === $res) {
return $this->fail(LoginLogic::getError());
}
return $this->success('', $res);
}
/**
* @notes 小程序绑定微信
* @return \think\response\Json
* @author 段誉
* @date 2022/9/20 19:48
*/
public function mnpAuthBind()
{
$params = (new WechatLoginValidate())->post()->goCheck("wechatAuth");
$params['user_id'] = $this->userId;
$result = LoginLogic::mnpAuthLogin($params);
if ($result === false) {
return $this->fail(LoginLogic::getError());
}
return $this->success('绑定成功', [], 1, 1);
}
2024-04-26 11:26:12 +08:00
}