diff --git a/src/api/product.js b/src/api/product.js index 51f1430..ef907f3 100644 --- a/src/api/product.js +++ b/src/api/product.js @@ -124,13 +124,13 @@ export default { /** * 保存商品的属性值 */ - saveProductAttributes(productId, attrs) { + saveProductAttributes(productId, categoryId, attrs) { const token = uni.getStorageSync('token') return new Promise((resolve, reject) => { uni.request({ url: `${import.meta.env.VITE_API_BASE_URL}/products/${productId}/attributes`, method: 'POST', - data: attrs, + data: { categoryId: categoryId, attributes: attrs }, header: { 'Content-Type': 'application/json', 'Authorization': token ? `Bearer ${token}` : '' diff --git a/src/pages/product/manage.vue b/src/pages/product/manage.vue index f13989b..f91b1c4 100644 --- a/src/pages/product/manage.vue +++ b/src/pages/product/manage.vue @@ -253,7 +253,7 @@ export default { uni.showToast({ title: '创建成功', icon: 'success' }) } - // 保存商品属性值 + // 保存商品属性值(包含公式自动计算) if (productId && this.categoryAttributes.length > 0) { const attrs = this.categoryAttributes.map((attr, idx) => ({ attrId: attr.attrId, @@ -262,7 +262,7 @@ export default { })).filter(a => a.attrValue) if (attrs.length > 0) { - await productApi.saveProductAttributes(productId, attrs) + await productApi.saveProductAttributes(productId, this.form.categoryId, attrs) } }