master
王文杰 8 months ago
parent 96a5741c7c
commit d0d49a26e1

@ -396,7 +396,7 @@ page {
} }
.label { .label {
margin: 0 20rpx; margin: 0 10rpx;
} }
} }

@ -11,8 +11,8 @@
* 4. token * 4. token
*/ */
import { useMemberStore } from '@/stores' import { useMemberStore } from '@/stores'
// const baseURL = 'http://192.168.0.166:8808/api' const baseURL = 'http://192.168.0.166:8808/api'
const baseURL = 'http://222.71.165.188:8808/api' // const baseURL = 'http://222.71.165.188:8808/api'
// 添加拦截器 // 添加拦截器
const httpInterceptor = { const httpInterceptor = {
// 拦截前触发 // 拦截前触发
@ -26,13 +26,14 @@ const httpInterceptor = {
// 3. 添加小程序端请求头标识 // 3. 添加小程序端请求头标识
options.header = { options.header = {
...options.header, ...options.header,
authorization: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1c2VyIjp7InVzZXJUeXBlIjoiQ0xJRU5UIiwiaWQiOiIxNzYzNzUyNzkzMzk3NjQ5NDA5IiwidXNlcm5hbWUiOiIxMzYwMTkyMTc0NSIsInBob25lIjoiMTM2MDE5MjE3NDUiLCJvcGVuaWQiOiJvWWtWODY5Wmt3YVpGcEhFUlRUc3IyRWZJdXU0IiwidGltZUV4cGlyZSI6MjU5MjAwMDAwMH0sImV4cCI6MTcxMjI4MjYyMn0.NnbHf8vZd53UkdZ2PoBrFspQAg-ov4q3x_zufxopNY5z9omdnJv0qrzNPiQzvi7SPu3JTVphBC43iW7PYk5VCntBaf9q3SoLqDQItaF0XHHRu72gVCvU5xTWi0fhAflvNwK8PIJXBZ88bGSW8ZobGfWZNe656OHvwOPavfsfOdIM2hzIJS_6PVTg_qlL_J25EIJpoZomSZzinqD3gloWiJX3ncH74AwJ5DDvZzed__dpJaSY1-P_bRd2p2aw6Iazu-9kOZqen_ZCxEe_0elelk3Mh0IfivkS_s55-XNFuVhlog3kGqyX1lFmiA89lUFHuX6P_o4nBPbX1cdg6mi00Q'
} }
// 4. 添加 token 请求头标识 // 4. 添加 token 请求头标识
const memberStore = useMemberStore() const memberStore = useMemberStore()
const token = memberStore.profile?.token const token = memberStore.profile?.token
if (token) { // if (token) {
options.header.authorization = token // options.header.authorization = token
} // }
}, },
} }
uni.addInterceptor('request', httpInterceptor) uni.addInterceptor('request', httpInterceptor)

Loading…
Cancel
Save