You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
3.0 KiB
72 lines
3.0 KiB
|
3 years ago
|
// common/http.interceptor.js
|
||
|
|
|
||
|
|
// 这里的Vue为Vue对象(非创建出来的实例),vm为main.js中“Vue.use(httpInterceptor, app)”这一句的第二个参数,
|
||
|
|
// 为一个Vue的实例,也即每个页面的"this"
|
||
|
|
// 如果需要了解这个install方法是什么,请移步:https://uviewui.com/components/vueUse.html
|
||
|
|
const install = (Vue, vm) => {
|
||
|
|
|
||
|
|
var userToken1 =""
|
||
|
|
var userKey1 =""
|
||
|
|
|
||
|
|
// 延迟才能取到缓存数据
|
||
|
|
setTimeout(()=>{
|
||
|
|
console.log("vm.$store.state.apiPass")
|
||
|
|
console.log(vm.$store.state.apiPass)
|
||
|
|
if (vm.$store.state.apiPass==2) {
|
||
|
|
|
||
|
|
// console.log(sessionStorage.getItem('key'))
|
||
|
|
// if (vm.$store.state.userKey==''||vm.$store.state.userToken=='') {
|
||
|
|
// window.location.href = 'https://www.hxgk.group/jumpapiurl/webindex?url=http://new.hxgk.group/sj/index.html&errorurl=http://new.hxgk.group/sj/index.html#/pages/login/login';
|
||
|
|
// }else if(vm.$store.state.userKey==undefined||vm.$store.state.userToken==undefined){
|
||
|
|
// window.location.href = 'https://www.hxgk.group/jumpapiurl/webindex?url=http://new.hxgk.group/sj/index.html&errorurl=http://new.hxgk.group/sj/index.html#/pages/login/login';
|
||
|
|
// }
|
||
|
|
userToken1=vm.$store.state.userToken
|
||
|
|
userKey1=vm.$store.state.userKey
|
||
|
|
|
||
|
|
}
|
||
|
|
},200);
|
||
|
|
// setTimeout(()=>{
|
||
|
|
// console.log(sessionStorage.getItem('key'))
|
||
|
|
// if (vm.$store.state.userKey==''||vm.$store.state.userToken=='') {
|
||
|
|
// window.location.href = 'https://www.hxgk.group/jumpapiurl/webindex?url=http://new.hxgk.group/sj/index.html&errorurl=http://new.hxgk.group/sj/index.html#/pages/login/login';
|
||
|
|
// }else if(vm.$store.state.userKey==undefined||vm.$store.state.userToken==undefined){
|
||
|
|
// window.location.href = 'https://www.hxgk.group/jumpapiurl/webindex?url=http://new.hxgk.group/sj/index.html&errorurl=http://new.hxgk.group/sj/index.html#/pages/login/login';
|
||
|
|
// }
|
||
|
|
// console.log("userTokenuserTokenuserToken")
|
||
|
|
// userToken1=vm.$store.state.userToken
|
||
|
|
// userKey1=vm.$store.state.userKey
|
||
|
|
// },200);
|
||
|
|
// setTimeout(()=>{
|
||
|
|
// // console.log(sessionStorage.getItem('key'))
|
||
|
|
// if (vm.$store.state.userKey==''||vm.$store.state.userToken=='') {
|
||
|
|
// window.location.href = 'https://www.hxgk.group/jumpapiurl/webindex?url=http://new.hxgk.group/sj/index.html';
|
||
|
|
// }else if(vm.$store.state.userKey==undefined||vm.$store.state.userToken==undefined){
|
||
|
|
// window.location.href = 'https://www.hxgk.group/jumpapiurl/webindex?url=http://new.hxgk.group/sj/index.html';
|
||
|
|
// }
|
||
|
|
// userToken1=vm.$store.state.userToken
|
||
|
|
// userKey1=vm.$store.state.userKey
|
||
|
|
// },200);
|
||
|
|
setTimeout(()=>{
|
||
|
|
Vue.prototype.$u.http.setConfig({
|
||
|
|
// baseUrl: 'http://hxgk.user.phone/api',
|
||
|
|
baseUrl: 'http://new.hxgk.group/api',
|
||
|
|
loadingText: '努力加载中~',
|
||
|
|
loadingTime: 800,
|
||
|
|
// 设置自定义头部content-type
|
||
|
|
header: {
|
||
|
|
'user-token': userToken1,
|
||
|
|
"user-key": userKey1,
|
||
|
|
// 'user-token': 'd0b27f36e0d7dfdf883dfe0000069ca182078ed2',
|
||
|
|
// "user-key": '4fb8e8697c366be03e8fc96319b98524'
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},500);
|
||
|
|
|
||
|
|
|
||
|
|
// 此为自定义配置参数,具体参数见上方说明
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
export default {
|
||
|
|
install
|
||
|
|
}
|