先自定义常量
1.文件接口路径 修改核心文件 application\common\controller\Api.php
/**
* 构造方法
* @access public
* @param Request $request Request 对象
*/
public function __construct(Request $request = null)
{
$this->request = is_null($request) ? Request::instance() : $request;
// 控制器初始化
$this->_initialize();
//<--代码位置 -->
if (!defined('IMG_PRE')) {
define("IMG_PRE", $this->request->domain());//定义获取域名常量
// define("IMG_PRE", 'https://yunlingshidai.oss-cn-shanghai.aliyuncs.com');//也可以是云端域名
}
//<--代码位置 -->
// 前置操作方法
if ($this->beforeActionList) {
foreach ($this->beforeActionList as $method => $options) {
is_numeric($method) ?
$this->beforeAction($options) :
$this->beforeAction($method, $options);