diff --git a/src/api/index.js b/src/api/index.js index 00e7767..02eafab 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -6,6 +6,7 @@ const request = (url, method, query = {}, data = {}) => { const token = uni.getStorageSync('token') const userId = uni.getStorageSync('userId') || '' const username = uni.getStorageSync('username') || '' + const role = uni.getStorageSync('role') || '' // 特殊情况:入库和库存调整需要 form-urlencoded 格式 const useFormData = (url.includes('/stock/in') || url.includes('/stock/adjust')) && Object.keys(data).length > 0 @@ -27,7 +28,8 @@ const request = (url, method, query = {}, data = {}) => { 'Content-Type': useFormData ? 'application/x-www-form-urlencoded' : 'application/json', 'Authorization': token ? `Bearer ${token}` : '', 'X-User-Id': userId, - 'X-Username': username + 'X-Username': username, + 'X-User-Role': role }, success: (res) => { if (res.data.code === 0) {