| | |
| | | } |
| | | |
| | | setSystemFuncs = () => { |
| | | if (!window.GLOB.WebSql && !window.GLOB.IndexDB) { |
| | | if (!window.GLOB.IndexDB) { |
| | | return |
| | | } |
| | | this.getfuncTime().then(res => { |
| | |
| | | } |
| | | |
| | | writeFuncs = (funcs) => { |
| | | let timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | let shim = +sessionStorage.getItem('sys_time_shim') |
| | | let timestamp = moment().add(shim, 'seconds').format('YYYY-MM-DD HH:mm:ss') |
| | | |
| | | let sys_datetime = sessionStorage.getItem('sys_datetime') |
| | | let app_datetime = sessionStorage.getItem('app_datetime') |
| | | if (sys_datetime && app_datetime) { |
| | | let seconds = Math.floor((new Date().getTime() - app_datetime) / 1000) |
| | | timestamp = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | // if (window.GLOB.WebSql) { |
| | | // window.GLOB.WebSql.transaction(tx => { |
| | | // tx.executeSql('DELETE FROM FUNCS') |
| | | |
| | | if (window.GLOB.WebSql) { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql('DELETE FROM FUNCS') |
| | | |
| | | funcs.forEach(item => { |
| | | if (!item.key_sql) return |
| | | tx.executeSql('INSERT INTO FUNCS (func_code, key_sql) VALUES (?, ?)', [item.func_code, item.key_sql]) |
| | | }) |
| | | tx.executeSql(`UPDATE VERSIONS SET createDate='${timestamp}' where CDefine1='funcs'`) |
| | | }) |
| | | } else { |
| | | // funcs.forEach(item => { |
| | | // if (!item.key_sql) return |
| | | // tx.executeSql('INSERT INTO FUNCS (func_code, key_sql) VALUES (?, ?)', [item.func_code, item.key_sql]) |
| | | // }) |
| | | // tx.executeSql(`UPDATE VERSIONS SET createDate='${timestamp}' where CDefine1='funcs'`) |
| | | // }) |
| | | // } else { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') |
| | | |
| | | objectStore.clear() |
| | |
| | | |
| | | let funcStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | funcStore.put({id: 'funcs', version: '1.0', createDate: timestamp}) |
| | | } |
| | | // } |
| | | } |
| | | |
| | | getfuncTime = () => { |
| | | return new Promise((resolve, reject) => { |
| | | if (window.GLOB.WebSql) { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql("SELECT * FROM VERSIONS where CDefine1='funcs'", [], (tx, results) => { |
| | | let rows = results.rows |
| | | if (rows.length === 0) { |
| | | tx.executeSql('DELETE FROM FUNCS') |
| | | tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', ['1.0', '1970-01-01 14:59:09.000', 'funcs']) |
| | | resolve({createDate: '1970-01-01 14:59:09.000'}) |
| | | } else { |
| | | resolve(rows[0]) |
| | | } |
| | | }, (tx, results) => { |
| | | reject() |
| | | console.warn(results) |
| | | }) |
| | | }) |
| | | } else { |
| | | // if (window.GLOB.WebSql) { |
| | | // window.GLOB.WebSql.transaction(tx => { |
| | | // tx.executeSql("SELECT * FROM VERSIONS where CDefine1='funcs'", [], (tx, results) => { |
| | | // let rows = results.rows |
| | | // if (rows.length === 0) { |
| | | // tx.executeSql('DELETE FROM FUNCS') |
| | | // tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', ['1.0', '1970-01-01 14:59:09.000', 'funcs']) |
| | | // resolve({createDate: '1970-01-01 14:59:09.000'}) |
| | | // } else { |
| | | // resolve(rows[0]) |
| | | // } |
| | | // }, (tx, results) => { |
| | | // reject() |
| | | // console.warn(results) |
| | | // }) |
| | | // }) |
| | | // } else { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | let request = objectStore.get('funcs') |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // } |
| | | }) |
| | | } |
| | | |
| | | getSmStemp = () => { |
| | | if (!sessionStorage.getItem('msgTemplate')) { |
| | | let _sql = `select ID,TemplateCode,SignName+'_'+describe as SignName from (select * from bd_msn_sms_temp where deleted=0 and status=20 ) a |
| | | inner join (select openid from sapp where id='${window.GLOB.appkey}') b |
| | | on a.openid=b.openid` |
| | | |
| | | _sql = Utils.formatOptions(_sql) |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: _sql, |
| | | obj_name: 'data', |
| | | arr_field: 'ID,TemplateCode,SignName' |
| | | } |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证 |
| | | |
| | | Api.getSystemConfig(param).then(res => { |
| | | let msgs = [] |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } else if (res.data) { |
| | | msgs = res.data |
| | | } |
| | | sessionStorage.setItem('msgTemplate', JSON.stringify(msgs)) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | |
| | | setTimeout(() => { |
| | | this.setSystemFuncs() |
| | | }, 200) |
| | | this.getSmStemp() |
| | | }, 500) |
| | | } |
| | | } |
| | | |