|
|
|
@ -23,8 +23,8 @@ const install = (Vue, vm) => {
|
|
|
|
// 请求拦截部分,如配置,每次请求前都会执行
|
|
|
|
// 请求拦截部分,如配置,每次请求前都会执行
|
|
|
|
Vue.prototype.$u.http.interceptor.request = (config) => {
|
|
|
|
Vue.prototype.$u.http.interceptor.request = (config) => {
|
|
|
|
console.log('config-http', config)
|
|
|
|
console.log('config-http', config)
|
|
|
|
let xtt_lifeData2 = uni.getStorageSync('xtt_lifeData2')
|
|
|
|
let xtt_lifeData3 = uni.getStorageSync('xtt_lifeData3')
|
|
|
|
let vuex_token = xtt_lifeData2.vuex_token;
|
|
|
|
let vuex_token = xtt_lifeData3.vuex_token;
|
|
|
|
if (vuex_token || vm.vuex_token) {
|
|
|
|
if (vuex_token || vm.vuex_token) {
|
|
|
|
config.header['Authorization'] = `Bearer ${vuex_token || vm.vuex_token}`;
|
|
|
|
config.header['Authorization'] = `Bearer ${vuex_token || vm.vuex_token}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -43,12 +43,11 @@ const install = (Vue, vm) => {
|
|
|
|
confirmText: '重新获取',
|
|
|
|
confirmText: '重新获取',
|
|
|
|
success: function(res) {
|
|
|
|
success: function(res) {
|
|
|
|
if (res.confirm) {
|
|
|
|
if (res.confirm) {
|
|
|
|
uni.removeStorageSync('xtt_lifeData2')
|
|
|
|
uni.removeStorageSync('xtt_lifeData3')
|
|
|
|
uni.login({
|
|
|
|
uni.login({
|
|
|
|
provider: 'weixin',
|
|
|
|
provider: 'weixin',
|
|
|
|
success: (res) => {
|
|
|
|
success: (res) => {
|
|
|
|
let url = baseUrl +
|
|
|
|
let url = baseUrl + '/api/mobile/user/login'
|
|
|
|
'/api/mobile/user/login'
|
|
|
|
|
|
|
|
uni.request({
|
|
|
|
uni.request({
|
|
|
|
url: url,
|
|
|
|
url: url,
|
|
|
|
data:{
|
|
|
|
data:{
|
|
|
|
@ -57,31 +56,34 @@ const install = (Vue, vm) => {
|
|
|
|
method: 'GET',
|
|
|
|
method: 'GET',
|
|
|
|
success: result => {
|
|
|
|
success: result => {
|
|
|
|
console.log("result",result)
|
|
|
|
console.log("result",result)
|
|
|
|
uni.setStorageSync("xtt_lifeData2",{'vuex_token':result.data.token})
|
|
|
|
uni.setStorageSync("xtt_lifeData3",{'vuex_token':result.data.token})
|
|
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
|
|
url: '/pages/home/home'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const currentPage =
|
|
|
|
|
|
|
|
// getCurrentPages()[
|
|
|
|
|
|
|
|
// getCurrentPages()
|
|
|
|
|
|
|
|
// .length - 1];
|
|
|
|
|
|
|
|
// const currentPagePath =
|
|
|
|
|
|
|
|
// "/" + currentPage.route;
|
|
|
|
|
|
|
|
// const currentPageOptions =
|
|
|
|
|
|
|
|
// currentPage.options;
|
|
|
|
|
|
|
|
// const queryString = Object
|
|
|
|
|
|
|
|
// .keys(
|
|
|
|
|
|
|
|
// currentPageOptions)
|
|
|
|
|
|
|
|
// .map(key =>
|
|
|
|
|
|
|
|
// `${key}=${currentPageOptions[key]}`
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
// .join('&');
|
|
|
|
|
|
|
|
// // 使用uni.reLaunch方法刷新当前页面
|
|
|
|
|
|
|
|
|
|
|
|
const currentPage =
|
|
|
|
// uni.reLaunch({
|
|
|
|
getCurrentPages()[
|
|
|
|
// url: `${currentPagePath}?${queryString}`
|
|
|
|
getCurrentPages()
|
|
|
|
// });
|
|
|
|
.length - 1];
|
|
|
|
// console.log("reLaunch",
|
|
|
|
const currentPagePath =
|
|
|
|
// `${currentPagePath}?${queryString}`
|
|
|
|
"/" + currentPage.route;
|
|
|
|
// )
|
|
|
|
const currentPageOptions =
|
|
|
|
|
|
|
|
currentPage.options;
|
|
|
|
|
|
|
|
const queryString = Object
|
|
|
|
|
|
|
|
.keys(
|
|
|
|
|
|
|
|
currentPageOptions)
|
|
|
|
|
|
|
|
.map(key =>
|
|
|
|
|
|
|
|
`${key}=${currentPageOptions[key]}`
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.join('&');
|
|
|
|
|
|
|
|
// 使用uni.reLaunch方法刷新当前页面
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
|
|
url: `${currentPagePath}?${queryString}`
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log("reLaunch",
|
|
|
|
|
|
|
|
`${currentPagePath}?${queryString}`
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|