| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- // +----------------------------------------------------------------------
- // | likeshop开源商城系统
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | gitee下载:https://gitee.com/likeshop_gitee
- // | github下载:https://github.com/likeshop-github
- // | 访问官网:https://www.likeshop.cn
- // | 访问社区:https://home.likeshop.cn
- // | 访问手册:http://doc.likeshop.cn
- // | 微信公众号:likeshop技术社区
- // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
- // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
- // | 禁止对系统程序代码以任何目的,任何形式的再发布
- // | likeshop团队版权所有并拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeshop.cn.team
- // +----------------------------------------------------------------------
- namespace app\admin\logic;
- use app\common\basics\Logic;
- use app\common\model\Admin;
- use app\common\server\ConfigServer;
- use think\facade\Cookie;
- /**
- * 后台登录 逻辑
- * Class LoginLogic
- * @Author FZR
- * @package app\admin\logic
- */
- class LoginLogic extends Logic
- {
- /**
- * Notes: 登录
- * @param $post
- * @author 段誉(2021/4/10 10:40)
- * @return bool
- */
- public static function login($post)
- {
- $adminModel = new Admin();
- $admin_info = $adminModel
- ->field(['id', 'account', 'name', 'role_id'])
- ->where(['account' => $post['account'], 'del' => 0])
- ->findOrEmpty()->toArray();
- //session
- session('admin_info', $admin_info);
- //登录信息更新
- $adminModel->where(['account' => $post['account']])
- ->update([
- 'login_ip' => request()->ip(),
- 'login_time' => time()
- ]);
- //记住账号
- if (isset($post['remember_account']) && $post['remember_account'] == 'on') {
- Cookie::set('account', $post['account']);
- } else {
- Cookie::delete('account');
- }
- return true;
- }
- /**
- * Notes: 退出
- * @author 段誉(2021/4/10 10:40)
- */
- public static function logout()
- {
- session('admin_info', null);
- }
- public static function config()
- {
- $config = [
- 'company_name' => ConfigServer::get('copyright', 'company_name'),
- 'number' => ConfigServer::get('copyright', 'number'),
- 'link' => ConfigServer::get('copyright', 'link'),
- 'login_logo' => ConfigServer::get('website_platform', 'platform_login_logo'),
- 'login_image' => ConfigServer::get('website_platform', 'platform_login_image'),
- 'login_title' => ConfigServer::get('website_platform', 'platform_login_title'),
- 'name' => ConfigServer::get('website', 'name'),
- 'web_favicon' => ConfigServer::get('website', 'web_favicon'),
- ];
- return $config;
- }
- }
|