objMPage = new MPage($this->onlineUserId, $this->onlineEnterpriseId); } /** * 添加,编辑 页面数据 * @return array */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if (empty($params)) { parent::sendOutput('参数为空', ErrorCode::$paramError); } $data = [ 'pageType' => isset($params['pageType']) ? $params['pageType'] : StatusCode::$pageType['home'],//页面类型 'pageName' => isset($params['pageName']) ? $params['pageName'] : '首页',//页面名称 'pageData' => isset($params['pageData']) ? json_encode($params['pageData']) : [], ]; foreach ($data as $key => $value) { if (empty($value) && $value !== 0) { parent::sendOutput($key . '参数错误', ErrorCode::$paramError); } } $data['isStore'] = ( isset($params['isStore']) && $params['isStore'] == true ) ? $params['isStore'] : false; if (isset($params['id'])) $data['id'] = $params['id']; return $data; } /** * 保存页面 */ public function save() { $data = $this->commonFieldFilter(); $isStore = $data['isStore']; unset($data['isStore']); $result = $this->objMPage->save($data,$isStore,$this->shopId); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * 获取页面信息 */ public function getPageInfo() { $id = $this->request->param('request_id'); if (empty($id)) { parent::sendOutput('参数错误', ErrorCode::$paramError); } $result = $this->objMPage->getPageInfo($id); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * 启用此页面/禁用此页面 */ public function updateEnableStatus() { $params = $this->request->getRawJson(); if (empty($params['id']) && empty($params['enableStatus']) && empty($params['pageType'])) { parent::sendOutput('参数为空', ErrorCode::$paramError); } $result = $this->objMPage->updateEnableStatus($params); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * 删除页面 */ public function del() { $id = $this->request->param('request_id'); if (empty($id)) { parent::sendOutput('参数错误', ErrorCode::$paramError); } $result = $this->objMPage->del($id); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * 获取页面列表 */ public function getAll() { $params = $this->request->getRawJson(); if (empty($params)) { parent::sendOutput('参数为空', ErrorCode::$paramError); } $pageParams = pageToOffset(isset($params['page']) ? $params['page'] : 1, isset($params['pageSize']) ? $params['pageSize'] : 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $selectParams['shopId'] = 0; !empty($this->shopId) && $selectParams['shopId'] = $this->shopId; $result = $this->objMPage->getAll($selectParams); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => isset($params['page']) ? $params['page'] : 1, 'pageSize' => isset($params['pageSize']) ? $params['pageSize'] : 10, 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * 获取专题 */ public function getSpecial() { $params = $this->request->getRawJson(); $pageParams = pageToOffset(isset($params['page']) ? $params['page'] : 1, isset($params['pageSize']) ? $params['pageSize'] : 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; if (isset($params['id']) && !empty($params['id'])) { $selectParams['id'] = $params['id']; } $selectParams['shopId'] = 0; !empty($this->shopId) && $selectParams['shopId'] = $this->shopId; $result = $this->objMPage->getSpecial($selectParams); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => isset($params['page']) ? $params['page'] : 1, 'pageSize' => isset($params['pageSize']) ? $params['pageSize'] : 10, 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } parent::sendOutput($result->getData(), $result->getErrorCode()); } }