From 4e10584d477c0fd5da7e3a7164ca04df795a4936 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Wed, 29 Jun 2022 10:47:54 +0800 Subject: [PATCH] 主机类型管理,缓存主动设定的主机类型,并在下次优先使用 --- common/Tools.js | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/common/Tools.js b/common/Tools.js index 0a8afb9..2f36e53 100644 --- a/common/Tools.js +++ b/common/Tools.js @@ -12,12 +12,13 @@ * 显示消息 * @param msg * @param [duration=2000] + * @param [mask=false] */ - static toast(msg, duration = 2000) { + static toast(msg, duration = 2000, mask = false) { Taro.showToast({ title: msg, icon: 'none', - mask: true, + mask, duration, }); } @@ -69,6 +70,22 @@ } /** + * 获取随机字符串 + * @param {number} long + * @return {string} + */ + static getRandomString(long) { + long = long || 32; + const template = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; + const count = template.length; + let result = ''; + for (let i = 0; i < long; i++) { + result += template.charAt(Math.floor(Math.random() * count)); + } + return result; + } + + /** * 检查网络状态 */ static checkOnlineState(callback) { @@ -86,7 +103,7 @@ img.onerror = null; callback && callback(false); }; - img.src = 'http://test.zhiheiot.com/download/buildArchive/online.png?t=' + Date.now(); + img.src = 'http://tt.zhiheiot.com/static/online.png?t=' + Date.now(); } // 网络未开启 else { -- Gitblit v1.9.1