12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\api\controller\energy;
- use app\hander\HelpHander;
- use think\Controller;
- use think\Db;
- class Base extends Controller
- {
- protected $userId;
- protected $orgId;
- protected function initialize()
- {
- parent::initialize();
- // $data = [
- // 'userId' => 1,
- // 'orgId' => 3,
- // 'time' => date('Y-m-d H:i:s')
- // ];
- //
- // $token = think_decrypt(think_encrypt(json_encode($data)));
- $token = think_decrypt(input('token','','trim'));
- if(!$token){
- HelpHander::error('token不正确');
- }
- $tdata = json_decode($token,true);
- // $tdata = json_decode(think_decrypt($token),true);
- if(!$tdata || !isset($tdata['userId']) || !isset($tdata['orgId'])){
- HelpHander::error('token不正确');
- }
- $this->userId = $tdata['userId'];
- $this->orgId = $tdata['orgId'];
- }
- }
|