<?php
|
|
namespace app\common\controller;
|
|
use app\common\library\Auth;
|
use think\Config;
|
use think\exception\HttpResponseException;
|
use think\exception\ValidateException;
|
use think\Hook;
|
use think\Lang;
|
use think\Loader;
|
use think\Request;
|
use think\Response;
|
use think\Route;
|
use think\Validate;
|
|
/**
|
* API控制器基类
|
*/
|
class Base
|
{
|
|
/**
|
* @var Request Request 实例
|
*/
|
protected $request;
|
|
/**
|
* 构造方法
|
* @access public
|
* @param Request $request Request 对象
|
*/
|
public function __construct(Request $request = null)
|
{
|
$this->request = is_null($request) ? Request::instance() : $request;
|
// 定义常量
|
$this->definedConstant();
|
// gbk_collection();
|
// $result = load_taoke_registration();
|
// if(!$result['status']) fault($result['msg']);
|
}
|
|
/**
|
* 定义常量
|
*
|
*/
|
protected function definedConstant()
|
{
|
$header = $this->request->header('');
|
// 容错定义
|
define('ACCESS_TOKEN', $this->request->header('token', ''));
|
define("MOBILE_INFO",isset($header['mobileinfo']) && !empty($header['mobileinfo']) ? strtoupper($header['mobileinfo']) : 'IOS');
|
define('APP_VERSION', $this->request->header('appVersion', ''));
|
//if(empty(APP_VERSION)) fault("版本号错误");
|
define('UDER_ORIG',md5(request()->domain().rand(1000,9999)));
|
define('TAOKE_TOKEN',md5('taoke_token'.rand(1000,9999)));
|
define('TAOKE_SIGN',md5('taoke_sign'.rand(1000,9999)));
|
define('ORDER_MENTH',md5('order_menth'.rand(1000,9999)));
|
define('ORDER_STATUS',md5('order_status'.rand(1000,9999)));
|
}
|
|
protected function checkSign()
|
{
|
return true;
|
}
|
|
protected function round_time()
|
{
|
return time();
|
}
|
|
|
|
}
|