export const saveEchartsDataToLocal = (time, binObj, envir1Obj, envir2Obj) => { if (localStorage.getItem('bin')) { const binLocal = JSON.parse(localStorage.getItem('bin')) resolveData(binLocal, time, binObj, 'bin') } else { resolveData({}, time, binObj, 'bin') } if (localStorage.getItem('envir1')) { const envir1Local = JSON.parse(localStorage.getItem('envir1')) resolveData(envir1Local, time, envir1Obj, 'envir1') } else { resolveData({}, time, envir1Obj, 'envir1') } if (localStorage.getItem('envir2')) { const envir2Local = JSON.parse(localStorage.getItem('envir2')) resolveData(envir2Local, time, envir2Obj, 'envir2') } else { resolveData({}, time, envir2Obj, 'envir2') } } function resolveData(obj, time, newData, key) { if (obj.hasOwnProperty('time')) { return } else { obj[time] = newData } localStorage.setItem(key, JSON.stringify(obj)) } export const time_To_hhmmss = seconds => { if (seconds <= 0) { return 0 } var hh var mm var ss //传入的时间为空或小于0 if (seconds == null || seconds < 0) { return } //得到小时 hh = (seconds / 3600) | 0 seconds = parseInt(seconds) - hh * 3600 if (parseInt(hh) < 10) { hh = '0' + hh } //得到分 mm = (seconds / 60) | 0 //得到秒 ss = parseInt(seconds) - mm * 60 if (parseInt(mm) < 10) { mm = '0' + mm } if (ss < 10) { ss = '0' + ss } return hh + ':' + mm + ':' + ss }