$layout
$layout : string
布局模板
Ajax异步请求接口
$auth : \app\common\library\Auth
权限Auth
$view : \think\View
$request : \think\Request
__construct(\think\Request $request = null)
构造方法
\think\Request | $request | Request 对象 |
validate(array $data, string|array $validate, array $message = array(), boolean $batch = false, mixed $callback = null) : array|string|true
验证数据
array | $data | 数据 |
string|array | $validate | 验证器名或者验证规则数组 |
array | $message | 提示信息 |
boolean | $batch | 是否批量验证 |
mixed | $callback | 回调方法(闭包) |
<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use think\Lang;
/**
* Ajax异步请求接口
* @internal
*/
class Ajax extends Frontend
{
protected $noNeedLogin = ['lang'];
protected $noNeedRight = ['*'];
protected $layout = '';
/**
* 加载语言包
*/
public function lang()
{
header('Content-Type: application/javascript');
$callback = $this->request->get('callback');
$controllername = input("controllername");
$this->loadlang($controllername);
//强制输出JSON Object
$result = 'define(' . json_encode(Lang::get(), JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE) . ');';
return $result;
}
/**
* 上传文件
*/
public function upload()
{
return action('api/common/upload');
}
}