jsonResponse(1, $msg, $data); } public function success($msg, $data=[], $cookie = null, $jsonp = false) { if (request()->debug) { return view('welcome'); } //增加数据为空值返回统一处理 // if(empty($data)){ // return $this->jsonResponse(1, '数据为空', null); // } return $this->jsonResponse(0, $msg, $data); } public function authFail($msg="未授权登录", $data=[]) { return $this->jsonResponse(2, $msg, $data); } public function banFail($msg="已封号,请联系客服", $data=[]) { return $this->jsonResponse(4, $msg, $data); } private function jsonResponse($code, $msg, $data=[]) { $result = [ 'code'=>$code, 'message'=>$msg, 'data'=>$data, ]; return Response()->json($result); } }