| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | 
							- <?php
 
- namespace app\api\controller\inspection;
 
- use app\common\controller\Api;
 
- use app\common\library\Auth;
 
- use think\Config;
 
- use think\Lang;
 
- use app\common\Service\InspectionService;
 
- use app\common\model\inspection\InspectionApplication;
 
- class Base extends Api
 
- {
 
-     protected $noNeedLogin = [];
 
-     protected $noNeedRight = ['*'];
 
-     protected $application = null;
 
-     //设置返回的会员字段
 
-     protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score', 'level', 'bio', 'balance', 'money', 'gender'];
 
-     public function _initialize()
 
-     {
 
-         if (isset($_SERVER['HTTP_ORIGIN'])) {
 
-             header('Access-Control-Expose-Headers: __token__');//跨域让客户端获取到
 
-         }
 
-         //跨域检测
 
-         check_cors_request();
 
-         if (!isset($_COOKIE['PHPSESSID'])) {
 
-             Config::set('session.id', $this->request->server("HTTP_SID"));
 
-         }
 
-         parent::_initialize();
 
-         Auth::instance()->setAllowFields($this->allowFields);
 
-         // 查询是否是审核员
 
-         $user = Auth::instance()->getUser();
 
-         $isInspection = null;
 
-         if ($user) {
 
-             $isInspection = InspectionService::getUserApplication($user->id);
 
-             if (!$isInspection) {
 
-               $this->error('您不是审核员');
 
-             }       
 
-             //  验证是否 通过
 
-             if ($isInspection->audit_status !== InspectionApplication::AUDIT_STATUS_PASSED) {
 
-               $this->error('您的验货员申请未通过');
 
-             }
 
-         }    
 
-        
 
-        $this->application = $isInspection;
 
-         //这里手动载入语言包
 
-         Lang::load(ROOT_PATH . '/addons/shop/lang/zh-cn.php');
 
-         Lang::load(APP_PATH . '/index/lang/zh-cn/user.php');
 
-         //加载当前控制器的语言包
 
-         $controllername = strtolower($this->request->controller());
 
-         $lang = $this->request->langset();
 
-         $lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
 
-         Lang::load(ADDON_PATH . 'shop/lang/' . $lang . '/' . str_replace('.', '/', $controllername) . '.php');
 
-     }
 
- }
 
 
  |