diff --git a/platform-code/src/pages/tech/login/Senselesslogin.tsx b/platform-code/src/pages/tech/login/Senselesslogin.tsx index b4d3969..7329761 100644 --- a/platform-code/src/pages/tech/login/Senselesslogin.tsx +++ b/platform-code/src/pages/tech/login/Senselesslogin.tsx @@ -9,49 +9,142 @@ import utils from "@/microhost/common" import { isString } from 'lodash' import user from 'mock/user'; import UserModel from '@/models/user'; +import { FrameMessage as message1 } from '@/library/union'; + const TechLoginView = () => { const cookieLoginKey = "_defs_ln" const defln = utils.loadCookie(cookieLoginKey) const isRemembered = useRef(!!defln && defln != "null") const searchParams = new URLSearchParams(window.location.search); const paramValue = searchParams.get('token'); + const pathValue = searchParams.get('path'); + useEffect(() => { - console.log("token:"+paramValue); - current(paramValue); + console.log("token:" + paramValue, pathValue); + current(paramValue); + }, []) - const current = (date: string) => { - requestaxios - .post("/openapi/v1/account/check-token?mta_open_api_key=bcefb9711f3947349596ab4e6f1f088c&mta_open_api_secret=NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=",{ "token":date}, { - headers:{ - 'Content-Type':'application/json;charset=UTF-8', - 'mta_open_api_key':'bcefb9711f3947349596ab4e6f1f088c', - 'mta_open_api_secret':'NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=' - }}) - .then(({ data }) => { - //console.log(data.code); - - if (data.loginName != undefined) { - //拿到账号密码之后进行登录 - console.log(data); - - let month = new Date().getTime() + 1000 * 24 * 3600 * 30 * 3 - utils.saveCookie('CZtoken', paramValue, month) - utils.saveCookie('loginName', data.loginName, month) - - doLogin(data.loginName); - } else { - message.error('获取财智系统用户信息报错!'); - window.location.href ="http://172.15.89.232:8080"; - } - }) - .catch((reason) => { - message.error('调取财智系统用户信息报错' + reason); - window.location.href ="http://172.15.89.232:8080"; - }); - }; - const doLogin = async (UserId:string) => { - let loginId = UserId; + const current = (date: string) => { + + // console.log("date", date) + + + requestaxios + .post("/openapi/v1/account/check-token?mta_open_api_key=bcefb9711f3947349596ab4e6f1f088c&mta_open_api_secret=NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=", { "token": date }, { + headers: { + 'Content-Type': 'application/json;charset=UTF-8', + 'mta_open_api_key': 'bcefb9711f3947349596ab4e6f1f088c', + 'mta_open_api_secret': 'NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=' + } + }) + .then(({ data }) => { + // console.log("data", data.code); + + if (data.loginName != undefined) { + //拿到账号密码之后进行登录 + // console.log(data); + + let month = new Date().getTime() + 1000 * 24 * 3600 * 30 * 3 + utils.saveCookie('CZtoken', paramValue, month) + utils.saveCookie('loginName', data.loginName, month) + doLogin(data.loginName); + + } else { + message.error('获取财智系统用户信息报错!'); + window.location.href = "http://172.15.89.232:8080"; + } + }) + .catch((reason) => { + 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; // if (!loginId || !loginId.trim()) { // message.error('请输入用户名'); @@ -61,55 +154,76 @@ const TechLoginView = () => { // return; // } - if(isRemembered.current){ + 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") - - if(isString(result)){ + // console.log("财智跳转", loginId, result) + + if (isString(result)) { message.error(result) return } let redirect: any = history.location.query?.redirect let jumpTo: string | undefined = undefined - if(redirect){ + + + // console.log("财智跳转1111111111", redirect, jumpTo) + + if (redirect) { let rd = decodeURIComponent(redirect) jumpTo = isUrl(rd) ? rd : undefined } - if(jumpTo){ - + if (jumpTo) { + } - else{ + else { 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") + // console.log("财智跳转333333333333333", redirect, jumpTo, routes) + return } - else{ + 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)}`) + if (pathValue == "notice") { + // console.log("跳转cc") + // 跳转cc + setTimeout(() => { + gomsglog() + }, 5000); + } + } - const isUrl = (addr: any) => { + const isUrl = (addr: any) => { 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]*)?$', - 'i', + '^((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', ); let uri: string = addr; uri = !uri || uri.length == 0 ? '' : uri[0] == '/' ? uri.substring(1) : uri; return v.test(uri); } - return ( - <> - ); - - + return ( + <> + ); + + } -export default TechLoginView; \ No newline at end of file +export default TechLoginView;