zhaojs
2023-05-16 ea24ddd0b978cbd3b0a900711b49b8a9c2db4186
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?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();
    }
 
    
 
}