fix: 登录后保存role,API请求携带X-User-Role头
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -6,6 +6,7 @@ const request = (url, method, query = {}, data = {}) => {
|
|||||||
const token = uni.getStorageSync('token')
|
const token = uni.getStorageSync('token')
|
||||||
const userId = uni.getStorageSync('userId') || ''
|
const userId = uni.getStorageSync('userId') || ''
|
||||||
const username = uni.getStorageSync('username') || ''
|
const username = uni.getStorageSync('username') || ''
|
||||||
|
const role = uni.getStorageSync('role') || ''
|
||||||
|
|
||||||
// 特殊情况:入库和库存调整需要 form-urlencoded 格式
|
// 特殊情况:入库和库存调整需要 form-urlencoded 格式
|
||||||
const useFormData = (url.includes('/stock/in') || url.includes('/stock/adjust')) && Object.keys(data).length > 0
|
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',
|
'Content-Type': useFormData ? 'application/x-www-form-urlencoded' : 'application/json',
|
||||||
'Authorization': token ? `Bearer ${token}` : '',
|
'Authorization': token ? `Bearer ${token}` : '',
|
||||||
'X-User-Id': userId,
|
'X-User-Id': userId,
|
||||||
'X-Username': username
|
'X-Username': username,
|
||||||
|
'X-User-Role': role
|
||||||
},
|
},
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.data.code === 0) {
|
if (res.data.code === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user