| | |
| | | import axios from 'axios' |
| | | import qs from 'qs' |
| | | import {notification } from 'antd' |
| | | import { notification } from 'antd' |
| | | import md5 from 'md5' |
| | | import moment from 'moment' |
| | | import Utils from '@/utils/utils.js' |
| | | import options from '@/store/options.js' |
| | | |
| | | let mkDataBase = null |
| | | |
| | | if (window.openDatabase) { |
| | | let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : '' |
| | | try { |
| | | mkDataBase = openDatabase(`mkdb${service}`, '1', 'mk-pc-database', 50 * 1024 * 1024) |
| | | mkDataBase.transaction(tx => { |
| | | tx.executeSql('CREATE TABLE IF NOT EXISTS VERSIONS (version varchar(50), createDate varchar(50), CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50))', [], () => { |
| | | |
| | | }, () => { |
| | | // eslint-disable-next-line |
| | | throw 'CREATE TABLE ERROR' |
| | | }) |
| | | tx.executeSql('CREATE TABLE IF NOT EXISTS CONFIGS (menuid varchar(50), userid varchar(50), openEdition varchar(50), webEdition varchar(50), LongParam text, LongParamUser text, CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50), CDefine4 varchar(50), CDefine5 varchar(50))', [], () => { |
| | | |
| | | }, () => { |
| | | // eslint-disable-next-line |
| | | throw 'CREATE TABLE ERROR' |
| | | }) |
| | | }) |
| | | // mkDataBase.transaction(tx => { |
| | | // tx.executeSql('DROP TABLE VERSIONS') |
| | | // tx.executeSql('DROP TABLE CONFIGS') |
| | | // }) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | mkDataBase = null |
| | | } |
| | | } |
| | | |
| | | axios.defaults.crossDomain = true |
| | | axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8' |
| | |
| | | |
| | | axios.interceptors.request.use((config) => { |
| | | config.method = 'post' |
| | | if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult')) { |
| | | if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult') || config.url.includes('wxNativePay')) { |
| | | config.data = qs.stringify(config.data) |
| | | } else if (config.url.includes('Upload') || config.url.includes('doupload') || config.url.includes('dopreload')) { |
| | | config.headers = { 'Content-Type': 'multipart/form-data' } |
| | |
| | | return Promise.reject(error) |
| | | }) |
| | | |
| | | const setCurrentUrl = () => { |
| | | const setCurrentUrl = (res) => { |
| | | if (!!(window.history && window.history.pushState)) { |
| | | if (window.location.href.indexOf('paramsmain') > -1) { |
| | | let _href = window.location.href.split('#') |
| | | localStorage.setItem(_href[0] + 'paramsmain', _href[1]) |
| | | } |
| | | |
| | | sessionStorage.clear() |
| | | sessionStorage.setItem('loginError', JSON.stringify({request: res.config ? res.config.data : '', response: JSON.stringify(res.data)})) |
| | | window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login') |
| | | window.location.reload() |
| | | } |
| | |
| | | |
| | | axios.interceptors.response.use((response) => { |
| | | if (response.data.ErrCode === 'LoginError') { |
| | | setCurrentUrl() |
| | | if (window.debugger === true) { |
| | | response.data.ErrCode = 'E' |
| | | return Promise.resolve(response.data) |
| | | } else { |
| | | setCurrentUrl(response) |
| | | } |
| | | } else { |
| | | return Promise.resolve(response.data) |
| | | } |
| | | }, (error) => { |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | bottom: 0, |
| | | message: '状态码-' + error.response.status + ',请联系管理员', |
| | | placement: 'bottomRight', |
| | | duration: 15 |
| | | }) |
| | | if (error && error.response) { |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | bottom: 0, |
| | | message: '状态码-' + error.response.status + ',请联系管理员', |
| | | placement: 'bottomRight', |
| | | duration: 15 |
| | | }) |
| | | } |
| | | return Promise.reject(error) |
| | | }) |
| | | |
| | |
| | | * @param {Object} param 查询及提交参数 |
| | | */ |
| | | dostarInterface (param) { |
| | | param.userid = '' |
| | | param.userid = param.userid || '' |
| | | |
| | | return axios({ |
| | | url: '/webapi/dostar', |
| | | data: param |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 使用dostar接口,跳转至dostars |
| | | * @param {Object} param 查询及提交参数 |
| | | */ |
| | | dostarToDostars (param) { |
| | | param.userid = param.userid || sessionStorage.getItem('UserID') || '' |
| | | param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || '' |
| | | |
| | | param = this.encryptParam(param) |
| | | |
| | | return axios({ |
| | | url: '/webapi/dostar', |
| | | data: param |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 游客登录 |
| | | */ |
| | | getTouristMsg () { |
| | | let _SessionUid = localStorage.getItem('SessionUid') |
| | | |
| | | if (!_SessionUid) { // 手动清除SessionUid时,实时生成 |
| | | _SessionUid = Utils.getuuid() |
| | | localStorage.setItem('SessionUid', _SessionUid) |
| | | } |
| | | |
| | | let param = { |
| | | func: 's_visitor_login', |
| | | timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), |
| | | SessionUid: _SessionUid, |
| | | TypeCharOne: 'pc' |
| | | } |
| | | |
| | | param.LText = md5(window.btoa(_SessionUid + param.timestamp)) |
| | | param.secretkey = md5(param.LText + 'mingke' + param.timestamp) |
| | | |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon') |
| | | } |
| | | |
| | | return axios({ |
| | | url: '/webapi/dologon', |
| | | data: param |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 手机号验证码登录 |
| | | */ |
| | | getphoneusermsg (phoneNo, checkcode, isCloud = false) { |
| | | let param = { |
| | | // func: 'webapi_login', |
| | | mob: phoneNo, |
| | | UserName: '', |
| | | Password: '', |
| | | check_code: checkcode, |
| | | way_no: 'sms_vcode', |
| | | systemType: options.sysType |
| | | } |
| | | |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (isCloud) { |
| | | param.debug = 'Y' |
| | | if (options.cloudServiceApi) { |
| | | param.rduri = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon') |
| | | } |
| | | } else if (!isCloud && window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon') |
| | | } |
| | | |
| | | return axios({ |
| | | url: '/webapi/dologon', |
| | | data: param |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统版本信息,启用或更新websql |
| | | */ |
| | | getAppVersion (_resolve, _reject) { |
| | | let appVersion = {} |
| | | |
| | | new Promise((resolve, reject) => { |
| | | if (!mkDataBase) { |
| | | reject() |
| | | } else { |
| | | mkDataBase.transaction(tx => { |
| | | if (!mkDataBase) { |
| | | reject() |
| | | return |
| | | } |
| | | tx.executeSql('SELECT * FROM VERSIONS', [], (tx, results) => { |
| | | if (results.rows.length === 0) { |
| | | tx.executeSql('DELETE FROM CONFIGS') |
| | | resolve({version: '', createDate: ''}) |
| | | } else if (results.rows.length === 1) { |
| | | resolve(results.rows[0]) |
| | | } else if (results.rows.length > 1) { |
| | | tx.executeSql('DELETE FROM VERSIONS') |
| | | tx.executeSql('DELETE FROM CONFIGS') |
| | | resolve({version: '', createDate: ''}) |
| | | } |
| | | }, (tx, results) => { |
| | | reject() |
| | | console.warn(results) |
| | | }) |
| | | }) |
| | | } |
| | | }).then(msg => { |
| | | if (msg.version) { |
| | | appVersion.oldVersion = msg.version |
| | | } |
| | | let curTime = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | |
| | | let param = { |
| | | func: 's_get_app_version', |
| | | modifydate: msg.createDate || curTime, |
| | | } |
| | | |
| | | param.userid = sessionStorage.getItem('UserID') || '' |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | |
| | | param = this.encryptParam(param) |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | | data: param |
| | | }).then(res => { |
| | | if (!res.status) { |
| | | reject() |
| | | return |
| | | } |
| | | let clear = false |
| | | let version = res.app_version || '1.00' |
| | | appVersion.newVersion = version |
| | | appVersion.oldVersion = appVersion.oldVersion || version |
| | | |
| | | if (res.menu_data && res.menu_data.length > 0) { |
| | | let keys = `1581067625930haged11ieaivpavv77k,1581734956310scks442ul2d955g9tu5,1583991994144ndddg0bhh0is6shi0v1,1583979633842550imkchl4qt4qppsiv,1578900109100np8aqd0a77q3na46oas,16044812935562g807p3p12huk8kokmb, |
| | | 1585192949946f3et2ts8tn82krmumdf,15855615451212m12ip23vpcm79kloro,1587005717541lov40vg61q7l1rbveon,1590458676585agbbr63t6ihighg2i1g,1602315375262ikd33ii0nii34pt861o,1582771068837vsv54a089lgp45migbg, |
| | | 1582777675954ifu05upurs465omoth7,158294809668898cklbv6c5bou8e1fpu,1584676379094iktph45fb8imhg96bql,1584695125339vo5g7iqgfn01qmrd6s2,1584699661372vhmpp9dn9foo0eob722,15848421131551gg04ie8sitsd3f7467, |
| | | 1589782279158ngr675kk3oksin35sul,1589788042787ffdt9hle4s45k9r1nvs,15900310928174dro07ihfckghpb5h13,1594095599055qicg2eb642v5qglhnuo,1599613340050c8nu6rbst9d4emnnbsq,1577972969199lei1g0qkvlh4tkc908m, |
| | | 1578479100252lfbp29v1kafk4s4q4ig,1577971621421tg4v0i1ur8873k7e0ob,1577929944419lgc5h3hepum765e2k7u,1588493493409k9guqp067d31lu7blsv` |
| | | |
| | | res.menu_data.forEach(mid => { |
| | | if (keys.indexOf(mid.menuid) > -1) { |
| | | clear = true |
| | | } |
| | | }) |
| | | } |
| | | |
| | | mkDataBase.transaction(tx => { |
| | | if (clear) { |
| | | tx.executeSql(`DELETE FROM CONFIGS`, [], () => {}, () => { reject() }) |
| | | } else if (res.menu_data && res.menu_data.length > 0) { |
| | | let keys = res.menu_data.map(mid => `'${mid.menuid}'`) |
| | | tx.executeSql(`DELETE FROM CONFIGS where menuid in (${keys.join(',')})`, [], () => {}, () => { |
| | | reject() |
| | | }) |
| | | } |
| | | if (msg.version) { |
| | | tx.executeSql(`UPDATE VERSIONS SET createDate='${curTime}'`, [], () => { |
| | | resolve() |
| | | }, () => { |
| | | reject() |
| | | }) |
| | | } else { |
| | | tx.executeSql('INSERT INTO VERSIONS (version, createDate) VALUES (?, ?)', [version, curTime], () => { |
| | | resolve() |
| | | }, () => { |
| | | reject() |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | }, () => { |
| | | mkDataBase = null |
| | | _reject() |
| | | return Promise.reject() |
| | | }).then(() => { |
| | | _resolve(appVersion) |
| | | }, () => { |
| | | mkDataBase = null |
| | | _reject() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 更新系统版本信息,清空配置信息 |
| | | */ |
| | | updateAppVersion (newVersion) { |
| | | return new Promise(resolve => { |
| | | if (!mkDataBase) { |
| | | resolve({status: false}) |
| | | return |
| | | } |
| | | let curTime = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | |
| | | mkDataBase.transaction(tx => { |
| | | tx.executeSql(`DELETE FROM CONFIGS`, [], () => {}, () => { |
| | | resolve({status: false}) |
| | | }) |
| | | tx.executeSql(`UPDATE VERSIONS SET version='${newVersion}', createDate='${curTime}'`, [], () => { |
| | | resolve({status: true}) |
| | | }, () => { |
| | | resolve({status: false}) |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 删除某个菜单配置信息 |
| | | */ |
| | | deleteMenuStorage (menuId) { |
| | | return new Promise(resolve => { |
| | | if (!mkDataBase) { |
| | | resolve() |
| | | return |
| | | } |
| | | mkDataBase.transaction(tx => { |
| | | tx.executeSql(`DELETE FROM CONFIGS where menuid='${menuId}'`, [], () => { |
| | | resolve() |
| | | }, () => { |
| | | mkDataBase = null |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取或修改云端配置 |
| | | */ |
| | | getCloudConfig (param) { |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | |
| | | if (sessionStorage.getItem('CloudUserID') && options.cloudServiceApi) { // 存在云端登录信息,且存在云端地址 |
| | | param.rduri = options.cloudServiceApi |
| | | param.userid = sessionStorage.getItem('CloudUserID') |
| | | param.SessionUid = sessionStorage.getItem('CloudSessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' |
| | | } else if (window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | } else { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | } |
| | | |
| | | param.nonc = Utils.getuuid() |
| | | |
| | | let keys = Object.keys(param).sort() |
| | | let values = '' |
| | | keys.forEach(key => { |
| | | if (key === 'rduri' || key === 't') return |
| | | if (typeof(param[key]) === 'object') { |
| | | values += key + JSON.stringify(param[key]) |
| | | } else { |
| | | values += key + param[key] |
| | | } |
| | | }) |
| | | param.sign = md5(values) |
| | | param.t = new Date().getTime() |
| | | param = this.encryptParam(param) |
| | | |
| | | return axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取云端配置,并缓存信息 |
| | | */ |
| | | getCloudCacheConfig (param) { |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | |
| | | if (sessionStorage.getItem('CloudUserID') && options.cloudServiceApi) { // 存在云端登录信息,且存在云端地址 |
| | | param.rduri = options.cloudServiceApi |
| | | param.userid = sessionStorage.getItem('CloudUserID') |
| | | param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' |
| | | } else if (window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | } else { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | } |
| | | |
| | | let _param = JSON.parse(JSON.stringify(param)) // 缓存校验,去除时间和加密字符 |
| | | delete _param.timestamp |
| | | delete _param.secretkey |
| | | delete _param.open_key |
| | | _param = JSON.stringify(_param) |
| | | _param = md5(_param) |
| | | |
| | | if (window.GLOB.CacheMap.has(_param)) { |
| | | return Promise.resolve(window.GLOB.CacheMap.get(_param)) |
| | | } else { |
| | | param = this.encryptParam(param) |
| | | |
| | | return new Promise(resolve => { |
| | | axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | | data: param |
| | | }).then(res => { |
| | | if (res.status) { |
| | | window.GLOB.CacheMap.set(_param, res) |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 获取或修改系统配置,增加appkey |
| | | */ |
| | | getSystemConfig (param) { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.userid = sessionStorage.getItem('UserID') || '' |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (sessionStorage.getItem('isEditState') === 'true' && options.cloudServiceApi) { // 编辑状态,且存在云端地址 |
| | | param.rduri = options.cloudServiceApi |
| | | param.userid = sessionStorage.getItem('CloudUserID') |
| | | param.SessionUid = sessionStorage.getItem('CloudSessionUid') || '' |
| | | param.userid = sessionStorage.getItem('CloudUserID') || '' |
| | | param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' |
| | | } else if (window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | |
| | | param.nonc = Utils.getuuid() |
| | | |
| | | let keys = Object.keys(param).sort() |
| | | let values = '' |
| | | keys.forEach(key => { |
| | | if (key === 'rduri' || key === 't') return |
| | | if (typeof(param[key]) === 'object') { |
| | | values += key + JSON.stringify(param[key]) |
| | | } else { |
| | | values += key + param[key] |
| | | } |
| | | }) |
| | | param.sign = md5(values) |
| | | param.t = new Date().getTime() |
| | | param = this.encryptParam(param) |
| | | |
| | | return axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | |
| | | * @description 获取或修改本地配置,增加appkey |
| | | */ |
| | | getLocalConfig (param) { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.userid = sessionStorage.getItem('UserID') || '' |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | param.nonc = Utils.getuuid() |
| | | |
| | | let keys = Object.keys(param).sort() |
| | | let values = '' |
| | | keys.forEach(key => { |
| | | if (key === 'rduri' || key === 't') return |
| | | if (typeof(param[key]) === 'object') { |
| | | values += key + JSON.stringify(param[key]) |
| | | } else { |
| | | values += key + param[key] |
| | | } |
| | | }) |
| | | param.sign = md5(values) |
| | | param.t = new Date().getTime() |
| | | param = this.encryptParam(param) |
| | | |
| | | return axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统配置,优先从缓存中取值,增加appkey |
| | | * @description 获取系统配置,取值优先等级websql、缓存、服务器 |
| | | * @param {Object} param 请求参数 |
| | | * @param {Boolean} SSO 是否为单点登录地址 |
| | | */ |
| | | getSystemCacheConfig (param, SSO = true) { |
| | | getCacheConfig (param) { |
| | | param.userid = sessionStorage.getItem('UserID') || '' |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (sessionStorage.getItem('isEditState') === 'true' && SSO) { // 编辑状态,单点登录服务器为云端 |
| | | if (sessionStorage.getItem('isEditState') === 'true') { // 编辑状态,单点登录服务器为云端 |
| | | if (options.cloudServiceApi) { // 存在云端地址时,使用云端系统参数 |
| | | param.rduri = options.cloudServiceApi |
| | | param.userid = sessionStorage.getItem('CloudUserID') || '' |
| | | param.SessionUid = sessionStorage.getItem('CloudSessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' |
| | | } |
| | | } else if (window.GLOB.mainSystemApi && SSO) { |
| | | } else if (window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | |
| | | let _param = JSON.parse(JSON.stringify(param)) // 缓存校验,去除时间和加密字符 |
| | | delete _param.timestamp |
| | | delete _param.secretkey |
| | | delete _param.open_key |
| | | _param = JSON.stringify(_param) |
| | | _param = md5(_param) |
| | | |
| | | if (mkDataBase) { |
| | | param = this.encryptParam(param) |
| | | |
| | | return new Promise(resolve => { |
| | | mkDataBase.transaction(tx => { |
| | | tx.executeSql(`SELECT * FROM CONFIGS WHERE menuid='${param.MenuID}' and userid='${param.userid}'`, [], (tx, results) => { |
| | | let paramItem = results.rows[0] |
| | | if (paramItem) { |
| | | resolve({ |
| | | ErrCode: 'S', |
| | | ErrMesg: '', |
| | | LongParam: paramItem.LongParam, |
| | | LongParamUser: paramItem.LongParamUser, |
| | | message: '', |
| | | open_edition: paramItem.openEdition, |
| | | status: true, |
| | | web_edition: paramItem.webEdition |
| | | }) |
| | | } else { |
| | | axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | | data: param |
| | | }).then(res => { |
| | | if (res.status) { |
| | | this.writeInWebSql([param.MenuID, param.userid, res.open_edition, res.web_edition, res.LongParam, res.LongParamUser]) |
| | | } |
| | | resolve(res) |
| | | }) |
| | | } |
| | | }, (tx, results) => { |
| | | mkDataBase = null |
| | | console.warn(results) |
| | | |
| | | axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | | data: param |
| | | }).then(res => { |
| | | if (res.status) { |
| | | window.GLOB.CacheMap.set(_param, res) |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | }) |
| | | }) |
| | | } else if (window.GLOB.CacheMap.has(_param)) { |
| | | return Promise.resolve(window.GLOB.CacheMap.get(_param)) |
| | | } else { |
| | | param = this.encryptParam(param) |
| | | |
| | | return new Promise(resolve => { |
| | | axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | | data: param |
| | | }).then(res => { |
| | | if (res.status) { |
| | | window.GLOB.CacheMap.set(_param, res) |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 将数据写入websql |
| | | */ |
| | | writeInWebSql (data) { |
| | | if (!mkDataBase) return |
| | | mkDataBase.transaction(tx => { |
| | | tx.executeSql('INSERT INTO CONFIGS (menuid, userid, openEdition, webEdition, LongParam, LongParamUser) VALUES (?, ?, ?, ?, ?, ?)', data) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description dostars 参数加密 |
| | | */ |
| | | encryptParam (param) { |
| | | param.nonc = Utils.getuuid() |
| | | |
| | | let keys = Object.keys(param).sort() |
| | | let values = '' |
| | | keys.forEach(key => { |
| | | if (key === 'rduri' || key === 't') return |
| | | if (param[key] === undefined) { |
| | | delete param[key] |
| | | } else if (typeof(param[key]) === 'object') { |
| | | values += key + JSON.stringify(param[key]) |
| | | } else { |
| | | values += key + param[key] |
| | | } |
| | | }) |
| | | param.sign = md5(values) |
| | | param.t = new Date().getTime() |
| | | |
| | | return param |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统配置,优先从缓存中取值,增加appkey |
| | | * @param {Object} param 请求参数 |
| | | * @param {Boolean} SSO 是否为单点登录地址 |
| | | */ |
| | | getSystemCacheConfig (param) { |
| | | param.userid = param.userid || sessionStorage.getItem('UserID') || '' |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | let _param = JSON.parse(JSON.stringify(param)) // 缓存校验,去除时间和加密字符 |
| | | delete _param.timestamp |
| | | delete _param.secretkey |
| | | delete _param.open_key |
| | | _param = JSON.stringify(_param) |
| | | _param = md5(_param) |
| | | |
| | | if (window.GLOB.CacheMap.has(_param)) { |
| | | return Promise.resolve(window.GLOB.CacheMap.get(_param)) |
| | | } else { |
| | | param.nonc = Utils.getuuid() |
| | | |
| | | let keys = Object.keys(param).sort() |
| | | let values = '' |
| | | keys.forEach(key => { |
| | | if (key === 'rduri' || key === 't') return |
| | | if (typeof(param[key]) === 'object') { |
| | | values += key + JSON.stringify(param[key]) |
| | | } else { |
| | | values += key + param[key] |
| | | } |
| | | }) |
| | | param.sign = md5(values) |
| | | param.t = new Date().getTime() |
| | | param = this.encryptParam(param) |
| | | |
| | | return new Promise(resolve => { |
| | | axios({ |
| | |
| | | genericInterface (param) { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (sessionStorage.getItem('isEditState') === 'true') { // HS下菜单 |
| | | param.userid = sessionStorage.getItem('CloudUserID') |
| | | param.SessionUid = sessionStorage.getItem('CloudSessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' |
| | | } |
| | | |
| | | param.nonc = Utils.getuuid() |
| | | |
| | | let keys = Object.keys(param).sort() |
| | | let values = '' |
| | | keys.forEach(key => { |
| | | if (key === 'rduri' || key === 't') return |
| | | if (typeof(param[key]) === 'object') { |
| | | values += key + JSON.stringify(param[key]) |
| | | } else { |
| | | values += key + param[key] |
| | | } |
| | | }) |
| | | param.sign = md5(values) |
| | | param.t = new Date().getTime() |
| | | param = this.encryptParam(param) |
| | | |
| | | return axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | |
| | | getExcelOut (param, name) { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | |
| | | appkey: window.GLOB.appkey || '', |
| | | Base64Img: base64 |
| | | } |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | |
| | | if (service === 'sso' && window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | } else if (service === 'cloud' && options.cloudServiceApi) { |
| | | param.rduri = options.cloudServiceApi |
| | | param.userid = sessionStorage.getItem('CloudUserID') |
| | | param.SessionUid = sessionStorage.getItem('CloudSessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' |
| | | } else { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | } |
| | | |
| | | param.nonc = Utils.getuuid() |
| | | |
| | | let keys = Object.keys(param).sort() |
| | | let values = '' |
| | | keys.forEach(key => { |
| | | if (key === 'rduri' || key === 't') return |
| | | if (typeof(param[key]) === 'object') { |
| | | values += key + JSON.stringify(param[key]) |
| | | } else { |
| | | values += key + param[key] |
| | | } |
| | | }) |
| | | param.sign = md5(values) |
| | | param.t = new Date().getTime() |
| | | param = this.encryptParam(param) |
| | | |
| | | if (param.rduri) { |
| | | param.rduri = param.rduri.replace(/webapi(.*)$/, 'webapi/SaveBase64Image') |
| | |
| | | commonInterface (param) { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.BID = param.BID || '' |
| | | param.debug = param.debug || '' |
| | |
| | | submitInterface (param) { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = sessionStorage.getItem('SessionUid') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | |
| | | return axios({ |