<?php
namespace app\api\controller;
use Firebase\JWT\JWT;
use think\facade\Request;

class Base extends \app\BaseController
{

    public function __construct(\think\App $app)
    {
        parent::__construct($app);

        if(Request::header("token")){
            $decodeData= (array)JWT::decode(Request::header('token'),config('app.jwt_key'),array("HS256"));
            $this->uid = $decodeData['uid'];
        } else {
            echo json_encode(['code'=>401,'msg'=>"token不存在!"]);exit;
        }

    }
}