12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- // +----------------------------------------------------------------------
- // | [ WE CAN DO IT MORE SIMPLE ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2018-2020 rights reserved.
- // +----------------------------------------------------------------------
- // | Author: TABLE ME
- // +----------------------------------------------------------------------
- // | Date: 2020-08-25 17:23
- // +----------------------------------------------------------------------
- declare (strict_types = 1);
- namespace app\warehouse\controller;
- use app\model\admin\Admin;
- use app\model\admin\AdminMenu;
- use app\model\warehouse\Warehouse;
- use app\Request;
- use library\exceptions\GeneralException;
- use library\lib\weixina;
- use library\services\UtilService;
- use library\utils\Captcha;
- use library\utils\Qiniu;
- use think\facade\Db;
- class Login
- {
- /**
- * 用户登录端
- * @param Request $request
- */
- public function index(Request $request)
- {
- [$account, $pwd, $imgcode] = UtilService::getMore([
- ['account','','empty','请输入登录账户'],
- ['pwd','','empty','请输入登录密码'],
- ['imgcode','','empty','验证码不能为空'],
- ],$request,true);
- if (!(new Captcha)->check($imgcode)) {
- return app('json')->fail('验证码错误,请重新输入');
- }
- //获取登录
- $adminInfo = Warehouse::login($account,$pwd);
- if(empty($adminInfo)) {
- return app('json')->fail(Warehouse::getErrorInfo('用户名错误,请重新输入'));
- }
- //生成令牌
- $token = Warehouse::createToken($adminInfo, 'warehouse');
- if(empty($token)) {
- return app('json')->fail(Warehouse::getErrorInfo());
- }
- return app('json')->success([
- 'token' => $token['token'],
- 'expires_time' => $token['params']['exp'],
- 'user_info' => [
- 'id' => $adminInfo->getData('id'),
- 'username' => $adminInfo->getData('username'),
- 'name' => $adminInfo->getData('name'),
- 'lx_name' => $adminInfo->getData('lx_name')
- ],
- ]);
- }
- /**
- * 用户发生退出
- */
- public function logut(){
- }
- /**
- * 验证码
- * @return \app\adminapi\controller\Login|\think\Response
- */
- public function captcha()
- {
- return (new Captcha())->create();
- }
- }
|