财智跳转测试

master
wuzuowei 6 months ago
parent 45861e02d5
commit fecd6238cb

@ -9,49 +9,142 @@ import utils from "@/microhost/common"
import { isString } from 'lodash' import { isString } from 'lodash'
import user from 'mock/user'; import user from 'mock/user';
import UserModel from '@/models/user'; import UserModel from '@/models/user';
import { FrameMessage as message1 } from '@/library/union';
const TechLoginView = () => { const TechLoginView = () => {
const cookieLoginKey = "_defs_ln" const cookieLoginKey = "_defs_ln"
const defln = utils.loadCookie(cookieLoginKey) const defln = utils.loadCookie(cookieLoginKey)
const isRemembered = useRef<boolean>(!!defln && defln != "null") const isRemembered = useRef<boolean>(!!defln && defln != "null")
const searchParams = new URLSearchParams(window.location.search); const searchParams = new URLSearchParams(window.location.search);
const paramValue = searchParams.get('token'); const paramValue = searchParams.get('token');
const pathValue = searchParams.get('path');
useEffect(() => { useEffect(() => {
console.log("token:"+paramValue); console.log("token:" + paramValue, pathValue);
current(paramValue); current(paramValue);
}, []) }, [])
const current = (date: string) => { const current = (date: string) => {
requestaxios
.post("/openapi/v1/account/check-token?mta_open_api_key=bcefb9711f3947349596ab4e6f1f088c&mta_open_api_secret=NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=",{ "token":date}, { // console.log("date", date)
headers:{
'Content-Type':'application/json;charset=UTF-8',
'mta_open_api_key':'bcefb9711f3947349596ab4e6f1f088c', requestaxios
'mta_open_api_secret':'NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=' .post("/openapi/v1/account/check-token?mta_open_api_key=bcefb9711f3947349596ab4e6f1f088c&mta_open_api_secret=NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=", { "token": date }, {
}}) headers: {
.then(({ data }) => { 'Content-Type': 'application/json;charset=UTF-8',
//console.log(data.code); 'mta_open_api_key': 'bcefb9711f3947349596ab4e6f1f088c',
'mta_open_api_secret': 'NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI='
if (data.loginName != undefined) { }
//拿到账号密码之后进行登录 })
console.log(data); .then(({ data }) => {
// console.log("data", data.code);
let month = new Date().getTime() + 1000 * 24 * 3600 * 30 * 3
utils.saveCookie('CZtoken', paramValue, month) if (data.loginName != undefined) {
utils.saveCookie('loginName', data.loginName, month) //拿到账号密码之后进行登录
// console.log(data);
doLogin(data.loginName);
} else { let month = new Date().getTime() + 1000 * 24 * 3600 * 30 * 3
message.error('获取财智系统用户信息报错!'); utils.saveCookie('CZtoken', paramValue, month)
window.location.href ="http://172.15.89.232:8080"; utils.saveCookie('loginName', data.loginName, month)
} doLogin(data.loginName);
})
.catch((reason) => { } else {
message.error('调取财智系统用户信息报错' + reason); message.error('获取财智系统用户信息报错!');
window.location.href ="http://172.15.89.232:8080"; window.location.href = "http://172.15.89.232:8080";
}); }
}; })
const doLogin = async (UserId:string) => { .catch((reason) => {
let loginId = UserId; message.error('调取财智系统用户信息报错' + reason);
window.location.href = "http://172.15.89.232:8080";
});
};
// 跳转ccfowe
const gomsglog = () => {
let body: message1 = new message1();
body.code = '@host#control#openPage';
body.data = {
newPage: false,
params: {
// recordData: JSON.stringify(record),
},
moduleId: '41f852c5-dfa3-3057-c62d-197d82f71b58', //要打开的模块id系统配置-导航菜单-找到所在模块的id
};
body.msg = '跳转';
body.to = 'iBKLinker-union-framework';
body.from = 'prd';
window.top?.postMessage(body, '*');
// console.log("财智跳转待办6666666666666666", window.top?.postMessage(body, '*'), body)
}
// const doLoginccfowe = async (UserId: string) => {
// let loginId = UserId;
// // let password = values.password;
// // if (!loginId || !loginId.trim()) {
// // message.error('请输入用户名');
// // return;
// // } else if (!password || !password.trim()) {
// // message.error('请输入密码');
// // return;
// // }
// if (isRemembered.current) {
// let month = new Date().getTime() + 1000 * 24 * 3600 * 30 * 3
// utils.saveCookie(cookieLoginKey, loginId, month)
// }
// let result = await MicroApps.GetRuntimeUser().doLogin(loginId, "000000")
// console.log("财智跳转", loginId, result)
// if (isString(result)) {
// message.error(result)
// return
// }
// let redirect: any = history.location.query?.redirect
// let jumpTo: string | undefined = undefined
// console.log("财智跳转1111111111", redirect, jumpTo)
// if (redirect) {
// let rd = decodeURIComponent(redirect)
// jumpTo = isUrl(rd) ? rd : undefined
// }
// if (jumpTo) {
// }
// else {
// let routes = await MicroApps.BuildRouteTree(loginId)
// console.log("财智跳转2222222222222", redirect, jumpTo, routes)
// if (!routes || routes.length == 0) {
// history.push("/noauth")
// console.log("财智跳转333333333333333", redirect, jumpTo, routes)
// return
// }
// else {
// jumpTo = "/" //routes[0].defaultPath && routes[0].defaultPath.length > 0 ? routes[0].defaultPath : "/welcome"
// console.log("财智跳转4444444444444", redirect, jumpTo, routes)
// }
// }
// history.push(`/animate?url=${encodeURIComponent(jumpTo)}`)
// console.log("财智跳转55555555555", redirect, jumpTo, `/animate?url=${encodeURIComponent(jumpTo)}`)
// setTimeout(() => {
// gomsglog()
// }, 100000);
// }
const doLogin = async (UserId: string) => {
let loginId = UserId;
// let password = values.password; // let password = values.password;
// if (!loginId || !loginId.trim()) { // if (!loginId || !loginId.trim()) {
// message.error('请输入用户名'); // message.error('请输入用户名');
@ -61,54 +154,75 @@ const TechLoginView = () => {
// return; // return;
// } // }
if(isRemembered.current){ if (isRemembered.current) {
let month = new Date().getTime() + 1000 * 24 * 3600 * 30 * 3 let month = new Date().getTime() + 1000 * 24 * 3600 * 30 * 3
utils.saveCookie(cookieLoginKey, loginId, month) utils.saveCookie(cookieLoginKey, loginId, month)
} }
let result = await MicroApps.GetRuntimeUser().doLogin(loginId, "000000") let result = await MicroApps.GetRuntimeUser().doLogin(loginId, "000000")
// console.log("财智跳转", loginId, result)
if(isString(result)){ if (isString(result)) {
message.error(result) message.error(result)
return return
} }
let redirect: any = history.location.query?.redirect let redirect: any = history.location.query?.redirect
let jumpTo: string | undefined = undefined let jumpTo: string | undefined = undefined
if(redirect){
// console.log("财智跳转1111111111", redirect, jumpTo)
if (redirect) {
let rd = decodeURIComponent(redirect) let rd = decodeURIComponent(redirect)
jumpTo = isUrl(rd) ? rd : undefined jumpTo = isUrl(rd) ? rd : undefined
} }
if(jumpTo){ if (jumpTo) {
} }
else{ else {
let routes = await MicroApps.BuildRouteTree(loginId) let routes = await MicroApps.BuildRouteTree(loginId)
if(!routes || routes.length == 0){ // console.log("财智跳转2222222222222", redirect, jumpTo, routes)
if (!routes || routes.length == 0) {
history.push("/noauth") history.push("/noauth")
// console.log("财智跳转333333333333333", redirect, jumpTo, routes)
return return
} }
else{ else {
jumpTo = "/" //routes[0].defaultPath && routes[0].defaultPath.length > 0 ? routes[0].defaultPath : "/welcome" jumpTo = "/" //routes[0].defaultPath && routes[0].defaultPath.length > 0 ? routes[0].defaultPath : "/welcome"
// console.log("财智跳转4444444444444", redirect, jumpTo, routes)
} }
} }
history.push(`/animate?url=${encodeURIComponent(jumpTo)}`) history.push(`/animate?url=${encodeURIComponent(jumpTo)}`)
// console.log("财智跳转55555555555", redirect, jumpTo, `/animate?url=${encodeURIComponent(jumpTo)}`)
if (pathValue == "notice") {
// console.log("跳转cc")
// 跳转cc
setTimeout(() => {
gomsglog()
}, 5000);
}
} }
const isUrl = (addr: any) => { const isUrl = (addr: any) => {
var v = new RegExp( var v = new RegExp(
'^((http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$', '^((http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$',
'i', 'i',
); );
let uri: string = addr; let uri: string = addr;
uri = !uri || uri.length == 0 ? '' : uri[0] == '/' ? uri.substring(1) : uri; uri = !uri || uri.length == 0 ? '' : uri[0] == '/' ? uri.substring(1) : uri;
return v.test(uri); return v.test(uri);
} }
return ( return (
<> <>
</>); </>);
} }

Loading…
Cancel
Save