| | |
| | | import qs from 'qs' |
| | | import { notification } from 'antd' |
| | | import md5 from 'md5' |
| | | import CryptoJS from 'crypto-js' |
| | | import jsSHA from 'jssha' |
| | | import moment from 'moment' |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | |
| | | window.GLOB.WebSql = null |
| | | window.GLOB.IndexDB = null |
| | | window.GLOB.OuterToken = {} |
| | | const systemMenuKeys = `1581067625930haged11ieaivpavv77k,1581734956310scks442ul2d955g9tu5,1583991994144ndddg0bhh0is6shi0v1,1583979633842550imkchl4qt4qppsiv,1578900109100np8aqd0a77q3na46oas, |
| | | 1585192949946f3et2ts8tn82krmumdf,15855615451212m12ip23vpcm79kloro,1587005717541lov40vg61q7l1rbveon,1590458676585agbbr63t6ihighg2i1g,1602315375262ikd33ii0nii34pt861o,1582771068837vsv54a089lgp45migbg, |
| | | 1582777675954ifu05upurs465omoth7,158294809668898cklbv6c5bou8e1fpu,1584676379094iktph45fb8imhg96bql,1584695125339vo5g7iqgfn01qmrd6s2,1584699661372vhmpp9dn9foo0eob722,15848421131551gg04ie8sitsd3f7467, |
| | |
| | | } |
| | | } |
| | | |
| | | visitOuterSystem (param, _resolve) { |
| | | let token = param.$token |
| | | delete param.$token |
| | | |
| | | try { |
| | | token = JSON.parse(token) |
| | | token = token.message |
| | | |
| | | const key = CryptoJS.enc.Utf8.parse(window.GLOB.appkey.slice(-16)) |
| | | const iv = CryptoJS.enc.Utf8.parse('mksoft') |
| | | |
| | | let encryptedHexStr = CryptoJS.enc.Hex.parse(token) |
| | | let _srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr) |
| | | let decrypt = CryptoJS.AES.decrypt(_srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }) |
| | | let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8) |
| | | token = decryptedStr.toString() |
| | | |
| | | token = JSON.parse(window.decodeURIComponent(window.atob(token))) |
| | | } catch (e) { |
| | | token = null |
| | | _resolve({status: false, ErrCode: 'E', message: '接口信息解析失败!'}) |
| | | } |
| | | |
| | | if (!token) return |
| | | |
| | | let userid = '' |
| | | let loginUid = '' |
| | | let dataM = '' |
| | | |
| | | if (window.GLOB.OuterToken[token.interface]) { |
| | | let msg = window.GLOB.OuterToken[token.interface] |
| | | |
| | | let seconds = Math.floor((new Date().getTime() - msg.timestamp) / 1000) |
| | | if (seconds >= 3600) { |
| | | delete window.GLOB.OuterToken[token.interface] |
| | | } else { |
| | | userid = msg.userid |
| | | loginUid = msg.loginUid |
| | | dataM = msg.dataM || '' |
| | | } |
| | | } |
| | | |
| | | // param.appkey = token.appkey || '' |
| | | |
| | | if (userid && loginUid) { |
| | | param.dataM = dataM |
| | | param.userid = userid |
| | | param.LoginUID = loginUid |
| | | param = this.encryptParam(param) |
| | | |
| | | axios({ |
| | | url: token.interface, |
| | | method: 'post', |
| | | data: param |
| | | }).then(res => { |
| | | _resolve(res) |
| | | }) |
| | | } else { |
| | | let _param = { |
| | | UserName: token.username, |
| | | systemType: options.sysType, |
| | | login_city: sessionStorage.getItem('city') || '', |
| | | device_id: localStorage.getItem('SessionUid') |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | |
| | | _param.Type = token.publicKey |
| | | let shaObj = new jsSHA('SHA-1', 'TEXT') |
| | | shaObj.update(token.password) |
| | | _param.Password = shaObj.getHash('HEX').toUpperCase() |
| | | _param.Password = md5(token.privateKey + token.username + _param.Password + _param.timestamp) |
| | | _param.appkey = token.appkey || '' |
| | | let url = token.interface.replace(/\/webapi(.*)/, '/webapi/dologon') |
| | | |
| | | if (token.ssoInterface) { |
| | | _param.rduri = token.ssoInterface.replace(/\/webapi(.*)/, '/webapi/dologon') |
| | | } |
| | | |
| | | axios({ |
| | | url, |
| | | method: 'post', |
| | | data: _param |
| | | }).then(result => { |
| | | if (result.status) { |
| | | window.GLOB.OuterToken[token.interface] = { |
| | | userid: result.UserID, |
| | | loginUid: result.LoginUID, |
| | | timestamp: new Date().getTime(), |
| | | dataM: result.dataM ? 'Y' : '' |
| | | } |
| | | |
| | | param.dataM = result.dataM ? 'Y' : '' |
| | | param.userid = result.UserID |
| | | param.LoginUID = result.LoginUID |
| | | param = this.encryptParam(param) |
| | | |
| | | axios({ |
| | | url: token.interface, |
| | | method: 'post', |
| | | data: param |
| | | }).then(res => { |
| | | _resolve(res) |
| | | }) |
| | | } else { |
| | | _resolve(result) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 获取业务通用接口 |
| | | * 访问 'https://sso.mk9h.cn/webapi/dostars'或云端时,传入userid、LoginUID |
| | |
| | | param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (param.$token === '') { |
| | | return Promise.resolve({status: false, ErrCode: 'E', message: '接口地址尚未设置!'}) |
| | | } else if (param.$token) { |
| | | return new Promise(resolve => this.visitOuterSystem(param, resolve)) |
| | | } |
| | | |
| | | if (['sPC_Get_TableData', 'sPC_Get_TableData_debug', 'sPC_TableData_InUpDe', 'sPC_TableData_InUpDe_debug', 'sPC_Get_structured_data'].includes(param.func)) { |
| | | if (sessionStorage.getItem('isEditState') === 'true') { |
| | | param.username = sessionStorage.getItem('CloudUserName') || '' |