From 74df67abf97081e0d42a53834c94ffe66b5544de Mon Sep 17 00:00:00 2001 From: Agent Date: Sun, 29 Mar 2026 15:33:22 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=9B=B4=E6=8E=A5=E5=9C=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=8F=91=E9=80=81=E8=AF=B7=E6=B1=82=E5=B9=B6=E5=8A=A0?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/category/index.vue | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/pages/category/index.vue b/src/pages/category/index.vue index bae3729..491bfd5 100644 --- a/src/pages/category/index.vue +++ b/src/pages/category/index.vue @@ -216,11 +216,30 @@ export default { uni.showToast({ title: '请至少添加一个属性', icon: 'none' }) return } + console.log('准备保存属性:', JSON.stringify(validAttrs)) try { - await productApi.saveCategoryAttributes(this.currentCategory.categoryId, validAttrs) - uni.showToast({ title: '保存成功', icon: 'success' }) - this.closeAttrDialog() + const token = uni.getStorageSync('token') + const role = uni.getStorageSync('role') || '' + const res = await uni.request({ + url: `${import.meta.env.VITE_API_BASE_URL}/products/categories/${this.currentCategory.categoryId}/attributes`, + method: 'POST', + data: { + attributes: validAttrs + }, + header: { + 'Authorization': token ? `Bearer ${token}` : '', + 'X-User-Role': role + } + }) + console.log('保存结果:', res.data) + if (res.data.code === 0) { + uni.showToast({ title: '保存成功', icon: 'success' }) + this.closeAttrDialog() + } else { + uni.showToast({ title: res.data.message || '保存失败', icon: 'none' }) + } } catch (e) { + console.error('保存失败:', e) uni.showToast({ title: '保存失败', icon: 'none' }) } }