From e8edfdadb561cd83bf6e1c3e00d55b8cc2aee6d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 17 十月 2022 17:57:34 +0800 Subject: [PATCH] 2022-10-17 --- src/api/index.js | 185 ++++++++++++++++++++++++++++++--------------- 1 files changed, 123 insertions(+), 62 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 02782e6..d86149f 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -10,16 +10,19 @@ window.GLOB.WebSql = null window.GLOB.IndexDB = null -const systemMenuKeys = `1581067625930haged11ieaivpavv77k,1581734956310scks442ul2d955g9tu5,1583991994144ndddg0bhh0is6shi0v1,1583979633842550imkchl4qt4qppsiv,1578900109100np8aqd0a77q3na46oas,16044812935562g807p3p12huk8kokmb, +const systemMenuKeys = `1581067625930haged11ieaivpavv77k,1581734956310scks442ul2d955g9tu5,1583991994144ndddg0bhh0is6shi0v1,1583979633842550imkchl4qt4qppsiv,1578900109100np8aqd0a77q3na46oas, 1585192949946f3et2ts8tn82krmumdf,15855615451212m12ip23vpcm79kloro,1587005717541lov40vg61q7l1rbveon,1590458676585agbbr63t6ihighg2i1g,1602315375262ikd33ii0nii34pt861o,1582771068837vsv54a089lgp45migbg, 1582777675954ifu05upurs465omoth7,158294809668898cklbv6c5bou8e1fpu,1584676379094iktph45fb8imhg96bql,1584695125339vo5g7iqgfn01qmrd6s2,1584699661372vhmpp9dn9foo0eob722,15848421131551gg04ie8sitsd3f7467, - 1589782279158ngr675kk3oksin35sul,1589788042787ffdt9hle4s45k9r1nvs,15900310928174dro07ihfckghpb5h13,1594095599055qicg2eb642v5qglhnuo,1599613340050c8nu6rbst9d4emnnbsq,1577972969199lei1g0qkvlh4tkc908m, + 1589782279158ngr675kk3oksin35sul,1589788042787ffdt9hle4s45k9r1nvs,1594095599055qicg2eb642v5qglhnuo,1577972969199lei1g0qkvlh4tkc908m,16044812935562g807p3p12huk8kokmb, 1578479100252lfbp29v1kafk4s4q4ig,1577971621421tg4v0i1ur8873k7e0ob,1577929944419lgc5h3hepum765e2k7u,1588493493409k9guqp067d31lu7blsv,15827879285193g85m3i2uprektpgmpf` +let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : '' +let db = `mkdb${service}` + if (window.openDatabase) { - CacheUtils.openWebSql(options.sysType) + CacheUtils.openWebSql(db) } else if (window.indexedDB) { - CacheUtils.openIndexDB(options.sysType) + CacheUtils.openIndexDB(db) } axios.defaults.crossDomain = true @@ -92,7 +95,7 @@ param.userid = param.userid || '' return axios({ - url: '/webapi/dostar', + url: `/webapi/dostar${param.func ? '/' + param.func : ''}`, method: 'post', data: param }) @@ -216,16 +219,6 @@ TypeCharOne: 'pc', kei_id: window.btoa(window.encodeURIComponent(window.GLOB.host)) } - - param.LText = md5(window.btoa(_SessionUid + param.timestamp)) - - // param.secretkey = md5(param.LText + 'mingke' + param.timestamp) // v_type 涓虹┖鏃� - let solt = md5((window.GLOB.appkey + window.btoa(window.GLOB.appkey + 'mingke') + 'mingke').toLowerCase()).slice(-6).toUpperCase() - - param.v_type = 'Y' - param.secretkey = md5(param.LText + solt + param.timestamp) - - param.appkey = window.GLOB.appkey || '' let url = '/webapi/dologon/s_visitor_login' if (window.GLOB.mainSystemApi) { @@ -246,7 +239,19 @@ if (!param.rduri) { param.rduri = window.GLOB.baseurl + 'webapi/dologon/s_visitor_login' } + + param.linkurl = appid.replace(/\/webapi(.*)/, '/index.html') } + + param.LText = md5(window.btoa(_SessionUid + param.timestamp + (param.linkurl || ''))) + + // param.secretkey = md5(param.LText + 'mingke' + param.timestamp) // v_type 涓虹┖鏃� + let solt = md5((window.GLOB.appkey + window.btoa(window.GLOB.appkey + 'mingke') + 'mingke').toLowerCase()).slice(-6).toUpperCase() + + param.v_type = param.v_type || 'Y' + param.secretkey = md5(param.LText + solt + param.timestamp) + + param.appkey = window.GLOB.appkey || '' return axios({ url: url, @@ -372,20 +377,38 @@ let app_datetime = sessionStorage.getItem('app_datetime') if (sys_datetime && app_datetime) { let seconds = Math.floor((new Date().getTime() - app_datetime) / 1000) - curTime = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') + '.000' + let _curTime = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') + '.000' + if (/^\d{4}-\d{2}-\d{2}/.test(_curTime)) { + curTime = _curTime + } } if (window.GLOB.WebSql) { return new Promise((resolve, reject) => { CacheUtils.getWebSqlVersion().then(msg => { - let modifydate = msg.createDate || curTime - if (modifydate.indexOf('Invalid date') > -1) { - modifydate = curTime - } - let param = { func: 's_get_app_version', - modifydate + modifydate: msg.createDate + } + + param.TypeCharOne = '' + param.typename = '' + + if (!msg.createDate && !msg.menuids) { + CacheUtils.updateWebSqlversion('1.00', curTime) + resolve() + return + } else if (!msg.createDate) { + param.modifydate = curTime + param.menuids = window.btoa(msg.menuids) + } else if (msg.menuids) { + let d = localStorage.getItem(db) + + if (!d || curTime.indexOf(d) === -1) { + param.menuids = window.btoa(msg.menuids) + } + + localStorage.setItem(db, curTime.substr(0, 10)) } this.getSystemConfig(param).then(res => { @@ -393,29 +416,28 @@ reject() return } - let clear = false - let version = '1.00' - - if (res.menu_data && res.menu_data.length > 0) { - res.menu_data.forEach(mid => { + + let list = res.menu_data || [] + + if (res.menu_del) { + list.push(...res.menu_del) + } + + if (list.length > 0) { + let clear = false + list.forEach(mid => { if (systemMenuKeys.indexOf(mid.menuid) > -1) { clear = true } }) - + let keys = list.map(mid => `'${mid.menuid}'`).join(',') if (clear) { - CacheUtils.clearWebSqlConfig() - } else { - let keys = res.menu_data.map(mid => `'${mid.menuid}'`).join(',') - CacheUtils.delWebSqlConfig(keys) + keys = '' } + CacheUtils.delWebSqlConfig(keys) } - - if (msg.version) { - CacheUtils.updateWebSqlTime(curTime) - } else { - CacheUtils.createWebSqlversion(version, curTime) - } + + CacheUtils.updateWebSqlversion(res.app_version || '1.00', curTime) resolve() }) @@ -426,13 +448,29 @@ } else { return new Promise((resolve, reject) => { CacheUtils.getIndexDBVersion().then(msg => { - let modifydate = msg.createDate || curTime - if (modifydate.indexOf('Invalid date') > -1) { - modifydate = curTime - } let param = { func: 's_get_app_version', - modifydate + modifydate: msg.createDate + } + + param.TypeCharOne = '' + param.typename = '' + + if (!msg.createDate && !msg.menuids) { + CacheUtils.updateIndexDBversion({version: '1.00', createDate: curTime}) + resolve() + return + } else if (!msg.createDate) { + param.modifydate = curTime + param.menuids = window.btoa(msg.menuids) + } else if (msg.menuids) { + let d = localStorage.getItem(db) + + if (!d || curTime.indexOf(d) === -1) { + param.menuids = window.btoa(msg.menuids) + } + + localStorage.setItem(db, curTime.substr(0, 10)) } this.getSystemConfig(param).then(res => { @@ -440,25 +478,28 @@ reject() return } - let clear = false - let version = '1.00' - if (res.menu_data && res.menu_data.length > 0) { - res.menu_data.forEach(mid => { + let list = res.menu_data || [] + + if (res.menu_del) { + list.push(...res.menu_del) + } + + if (list.length > 0) { + let clear = false + list.forEach(mid => { if (systemMenuKeys.indexOf(mid.menuid) > -1) { clear = true } }) - + let keys = list.map(mid => mid.menuid) if (clear) { - CacheUtils.clearIndexDBConfig() - } else { - let keys = res.menu_data.map(mid => `'${mid.menuid}'`) - CacheUtils.delIndexDBConfig(keys) + keys = '' } + CacheUtils.delIndexDBConfig(keys) } - CacheUtils.updateIndexDBversion({version: version, createDate: curTime}) + CacheUtils.updateIndexDBversion({version: res.app_version || '1.00', createDate: curTime}) resolve() }) @@ -473,12 +514,11 @@ * @description 鏇存柊绯荤粺鐗堟湰淇℃伅锛屾竻绌洪厤缃俊鎭� */ updateAppVersion () { - let curTime = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - CacheUtils.clearWebSqlConfig() - CacheUtils.updateWebSqlversion('1.00', curTime) - CacheUtils.clearIndexDBConfig() - CacheUtils.updateIndexDBversion({version: '1.00', createDate: curTime}) - CacheUtils.clearFuncs(options.sysType) + CacheUtils.delWebSqlConfig() + CacheUtils.updateWebSqlversion() + CacheUtils.delIndexDBConfig() + CacheUtils.updateIndexDBversion() + CacheUtils.clearFuncs() } /** @@ -562,7 +602,11 @@ param.userid = sessionStorage.getItem('CloudUserID') || '' param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } else if (window.GLOB.mainSystemApi) { - url = window.GLOB.mainSystemApi + if (!window.GLOB.transfer) { + url = window.GLOB.mainSystemApi + } else { + param.rduri = window.GLOB.mainSystemApi + } } param = this.encryptParam(param) @@ -592,7 +636,11 @@ param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } } else if (window.GLOB.mainSystemApi) { - url = window.GLOB.mainSystemApi + if (!window.GLOB.transfer) { + url = window.GLOB.mainSystemApi + } else { + param.rduri = window.GLOB.mainSystemApi + } } let _param = JSON.parse(JSON.stringify(param)) // 缂撳瓨鏍¢獙锛屽幓闄ゆ椂闂村拰鍔犲瘑瀛楃 @@ -740,7 +788,7 @@ param.appkey = window.GLOB.appkey || '' let url = '/webapi/dostars' - if (param.rduri) { + if (param.rduri && !window.GLOB.transfer) { url = param.rduri delete param.rduri } @@ -809,9 +857,22 @@ param = this.encryptParam(param) if (login) { + let time = +sessionStorage.getItem(rduri) + let c_time = Math.round(new Date().getTime() / 1000) + + if (time && c_time - time <= 60) { + sessionStorage.setItem(rduri, c_time) + return axios({ + url: `${url}${param.func ? '/' + param.func : ''}`, + method: 'post', + data: param + }) + } + return new Promise((resolve, reject) => { this.getTouristMsg('login_check', rduri).then(res => { if (res.status) { + sessionStorage.setItem(rduri, c_time) axios({ url: `${url}${param.func ? '/' + param.func : ''}`, method: 'post', -- Gitblit v1.8.0