setValue(); self::setViewValue(); } public function setValue() { $this->admin_info = session('admin_info'); $this->admin_id = session('admin_info.id'); //分页参数 $page_no = (int)$this->request->get('page_no'); $this->page_no = $page_no && is_numeric($page_no) ? $page_no : $this->page_no; $page_size = (int)$this->request->get('page_size'); $this->page_size = $page_size && is_numeric($page_size) ? $page_size : $this->page_size; $this->page_size = min($this->page_size, 100); } /** * 设置视图全局变量 */ private function setViewValue() { $app = Config::get('project.'); $this->assign('view_env_name', $app['env_name']); $this->assign('view_admin_name', $app['admin_name']); $this->assign('view_theme_color', $app['theme_color']); $this->assign('view_theme_button', $app['theme_button']); $this->assign('version', $app['version']); $this->assign('front_version', $app['front_version']); $this->assign('storageUrl', UrlServer::getFileUrl('/')); $this->assignJs('image_upload_url', Url::build('file/image')); } /** * User: 意象信息科技 lr * Desc: 请求成功 * @param string $msg * @param array $data * @param int $code * @param int $show * @param array $header */ protected function _success($msg = '', $data = [], $code = 1, $show = 0, $wait = 3, $url = '', array $header = []) { $type = $this->getResponseType(); $time = Debug::getUseTime(); $result = [ 'code' => $code, 'msg' => $msg, 'data' => $data, 'show' => $show, 'time' => $time, 'wait' => $wait, 'url' => $url, ]; $type = $this->getResponseType(); // 把跳转模板的渲染下沉,这样在 response_send 行为里通过getData()获得的数据是一致性的格式 if ('html' == strtolower($type)) { $type = 'jump'; } $response = Response::create($result, $type)->header($header)->options(['jump_template' => $this->app['config']->get('dispatch_success_tmpl')]); throw new HttpResponseException($response); } /** * User: 意象信息科技 lr * Desc: 请求失败 * @param string $msg * @param array $data * @param int $code * @param int $show * @param array $header */ protected function _error($msg = '', $data = [], $code = 0, $show = 1, $wait = 3, $url = '', array $header = []) { $type = $this->getResponseType(); $time = Debug::getUseTime(); $result = [ 'code' => $code, 'msg' => $msg, 'data' => $data, 'show' => $show, 'time' => $time, 'wait' => $wait, 'url' => $url, ]; if ('html' == strtolower($type)) { $type = 'jump'; } $response = Response::create($result, $type)->header($header)->options(['jump_template' => $this->app['config']->get('dispatch_error_tmpl')]); throw new HttpResponseException($response); } /** * User: 意象信息科技 lr * Desc: 通过返回 * @param $data */ protected function successOrError($data) { if ($data['code'] == 1) { $this->_success($data['msg'], $data['data'], $data['code'], $data['show']); } $this->_error($data['msg'], $data['data'], $data['code'], $data['show']); } protected function assignJs($name, $value) { $this->js_data[$name] = $value; $js_code = ""; $this->assign('js_code', $js_code); } }