Base.php 1.2 KB

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