From 441e1cb71930e7b9aa8a9e9b8214cee643f8043f Mon Sep 17 00:00:00 2001 From: Agent Date: Sun, 29 Mar 2026 15:20:47 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B1=9E=E6=80=A7API?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=92=8C=E6=95=B0=E6=8D=AE=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/product.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/api/product.js b/src/api/product.js index 7b4bdbf..8c3c02f 100644 --- a/src/api/product.js +++ b/src/api/product.js @@ -79,7 +79,19 @@ export default { * 获取种类的属性定义 */ getCategoryAttributes(categoryId) { - return api.request(`/products/categories/${categoryId}/attributes`, 'GET') + const token = uni.getStorageSync('token') + return new Promise((resolve, reject) => { + uni.request({ + url: `${import.meta.env.VITE_API_BASE_URL}/products/categories/${categoryId}/attributes`, + method: 'GET', + header: { 'Authorization': token ? `Bearer ${token}` : '' }, + success: (res) => { + if (res.data.code === 0) resolve(res.data.data) + else reject(res.data) + }, + fail: reject + }) + }) }, /** @@ -87,6 +99,7 @@ export default { */ saveCategoryAttributes(categoryId, attrs) { const token = uni.getStorageSync('token') + const role = uni.getStorageSync('role') || '' return new Promise((resolve, reject) => { uni.request({ url: `${import.meta.env.VITE_API_BASE_URL}/products/categories/${categoryId}/attributes`, @@ -94,7 +107,8 @@ export default { data: attrs, header: { 'Content-Type': 'application/json', - 'Authorization': token ? `Bearer ${token}` : '' + 'Authorization': token ? `Bearer ${token}` : '', + 'X-User-Role': role }, success: (res) => { if (res.data.code === 0) {