Base.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\user\controller;
  3. use app\BaseController;
  4. use app\common\Ocr;
  5. use think\App;use think\Exception;
  6. class Base extends BaseController{
  7. protected $uid=0;
  8. protected $uname='system';
  9. protected $level=0;
  10. protected $noLogin=[];
  11. protected $token='';
  12. protected $model=null;
  13. protected $keepTime=3600;
  14. public function __construct(App $app) {
  15. parent::__construct($app);
  16. $this->token = $this->request->param('token','','trim');
  17. if (!action_in_arr($this->noLogin)){
  18. if($this->token=='')throw new \Exception("token不能为空",101);
  19. $this->Auth();
  20. }
  21. }
  22. /**授权token鉴定
  23. * @return \think\response\Json|void
  24. */
  25. public function Auth(){
  26. $User = \app\common\User::instance();
  27. $User->init($this->token);
  28. if (!$User->isLogin()) throw new \Exception($User->getError(),$User->getErroCode());
  29. $this->uid = $User->id;
  30. $this->uname = $User->nickname;
  31. $this->level = $User->level;
  32. }
  33. public function GetBusinessInfoByParam($url='',$image=''){
  34. if ($url=="" && $image=="") throw new \Exception("营业执照识别必须上传图片或存在链接");
  35. $ocr= Ocr::getInstance();
  36. $result= $ocr::businessLicense($url,$image);
  37. return $result;
  38. }
  39. }