0, 'msg' => "", 'data' => $data, ]; return json($rs); } //ErrorCode:需要code/msg参数 static public function ErrorCode($code, $msg) { $rs = [ 'code' => $code, 'msg' => $msg, 'data' => "", ]; return json($rs); } //error,传入定义的数组常量 static public function Error($arr) { $rs = [ 'code' => $arr['code'], 'msg' => $arr['msg'], 'data' => "", ]; return json($rs); } /** * 通用化API数据格式输出 * @param $status * @param string $message * @param array $data * @param int $httpStatus * @return \think\response\Json */ static public function show($status, $message = 'error', $data = [], $httpStatus = 200) { $result = [ "status" => $status, "message" => $message, "result" => $data ]; return json($result, $httpStatus); } }