diff --git a/convention.php b/convention.php index 6b03dee3..59192283 100644 --- a/convention.php +++ b/convention.php @@ -91,7 +91,8 @@ return [ // +---------------------------------------------------------------------- // 默认跳转页面对应的模板文件 - 'dispatch_jump_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', + 'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', + 'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', // 默认的模板引擎 'template_engine' => 'Think', diff --git a/library/think/Response.php b/library/think/Response.php index 98a01b8b..95e53e4b 100644 --- a/library/think/Response.php +++ b/library/think/Response.php @@ -181,7 +181,7 @@ class Response $type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type'); if ('html' == $type) { - $result = \think\View::instance()->fetch(Config::get('dispatch_jump_tmpl'), $result); + $result = \think\View::instance()->fetch(Config::get('dispatch_success_tmpl'), $result); } self::type($type); return $result; @@ -214,7 +214,7 @@ class Response $type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type'); if ('html' == $type) { - $result = \think\View::instance()->fetch(Config::get('dispatch_jump_tmpl'), $result); + $result = \think\View::instance()->fetch(Config::get('dispatch_error_tmpl'), $result); } self::type($type); return $result; diff --git a/library/traits/controller/Jump.php b/library/traits/controller/Jump.php index c0a67b60..796a8ce4 100644 --- a/library/traits/controller/Jump.php +++ b/library/traits/controller/Jump.php @@ -46,6 +46,20 @@ trait Jump return Response::success($msg, $data, $url, $wait); } + /** + * 返回封装后的API数据到客户端 + * @access public + * @param mixed $data 要返回的数据 + * @param integer $code 返回的code + * @param mixed $msg 提示信息 + * @param string $type 返回数据格式 + * @return mixed + */ + public function result($data, $code = 0, $msg = '', $type = '') + { + return Response::result($data, $code, $msg, $type); + } + /** * URL重定向 * @access protected