| | |
| | | import options from '@/store/options.js' |
| | | |
| | | let mkDataBase = null |
| | | let storUsable = false |
| | | |
| | | if (window.openDatabase) { |
| | | let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : '' |
| | |
| | | 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' |
| | |
| | | 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('#') |
| | |
| | | } |
| | | |
| | | 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() |
| | | } |
| | |
| | | response.data.ErrCode = 'E' |
| | | return Promise.resolve(response.data) |
| | | } else { |
| | | setCurrentUrl() |
| | | 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) |
| | | }) |
| | | |
| | |
| | | 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 (res.menu_data && res.menu_data.length > 0) { |
| | | 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() |
| | |
| | | }) |
| | | }) |
| | | }, () => { |
| | | _reject() |
| | | mkDataBase = null |
| | | _reject() |
| | | return Promise.reject() |
| | | }).then(() => { |
| | | storUsable = true |
| | | _resolve(appVersion) |
| | | }, () => { |
| | | mkDataBase = null |
| | | _reject() |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * @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) { |
| | |
| | | * @description 获取或修改本地配置,增加appkey |
| | | */ |
| | | getLocalConfig (param) { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | param.userid = sessionStorage.getItem('UserID') || '' |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | |
| | | _param = JSON.stringify(_param) |
| | | _param = md5(_param) |
| | | |
| | | if (mkDataBase && storUsable) { |
| | | if (mkDataBase) { |
| | | param = this.encryptParam(param) |
| | | |
| | | return new Promise(resolve => { |
| | |
| | | }) |
| | | } |
| | | }, (tx, results) => { |
| | | mkDataBase = null |
| | | console.warn(results) |
| | | |
| | | axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | | data: param |
| | |
| | | } |
| | | resolve(res) |
| | | }) |
| | | mkDataBase = null |
| | | storUsable = false |
| | | console.warn(results) |
| | | }) |
| | | }) |
| | | }) |