单点修改
This commit is contained in:
1 parent
3c70d63a54
commit
27f5a5fb8e
2 files changed
+51
-9
No files matched your search
+41
-8
@@ -23,6 +23,29 @@ const state = reactive<any>({
|
||||
|
||||
|
||||
onLoad((options) => {
|
||||
window.CP2.getAppInfo().then((res) => {
|
||||
console.log(res);
|
||||
if (res.code==1){
|
||||
//诗画
|
||||
console.log("诗画环境")
|
||||
window.CP2.getUserInfo().then((res) => {
|
||||
let accountId=res.data.accountId;
|
||||
let sessionId=res.sessionId;
|
||||
doLogin(1,null,accountId,sessionId)
|
||||
});
|
||||
}else {
|
||||
//浙政钉或者h5
|
||||
const url = window.location.href;
|
||||
const params = new URL(url).searchParams;
|
||||
const token = params.get('uabaseToken'); // 获取 uabaseToken 参数值
|
||||
console.log('Token:', token);
|
||||
if (null!=token){
|
||||
//浙政钉
|
||||
doLogin(2,token,null,null)
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
onShow(() => {
|
||||
getUserInfo()
|
||||
@@ -36,7 +59,7 @@ const getUserInfo = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const doLogin = async () => {
|
||||
const doLogin = async (loginType,token, accountId, sessionId) => {
|
||||
const tokenKey = constant.storageConstant.TOKEN
|
||||
const userInfoKey = constant.storageConstant.USERINFO
|
||||
const tokenStorage = uni.getStorageSync(tokenKey)
|
||||
@@ -46,12 +69,23 @@ const doLogin = async () => {
|
||||
title: '登录中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
const url = window.location.href;
|
||||
const params = new URL(url).searchParams;
|
||||
const token = params.get('uabaseToken'); // 获取 uabaseToken 参数值
|
||||
console.log('Token:', token);
|
||||
const { data: authData } = await userApi.auth(token);
|
||||
let authData;
|
||||
if (loginType==1){
|
||||
// 诗画
|
||||
const params = {
|
||||
accountId:accountId,
|
||||
sessionId:sessionId
|
||||
}
|
||||
const response = await userApi.authsh(params);
|
||||
authData = response.data;
|
||||
}else if (loginType==2){
|
||||
//浙政钉
|
||||
const response = await userApi.auth(token);
|
||||
authData = response.data;
|
||||
}else {
|
||||
//后期手机号+验证码登录
|
||||
}
|
||||
// const {data: authData} = await userApi.auth(token);
|
||||
uni.setStorageSync(tokenKey, authData)
|
||||
const { data: userData } = await userApi.userInfo();
|
||||
uni.setStorageSync(userInfoKey, userData)
|
||||
@@ -74,7 +108,6 @@ const doLogout = async () => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '退出登录成功', icon: "none" });
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
+10
-1
@@ -20,7 +20,16 @@ export default {
|
||||
loadingMsg: "授权中",
|
||||
},
|
||||
}),
|
||||
|
||||
authsh: (params: any) =>
|
||||
request({
|
||||
url: `/sys/auth/shjnsso`,
|
||||
method: "POST",
|
||||
custom: {
|
||||
showLoading: false,
|
||||
loadingMsg: "授权中",
|
||||
},
|
||||
data:params,
|
||||
}),
|
||||
refreshToken: (params: any) =>
|
||||
request({
|
||||
url: `/sys/auth/refresh-token`,
|
||||
|
||||
Reference in new issue
Block a user