qq_41295110
2025-07-15 ba04983aaf5cbb0d57c4ec3530ee1663f0f83115
utils/common.js
@@ -87,7 +87,45 @@
   isAllDigits(str) {
      return /^\d+$/.test(str);
   }
   isJson(str) {
      try{
         JSON.parse(str)
         return true
      }catch{
         return false
      }
   }
   timeClock(callback, delay) {
       let timeoutId;
       let isRunning = false;
       function interval() {
           timeoutId = setTimeout(() => {
               callback();
            clearTimeout(timeoutId); // 立即清除当前定时器ID
               if (isRunning) {
                   interval();
               }
           }, delay);
       }
       return {
           start() {
               if (!isRunning) {
                   isRunning = true;
                   interval();
               }
           },
           stop() {
               if (isRunning) {
                   isRunning = false;
                   clearTimeout(timeoutId);
               }
           }
       };
   }
   // uni-app 使用 封装请求函数 使用传统函数当作回调需要传that,箭头函数不需要
   doRequest(url, data, resFunction, errFunction, method, that) {
      that = that || this;
@@ -124,14 +162,17 @@
            } else {
               throw new TypeError("访问失败回调函数类型不为函数或者空!")
            }
         },complete() {
            setTimeout(() => {
               uni.hideLoading()
               if (errorTip != null) {
                  errorTip()
               }
            }, 1000)
         }
      })
      setTimeout(() => {
         uni.hideLoading()
         if (errorTip != null) {
            errorTip()
         }
      }, 1000)
   }
}