兼容中台系统

This commit is contained in:
weipengfei 2023-11-22 15:48:06 +08:00
parent fec01de9c0
commit 1d1f6498e9
4 changed files with 67 additions and 10 deletions

54
App.vue
View File

@ -20,6 +20,9 @@
getUserInfo
} from '@/api/user.js';
import {
parseToken
} from "@/api/appLet.js";
import {
HTTP_REQUEST_URL
} from './config/app';
@ -29,6 +32,7 @@
history
} from '@/api/public.js'
import Routine from './libs/routine.js';
import { Toast } from "./libs/uniApi";
export default {
data() {
@ -93,16 +97,52 @@
key: 'launchFlag'
})
//
// parseToken({
// token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjZXNoaS1taWRkbGUubGloYWluay5jbiIsImF1ZCI6ImNlc2hpLW1pZGRsZS5saWhhaW5rLmNuIiwiaWF0IjoxNzAwNjIwMjUxLCJuYmYiOjE3MDA2MjAyNTEsImV4cCI6MTcwMTIyNTA1MSwiZGF0YSI6eyJ1aWQiOjUsInBob25lIjoiMTc2ODUxNTE2NDMiLCJhdmF0YXIiOiIvcmVzb3VyY2UvaW1hZ2UvYWRtaW5hcGkvZGVmYXVsdC9kZWZhdWx0X2F2YXRhci5wbmciLCJuaWNrbmFtZSI6Ilx1NzUyOFx1NjIzNzE3Njg1MTUxNjQzIn19.sTWAHCScRY9FExwJw1MReHTnRBcK7tYu1AMSia_Sm4M'
// }).then((res)=>{
// this.$store.commit("LOGIN", {
// 'token': res.data.token,
// 'time': 604800
// });
// this.$isResolve()
// }).catch((err)=>{
// if(err==''){
// this.$store.commit("LOGIN", {
// 'token': option.referrerInfo?.extraData?.uniMP,
// 'time': 604800
// });
// }else {
// Toast(err);
// }
// this.$isResolve()
// })
if (option?.referrerInfo?.extraData?.uniMP) {
uni.setStorageSync('uniMP', option.referrerInfo?.extraData?.uniMP);
// uni.setStorageSync('APP_token', option.referrerInfo?.extraData?.token);
this.$store.commit("LOGIN", {
'token': option.referrerInfo?.extraData?.token,
'time': 604800
});
}
// this.$store.commit("LOGIN", {
// 'token': option.referrerInfo?.extraData?.token,
// 'time': 604800
// });
parseToken({
token: option.referrerInfo?.extraData?.token
}).then((res)=>{
this.$store.commit("LOGIN", {
'token': res.data.token,
'time': 604800
});
this.$isResolve()
}).catch((err)=>{
this.$store.commit("LOGIN", {
'token': option.referrerInfo?.extraData?.uniMP,
'time': 604800
});
console.log('TOKEN解析错误:', err);
this.$isResolve()
})
}else {
this.$isResolve()
}
// #ifdef APP-PLUS
// #endif

9
api/appLet.js Normal file
View File

@ -0,0 +1,9 @@
import request from "@/utils/request.js";
/**
* 文章详情
*
*/
export function parseToken(data) {
return request.post('parse/token', data, { noAuth: true });
}

View File

@ -34,6 +34,12 @@ Vue.prototype.$eventHub = new Vue();
Vue.config.productionTip = false
Vue.prototype.$bus = new Vue();
// initRouter()
// 让app的onLaunch先执行主要是用来进行登录
Vue.prototype.$onLaunched = new Promise(resolve => {
Vue.prototype.$isResolve = resolve
})
// #ifdef H5
import {
parseQuery

View File

@ -569,9 +569,10 @@
})
},
onLoad() {
this.list1()
async onLoad() {
this.Fheight = uni.getSystemInfoSync().windowHeight + 'px';
await this.$onLaunched;
this.list1()
},
@ -588,7 +589,8 @@
},
onShow() {
async onShow() {
await this.$onLaunched;
this.getUserInfo()
this.codelist()
},