From aeb317703c9c82edb7c4c7ecc5985eef62864c7c Mon Sep 17 00:00:00 2001 From: jazz <jazzxhunter@163.com> Date: 星期二, 05 十二月 2023 19:41:21 +0800 Subject: [PATCH] update_202312051941_项目-治疗室屏幕web-切图v1 --- src/utils/fn.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/src/utils/fn.js b/src/utils/fn.js index c569024..15fa356 100644 --- a/src/utils/fn.js +++ b/src/utils/fn.js @@ -330,6 +330,47 @@ 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, @@ -358,6 +399,9 @@ countGetTime, stopCountGetTime, + pollingAjaxFn, + stopPollingAjaxFn, + getCheckedId, /** * 娣辨嫹璐� -- Gitblit v1.8.0