|
|
@@ -34,6 +34,8 @@ class webApp extends BaseController
|
|
|
protected $validate;
|
|
|
// 登录ID
|
|
|
protected $userId = 0;
|
|
|
+ // 登录店铺ID
|
|
|
+ protected $shopId = 0;
|
|
|
// 登录信息
|
|
|
protected $userInfo = [];
|
|
|
|
|
|
@@ -45,11 +47,14 @@ class webApp extends BaseController
|
|
|
*/
|
|
|
public function __construct()
|
|
|
{
|
|
|
+
|
|
|
+ parent::__construct();
|
|
|
+
|
|
|
// 初始化分页参数
|
|
|
$this->initConfig();
|
|
|
|
|
|
// 登录检测中间件
|
|
|
- $this->middleware('web.login');
|
|
|
+// $this->middleware('web.login');
|
|
|
|
|
|
// 初始化登录信息
|
|
|
$this->middleware(function ($request, $next) {
|
|
|
@@ -57,14 +62,10 @@ class webApp extends BaseController
|
|
|
$token = $request->headers->get('Authorization');
|
|
|
$token = str_replace("Bearer ", null, $token);
|
|
|
|
|
|
- if($token == 'app123'){
|
|
|
- $userId = ConfigService::make()->getConfigByCode('test_uid');
|
|
|
- $userId = $userId? $userId : 58;
|
|
|
- }else{
|
|
|
- // JWT解密token
|
|
|
- $jwt = new Jwt('jwt_app');
|
|
|
- $userId = $jwt->verifyToken($token);
|
|
|
- }
|
|
|
+ // JWT解密token
|
|
|
+ $jwt = new Jwt('jwt_app');
|
|
|
+ $userId = $jwt->verifyToken($token);
|
|
|
+
|
|
|
|
|
|
// 登录验证
|
|
|
$userInfo = RedisService::get("stores:auths:info:{$userId}");
|
|
|
@@ -72,6 +73,7 @@ class webApp extends BaseController
|
|
|
$this->initLogin($userId);
|
|
|
}else{
|
|
|
$this->userId = $userId;
|
|
|
+ $this->shopId = isset($userInfo['login_shop_id'])? $userInfo['login_shop_id'] : 0;
|
|
|
$this->userInfo = $userInfo;
|
|
|
}
|
|
|
|
|
|
@@ -92,6 +94,7 @@ class webApp extends BaseController
|
|
|
// 分页基础默认值
|
|
|
defined('PERPAGE') or define('PERPAGE', isset($this->param['limit']) ? $this->param['limit'] : 20);
|
|
|
defined('PAGE') or define('PAGE', isset($this->param['page']) ? $this->param['page'] : 1);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -111,85 +114,13 @@ class webApp extends BaseController
|
|
|
$memberModel = new MemberModel();
|
|
|
$userInfo = $memberModel->getInfo($this->userId);
|
|
|
$this->userInfo = $userInfo;
|
|
|
+ $this->shopId = isset($userInfo['login_shop_id'])? $userInfo['login_shop_id'] : 0;
|
|
|
RedisService::set("auths:info:{$userId}", $this->userInfo, 4*24*3600);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 初始化请求配置
|
|
|
- * @since 2020/11/10
|
|
|
- * @author wesmiler
|
|
|
- */
|
|
|
- private function initRequestConfig()
|
|
|
- {
|
|
|
- // 定义是否GET请求
|
|
|
- defined('IS_GET') or define('IS_GET', \request()->isMethod('GET'));
|
|
|
-
|
|
|
- // 定义是否POST请求
|
|
|
- defined('IS_POST') or define('IS_POST', \request()->isMethod('POST'));
|
|
|
-
|
|
|
- // 定义是否AJAX请求
|
|
|
- defined('IS_AJAX') or define('IS_AJAX', \request()->ajax());
|
|
|
-
|
|
|
- // 定义是否PAJAX请求
|
|
|
- defined('IS_PJAX') or define('IS_PJAX', \request()->pjax());
|
|
|
-
|
|
|
- // 定义是否PUT请求
|
|
|
- defined('IS_PUT') or define('IS_PUT', \request()->isMethod('PUT'));
|
|
|
|
|
|
- // 定义是否DELETE请求
|
|
|
- defined('IS_DELETE') or define('IS_DELETE', \request()->isMethod('DELETE'));
|
|
|
-
|
|
|
- // 请求方式
|
|
|
- defined('REQUEST_METHOD') or define('REQUEST_METHOD', \request()->method());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 初始化系统常量
|
|
|
- * @author wesmiler
|
|
|
- * @since 2020/11/10
|
|
|
- */
|
|
|
- private function initSystemConst()
|
|
|
- {
|
|
|
- // 项目根目录
|
|
|
- defined('ROOT_PATH') or define('ROOT_PATH', base_path());
|
|
|
-
|
|
|
- // 文件上传目录
|
|
|
- defined('ATTACHMENT_PATH') or define('ATTACHMENT_PATH', base_path('public/uploads'));
|
|
|
-
|
|
|
- // 图片上传目录
|
|
|
- defined('IMG_PATH') or define('IMG_PATH', base_path('public/uploads/images'));
|
|
|
-
|
|
|
- // 临时存放目录
|
|
|
- defined('UPLOAD_TEMP_PATH') or define('UPLOAD_TEMP_PATH', ATTACHMENT_PATH . "/img");
|
|
|
-
|
|
|
- // 文件存放目录
|
|
|
- defined('UPLOAD_FILE_PATH') or define('UPLOAD_FILE_PATH', ATTACHMENT_PATH . "/file");
|
|
|
-
|
|
|
- // cert目录
|
|
|
- defined('WECHAT_PAY_CERT_PATH') or define('WECHAT_PAY_CERT_PATH', base_path('public/certs'));
|
|
|
-
|
|
|
- // 定义普通图片域名
|
|
|
- defined('IMG_URL') or define('IMG_URL', env('IMG_URL'));
|
|
|
-
|
|
|
- // 数据表前缀
|
|
|
- defined('DB_PREFIX') or define('DB_PREFIX', DB::connection()->getTablePrefix());
|
|
|
-
|
|
|
- // 系统全称
|
|
|
- defined('SITE_NAME') or define('SITE_NAME', env('SITE_NAME'));
|
|
|
- // 系统简称
|
|
|
- defined('NICK_NAME') or define('NICK_NAME', env('NICK_NAME'));
|
|
|
- // 系统版本号
|
|
|
- defined('VERSION') or define('VERSION', env('VERSION'));
|
|
|
-
|
|
|
- // 请求参数
|
|
|
- $this->param = \request()->input();
|
|
|
-
|
|
|
- // 分页基础默认值
|
|
|
- defined('PERPAGE') or define('PERPAGE', isset($this->param['limit']) ? $this->param['limit'] : 20);
|
|
|
- defined('PAGE') or define('PAGE', isset($this->param['page']) ? $this->param['page'] : 1);
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 获取数据列表
|