跳转验证

master
wuzuowei 4 months ago
parent 3e951d0df5
commit 3571fc7688

@ -1,7 +1,7 @@
import CommonFunction from "./common" import CommonFunction from "./common"
import {defaultSetting as cfg} from "@/config/default" import { defaultSetting as cfg } from "@/config/default"
import {history as umiHistory} from "umi" import { history as umiHistory } from "umi"
import {SystemData} from "./models/system" import { SystemData } from "./models/system"
import requestaxios from 'axios'; import requestaxios from 'axios';
import utils from "@/microhost/common" import utils from "@/microhost/common"
@ -10,132 +10,133 @@ import utils from "@/microhost/common"
*/ */
module Runtime { module Runtime {
export type LocalUserData = { export type LocalUserData = {
loginName?: string, loginName?: string,
loginId: any, loginId: any,
access_token?: string, access_token?: string,
refresh_token?: string, refresh_token?: string,
} }
export const GetLoginData = (autoLogin: boolean = true) : LocalUserData => { export const GetLoginData = (autoLogin: boolean = true): LocalUserData => {
let local: any = CommonFunction.loadCache(cfg.userInfo) let local: any = CommonFunction.loadCache(cfg.userInfo)
if(!local) return { if (!local) return {
loginId: null loginId: null
} }
return local return local
} }
export const GetLoginId = () => { export const GetLoginId = () => {
return GetLoginData().loginId return GetLoginData().loginId
} }
/** /**
* *
* @param naviData * @param naviData
* @returns * @returns
*/ */
export const isMicroApp = (naviData: any) => { export const isMicroApp = (naviData: any) => {
if(!naviData || !naviData.microFrontendUrl || !naviData.uniqueName) return false if (!naviData || !naviData.microFrontendUrl || !naviData.uniqueName) return false
return naviData.microFrontendUrl.length > 0 && naviData.uniqueName.length > 0 return naviData.microFrontendUrl.length > 0 && naviData.uniqueName.length > 0
} }
/** /**
* *
* @param app * @param app
* @param cate * @param cate
* @returns * @returns
*/ */
export const createMicroUrl = (app: any, cate: any) => { export const createMicroUrl = (app: any, cate: any) => {
if(!isMicroApp(app) || !cate || !cate.url || cate.url.length == 0) return null if (!isMicroApp(app) || !cate || !cate.url || cate.url.length == 0) return null
if(CommonFunction.isUrl(cate.url)) return cate.url if (CommonFunction.isUrl(cate.url)) return cate.url
let head: any = app.uniqueName let head: any = app.uniqueName
let path: any = cate.url let path: any = cate.url
path = path[0] == "/" ? path : `/${path}` path = path[0] == "/" ? path : `/${path}`
return `/${head}${path}` return `/${head}${path}`
} }
/** /**
* *
* @param status * @param status
*/ */
export const errorPage = (status?: 404 | 500, redirect?: any) => { export const errorPage = (status?: 404 | 500, redirect?: any) => {
redirect = CommonFunction.isUrl(redirect) ? redirect : `` redirect = CommonFunction.isUrl(redirect) ? redirect : ``
let uri: any = "/error/203" let uri: any = "/error/203"
if(status){ if (status) {
uri = `/error/${status}` uri = `/error/${status}`
} }
redirect = encodeURIComponent(redirect) redirect = encodeURIComponent(redirect)
let url = `${uri}?from=${redirect}` let url = `${uri}?from=${redirect}`
console.error(`${url} throw error`) console.error(`${url} throw error`)
//location.href = url //location.href = url
} }
export const openHomepage = (force?: boolean) => { export const openHomepage = (force?: boolean) => {
if(force){ if (force) {
location.href = "/" location.href = "/"
} }
else{ else {
umiHistory.push("/") umiHistory.push("/")
} }
} }
//程志刚添加工用方法调取财智心跳接口 //程志刚添加工用方法调取财智心跳接口
export const current = async () => { export const current = async () => {
const date = utils.loadCookie("CZtoken") const date = utils.loadCookie("CZtoken")
requestaxios requestaxios
.post("/openapi/v1/account/check-token?mta_open_api_key=bcefb9711f3947349596ab4e6f1f088c&mta_open_api_secret=NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=",{ "token":date}, { .post("/openapi/v1/account/check-token?mta_open_api_key=bcefb9711f3947349596ab4e6f1f088c&mta_open_api_secret=NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=", { "token": date }, {
headers:{ headers: {
'Content-Type':'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',
'mta_open_api_key':'bcefb9711f3947349596ab4e6f1f088c', 'mta_open_api_key': 'bcefb9711f3947349596ab4e6f1f088c',
'mta_open_api_secret':'NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=' 'mta_open_api_secret': 'NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI='
}}) }
.then(({ data }) => { })
if (data.code != '200') { .then(({ data }) => {
return '失败!'; if (data.code != '200') {
} else return '失败!';
{ } else {
return '成功!'; return '成功!';
} }
}) })
.catch((reason) => { .catch((reason) => {
return '报错' + reason; return '报错' + reason;
}); });
}; };
//程志刚添加退出财智系统 //程志刚添加退出财智系统
export const czlogout = async () => { export const czlogout = async () => {
const date = utils.loadCookie("CZtoken") const date = utils.loadCookie("CZtoken")
requestaxios requestaxios
.post("/openapi/v1/account/logout?mta_open_api_key=bcefb9711f3947349596ab4e6f1f088c&mta_open_api_secret=NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=",{ "token":date}, { .post("/openapi/v1/account/logout?mta_open_api_key=bcefb9711f3947349596ab4e6f1f088c&mta_open_api_secret=NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=", { "token": date }, {
headers:{ headers: {
'Content-Type':'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',
'mta_open_api_key':'bcefb9711f3947349596ab4e6f1f088c', 'mta_open_api_key': 'bcefb9711f3947349596ab4e6f1f088c',
'mta_open_api_secret':'NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI=' 'mta_open_api_secret': 'NjNiYWVmNWQzYzdlYTBlMWEzYmVmM2UxYmU3NzYyNWI='
}}) }
})
}
}
//程志刚添加退出CCfLow
export const CCfLowlogout = async () => { //程志刚添加退出CCfLow
let userNo =utils.loadCookie('loginName'); export const CCfLowlogout = async () => {
//const date = utils.loadCookie("token") let userNo = utils.loadCookie('loginName');
requestaxios //const date = utils.loadCookie("token")
.get("http://172.15.89.222:8081/WF/API/Port_LoginOut?userNo="+userNo) requestaxios
utils.removeCookie("CZtoken"); .get("https://craft.dayesteel.com.cn:8081/WF/API/Port_LoginOut?userNo=" + userNo)
utils.removeCookie("loginName"); utils.removeCookie("CZtoken");
} utils.removeCookie("loginName");
export const logout = async () => { }
let model = new SystemData() export const logout = async () => {
await model.logout() let model = new SystemData()
window.location.href = cfg.url.login await model.logout()
} window.location.href = cfg.url.login
}
} }
export default Runtime export default Runtime

Loading…
Cancel
Save