Properties

$request

$request : \think\Request

Type

\think\Request — Request 实例

$failException

$failException : boolean

Type

boolean — 验证失败是否抛出异常

$batchValidate

$batchValidate : boolean

Type

boolean — 是否批量验证

$beforeActionList

$beforeActionList : array

Type

array — 前置操作方法列表

$noNeedLogin

$noNeedLogin : array

无需登录的方法,同时也就不需要鉴权了

Type

array

$noNeedRight

$noNeedRight : array

无需鉴权的方法,但需要登录

Type

array

$responseType

$responseType : string

默认响应输出类型,支持json/xml

Type

string

Methods

__construct()

__construct(\think\Request  $request = null) 

构造方法

Parameters

\think\Request $request

Request 对象

_initialize()

_initialize() 

初始化操作

index()

index() 

会员中心

login()

login() 

会员登录

mobilelogin()

mobilelogin() 

手机验证码登录

register()

register() 

注册会员

logout()

logout() 

注销登录

profile()

profile() 

修改会员个人信息

changeemail()

changeemail() 

修改邮箱

changemobile()

changemobile() 

修改手机号

third()

third() 

第三方登录

resetpwd()

resetpwd() 

重置密码

loadlang()

loadlang(string  $name) 

加载语言文件

Parameters

string $name

success()

success(string  $msg = '', mixed  $data = null, integer  $code = 1, string  $type = null, array  $header = array()) 

操作成功返回的数据

Parameters

string $msg

提示信息

mixed $data

要返回的数据

integer $code

错误码,默认为1

string $type

输出类型

array $header

发送的 Header 信息

error()

error(string  $msg = '', mixed  $data = null, integer  $code, string  $type = null, array  $header = array()) 

操作失败返回的数据

Parameters

string $msg

提示信息

mixed $data

要返回的数据

integer $code

错误码,默认为0

string $type

输出类型

array $header

发送的 Header 信息

result()

result(mixed  $msg, mixed  $data = null, integer  $code, string  $type = null, array  $header = array()) : void

返回封装后的 API 数据到客户端

Parameters

mixed $msg

提示信息

mixed $data

要返回的数据

integer $code

错误码,默认为0

string $type

输出类型,支持json/xml/jsonp

array $header

发送的 Header 信息

Throws

\think\exception\HttpResponseException

beforeAction()

beforeAction(string  $method, array  $options = array()) : void

前置操作

Parameters

string $method

前置操作方法名

array $options

调用参数 ['only'=>[...]] 或者 ['except'=>[...]]

validateFailException()

validateFailException(boolean  $fail = true) : $this

设置验证失败后是否抛出异常

Parameters

boolean $fail

是否抛出异常

Returns

$this

validate()

validate(array  $data, string|array  $validate, array  $message = array(), boolean  $batch = false, mixed  $callback = null) : array|string|true

验证数据

Parameters

array $data

数据

string|array $validate

验证器名或者验证规则数组

array $message

提示信息

boolean $batch

是否批量验证

mixed $callback

回调方法(闭包)

Throws

\think\exception\ValidateException

Returns

array|string|true