This commit is contained in:
@@ -4,6 +4,7 @@ const BASE_URL = 'https://sales.violin-work.online/api/v1'
|
|||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
const request = (url, method, data = {}) => {
|
const request = (url, method, data = {}) => {
|
||||||
const token = uni.getStorageSync('token')
|
const token = uni.getStorageSync('token')
|
||||||
|
const userInfo = uni.getStorageSync('userInfo') || {}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.request({
|
uni.request({
|
||||||
@@ -12,7 +13,9 @@ const request = (url, method, data = {}) => {
|
|||||||
data: data,
|
data: data,
|
||||||
header: {
|
header: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': token ? `Bearer ${token}` : ''
|
'Authorization': token ? `Bearer ${token}` : '',
|
||||||
|
'X-User-Id': userInfo.userId || '',
|
||||||
|
'X-Username': userInfo.username || ''
|
||||||
},
|
},
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.data.code === 0) {
|
if (res.data.code === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user