123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\shop\logic;
-
-
- use app\common\basics\Logic;
- use app\common\model\shop\ShopAdmin;
- use app\common\server\ConfigServer;
- use think\facade\Cookie;
-
-
- class LoginLogic extends Logic
- {
-
-
-
- public static function login($post)
- {
- $adminModel = new ShopAdmin();
- $admin_info = $adminModel->alias('a')
- ->join('shop s', 's.id = a.shop_id')
- ->field(['a.id', 'a.account', 'a.name', 'role_id', 'shop_id', 's.name' => 'shop_name', 's.hksy_type'])
- ->where(['a.account' => $post['account'], 'a.del' => 0])
- ->findOrEmpty()->toArray();
-
-
- session('shop_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;
- }
-
-
-
- public static function logout()
- {
- session('shop_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_shop', 'shop_login_logo'),
- 'login_image' => ConfigServer::get('website_shop', 'shop_login_image'),
- 'login_title' => ConfigServer::get('website_shop', 'shop_login_title'),
-
- 'name' => ConfigServer::get('website', 'name'),
- 'web_favicon' => ConfigServer::get('website', 'web_favicon'),
- ];
- return $config;
- }
-
-
- }
|