From d387487bc564c28c10f494340fab4c252338dfda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B1=95=E9=B9=8F?= Date: Sat, 6 Dec 2025 01:39:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddata-services=E5=B1=9E?= =?UTF-8?q?=E6=80=A7JSON=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E9=80=97=E5=8F=B7=E5=88=86=E9=9A=94?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pending_bookings.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pending_bookings.php b/pending_bookings.php index aa8f1cd..4c09648 100644 --- a/pending_bookings.php +++ b/pending_bookings.php @@ -824,7 +824,21 @@ try { const duration = parseInt(selectedOption.getAttribute('data-duration')); const price = parseFloat(selectedOption.getAttribute('data-price')); const servicesJSON = selectedOption.getAttribute('data-services'); - const services = servicesJSON ? JSON.parse(servicesJSON) : []; + let services = []; + + // 尝试解析servicesJSON,如果解析失败则将其视为逗号分隔字符串 + if (servicesJSON) { + try { + // 尝试作为JSON解析 + services = JSON.parse(servicesJSON); + console.log('✅ Parsed services as JSON:', services); + } catch (e) { + // 如果JSON解析失败,尝试作为逗号分隔字符串处理 + console.log('⚠️ JSON parse failed, treating as comma-separated string:', servicesJSON); + services = servicesJSON.split(',').map(service => service.trim()).filter(service => service.length > 0); + console.log('✅ Converted to array:', services); + } + } console.log('Package data:', {duration, price, services: services.length});