From cb2187c0ff3a2c72df67425ac509c8820994b8d3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 29 Nov 2024 20:48:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(api):=20=E4=BC=98=E5=8C=96=20wps=5Fpro?= =?UTF-8?q?duct=20=E6=8E=A5=E5=8F=A3=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增获取 post 数据的第一个键并解码 - 重构了原始的直接解码整个数据的逻辑 --- app/api/controller/IndexController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 3b72c497a..0b2652957 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -285,10 +285,11 @@ class IndexController extends BaseApiController public function wps_product() { $data = $this->request->post(); - return $this->success('ok',$data); - + if ($data) { - $data=json_decode($data,true); + $keys = array_keys($data); // 获取所有键 + $firstKey = $keys[0]; // 获取第一个键 + $data=json_decode($firstKey,true); if ($data['product_id'] > 0) { $find = Db::name('wps_product')->where('product_id', $data['product_id'])->find(); $arr = [];