| | |
| | | fn_obj[`timer_${pageKey}`] = null |
| | | } |
| | | |
| | | /** |
| | | * 轮询异步调用接口 |
| | | * @param {Object} page 页面对象this |
| | | * @param {String} fnName 要轮询的方法名称 |
| | | * @param {String} pageKey 页面关键字 |
| | | * @param {Number} timeStamp 多少秒轮询 |
| | | */ |
| | | function pollingAjaxFn(page, fnName, pageKey, timeStamp = 1000) { |
| | | if (!page || !fnName || !pageKey) { |
| | | return |
| | | } |
| | | page[fnName] && page[fnName]() |
| | | fn_obj[`pollingTimer_${pageKey}`] = setTimeout(() => { |
| | | pollingAjaxFn(page, fnName, pageKey, timeStamp) |
| | | }, timeStamp) |
| | | } |
| | | |
| | | /** |
| | | * 停止轮询 |
| | | * @param {String} pageKey 页面关键词 |
| | | */ |
| | | function stopPollingAjaxFn(pageKey) { |
| | | clearTimeout(fn_obj[`pollingTimer_${pageKey}`]) |
| | | fn_obj[`pollingTimer_${pageKey}`] = null |
| | | } |
| | | |
| | | // 随机12位数 |
| | | function getCheckedId() { |
| | | var s = [] |
| | | var hexDigits = '0123456789abcdef' |
| | | for (var i = 0; i < 12; i++) { |
| | | s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1) |
| | | } |
| | | // s[14] = '4'; |
| | | // s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); |
| | | |
| | | // s[8] = s[13] = s[18] = s[23] = '-' |
| | | var uuid = s.join('') |
| | | return uuid |
| | | } |
| | | |
| | | var fn = { |
| | | getLocalStorage, |
| | | getSessionStorage, |
| | |
| | | |
| | | countGetTime, |
| | | stopCountGetTime, |
| | | pollingAjaxFn, |
| | | stopPollingAjaxFn, |
| | | getCheckedId, |
| | | |
| | | /** |
| | | * 深拷贝 |