|  | @@ -13,7 +13,7 @@ class Base extends Api
 | 
	
		
			
				|  |  |      protected $noNeedRight = ['*'];
 | 
	
		
			
				|  |  |      //设置返回的会员字段
 | 
	
		
			
				|  |  |      protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score', 'level', 'bio', 'balance', 'money', 'gender'];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    protected $platformKey;
 | 
	
		
			
				|  |  |      public function _initialize()
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -29,6 +29,15 @@ class Base extends Api
 | 
	
		
			
				|  |  |          parent::_initialize();
 | 
	
		
			
				|  |  |          Config::set('default_return_type', 'json');
 | 
	
		
			
				|  |  |          Auth::instance()->setAllowFields($this->allowFields);
 | 
	
		
			
				|  |  | +        $platform = $this->request->header('platform');
 | 
	
		
			
				|  |  | +         // 需要转换   前段穿 DouyinMiniProgram  后端配置是   douyin_mini_program
 | 
	
		
			
				|  |  | +        $platformKey = $this->convertPlatformName($platform);
 | 
	
		
			
				|  |  | +        $this->platformKey = $platformKey;
 | 
	
		
			
				|  |  | +        $platformConfig = shop_config('shop.platform.' . $platformKey);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (empty($platformConfig['status']) || !$platformConfig['status']) {
 | 
	
		
			
				|  |  | +            $this->error('暂不支持该平台,请前往商城配置启用对应平台');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //判断站点状态
 | 
	
		
			
				|  |  |          // if (isset($config['openedsite']) && !in_array('uniapp', explode(',', $config['openedsite']))) {
 | 
	
	
		
			
				|  | @@ -45,4 +54,17 @@ class Base extends Api
 | 
	
		
			
				|  |  |          // Lang::load(ADDON_PATH . 'shop/lang/' . $lang . '/' . str_replace('.', '/', $controllername) . '.php');
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +     /**
 | 
	
		
			
				|  |  | +     * 转换平台名称格式
 | 
	
		
			
				|  |  | +     * 将前端驼峰命名转换为后端下划线格式
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param string $platform
 | 
	
		
			
				|  |  | +     * @return string
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    protected function convertPlatformName($platform)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        // 将驼峰命名转换为下划线格式
 | 
	
		
			
				|  |  | +        return strtolower(preg_replace('/([A-Z])/', '_$1', lcfirst($platform)));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |