From b42e20bff89c4835c383cc1872fd5d271c4269de Mon Sep 17 00:00:00 2001 From: "lmr@hainatravel.com" <59361885@qq.com> Date: Fri, 23 Feb 2018 10:27:12 +0800 Subject: [PATCH] fix amp --- application/controllers/info_amp.php | 46 ++++++++++++++++++---------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/application/controllers/info_amp.php b/application/controllers/info_amp.php index 6b68dc18..6369221b 100644 --- a/application/controllers/info_amp.php +++ b/application/controllers/info_amp.php @@ -9,9 +9,10 @@ class Info_amp extends CI_Controller function __construct() { parent::__construct(); - $this->permission->is_admin(); + //$this->permission->is_admin(); $this->load->model('InfoMetas_model'); - //$this->output->enable_profiler(TRUE); + //CORS + header('Access-Control-Allow-Origin:*'); } public function save_amp() @@ -22,22 +23,22 @@ class Info_amp extends CI_Controller $status = $this->input->post('status'); if ($icid && $json && $html && $status) { try { - $this->InfoMetas_model->add($ic_id, 'AMP', $html); - $this->InfoMetas_model->add($ic_id, 'AMP_JSON', $json); - $this->InfoMetas_model->add($ic_id, 'AMP_STATUS', $status); + $this->InfoMetas_model->add($icid, 'AMP', $html); + $this->InfoMetas_model->add($icid, 'AMP_JSON', $json); + $this->InfoMetas_model->add($icid, 'AMP_STATUS', $status); echo json_encode(array( "succ" => true )); } catch(Exception $e) { echo json_encode(array( "succ" => false, - "message" => $e->getMessage() + "message" => "save_amp() -> ".$e->getMessage() )); } } else { echo json_encode(array( "succ" => false, - "message" => "Post para error." + "message" => "save_amp() -> Post para error." )); } } @@ -45,15 +46,28 @@ class Info_amp extends CI_Controller public function load_amp() { $icid = $this->input->post('icid'); - $html = $this->InfoMetas_model->get($ic_id, 'AMP'); - $json = $this->InfoMetas_model->get($ic_id, 'AMP_JSON'); - $status = $this->InfoMetas_model->get($ic_id, 'AMP_STATUS'); - echo json_encode(array( - "icid" => $icid, - "json" => $json, - "html" => $html, - "status" => $status - )); + if (!$icid) { + echo json_encode(array( + "succ" => false, + "message" => "load_amp() -> Post para error." + )); + return false; + } + $json = $this->InfoMetas_model->get($icid, 'AMP_JSON'); + $status = $this->InfoMetas_model->get($icid, 'AMP_STATUS'); + if ($html) { + echo json_encode(array( + "succ" => true, + "icid" => $icid, + "json" => $json, + "status" => $status + )); + } else { + echo json_encode(array( + "succ" => false, + "message" => "load_amp() -> No data error." + )); + } } }