// 设置根节点html的字体大小用于移动端适配使用
export const setHtmlFontSize = () => {
console.count("setHtmlFontSize");
(function (doc, win) {
let resizeEvt = "orientationchange" in win ? "orientationchange" : "resize",
recalc = function () {
let htmlDom = doc.getElementsByTagName("html")[0];
requestAnimationFrame(() => {
let clientWidth = doc.documentElement.clientWidth || doc.body.clientWidth;
if (!clientWidth) return;
htmlDom.style.fontSize =
clientWidth >= 578.88 ? "144px" : 154.5 * (clientWidth / 578.88) + "px";
});
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener("DOMContentLoaded", recalc, false);
recalc();
})(document, window);
};
// 密码正则 6到12位(字母,数字,下划线,减号)
export const pwdRegex = (pwd = '') => {
let regex = /^[a-zA-Z0-9_-]{6,12}$/;
return regex.test(pwd)
}
// 手机号正则
export const phoneRegex = (pwd = '') => {
let regex = /^1[3-9]\d{9}$/;
return regex.test(pwd)
}