From 37c46417c9732745cbef6cff84d4861e95301948 Mon Sep 17 00:00:00 2001 From: Agent Date: Sun, 29 Mar 2026 15:27:41 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A1=AE=E4=BF=9Dpayload=E6=98=AF?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/product.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/product.js b/src/api/product.js index 0bd4197..d5f8079 100644 --- a/src/api/product.js +++ b/src/api/product.js @@ -100,13 +100,15 @@ export default { saveCategoryAttributes(categoryId, attrs) { const token = uni.getStorageSync('token') const role = uni.getStorageSync('role') || '' + // 确保是数组格式 + const payload = Array.isArray(attrs) ? attrs : [attrs] return new Promise((resolve, reject) => { uni.request({ url: `${import.meta.env.VITE_API_BASE_URL}/products/categories/${categoryId}/attributes`, method: 'POST', - data: JSON.stringify(attrs), + data: payload, header: { - 'Content-Type': 'text/plain', + 'Content-Type': 'application/json', 'Authorization': token ? `Bearer ${token}` : '', 'X-User-Role': role },