|
@@ -1,3 +1,4 @@
|
|
|
+import Vue from 'vue'
|
|
|
import axios from 'axios'
|
|
|
import router from '../router'
|
|
|
import { getCookieValue } from '../utils'
|
|
@@ -17,11 +18,14 @@ if (platform.isAlipay) {
|
|
|
} else if (platform.isWeixin) {
|
|
|
tingbangSource = 'wechat'
|
|
|
}
|
|
|
-// todo wechatToken
|
|
|
+
|
|
|
// Add a request interceptor
|
|
|
request.interceptors.request.use(request => {
|
|
|
request.headers.token = getCookieValue('afhousetoken')
|
|
|
request.headers.tingbangSource = tingbangSource
|
|
|
+ if (platform.isWeixin) {
|
|
|
+ request.headers.wechatToken = getCookieValue('afhousewechatToken')
|
|
|
+ }
|
|
|
return request
|
|
|
}, error => {
|
|
|
// Do something with request error
|
|
@@ -33,6 +37,7 @@ request.interceptors.response.use(response => {
|
|
|
// Do something with response data
|
|
|
const { code, authorizeUrl } = response.data
|
|
|
if (code === 301 && authorizeUrl) {
|
|
|
+ Vue.cookie.delete('afhousewechatToken')
|
|
|
location.replace(authorizeUrl)
|
|
|
} else if (code === 403) {
|
|
|
router.push('/login')
|