task#14504,kpi的pc端适配js代码影响了后台挂载的H5页面,只给window.location.pathname=='/h5/supplier/dispatch/kpiIndex'加适配

This commit is contained in:
2024-08-07 13:58:50 +08:00
parent 8bed0868f8
commit dedb0f53e9

View File

@ -3,6 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0">-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover,user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover,user-scalable=no">
<meta name="format-detection" content="telephone=yes"/> <meta name="format-detection" content="telephone=yes"/>
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
@ -34,11 +35,11 @@
// VConsole 默认会挂载到 `window.VConsole` 上 // VConsole 默认会挂载到 `window.VConsole` 上
// let vConsole = new window.VConsole(); // let vConsole = new window.VConsole();
(function (doc, win) { (function (doc, win) {
console.log("==window.location.pathname===",window.location.pathname)
let docEl = doc.documentElement let docEl = doc.documentElement
let resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize' let resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
recalc = function () { recalc = function () {
var clientWidth = docEl.clientWidth; var clientWidth = docEl.clientWidth;
// console.log("clientWidth",clientWidth)
if (!clientWidth) return; if (!clientWidth) return;
if (clientWidth < 400) { if (clientWidth < 400) {
clientWidth = 400; clientWidth = 400;
@ -48,13 +49,20 @@
if (!doc.addEventListener) return; if (!doc.addEventListener) return;
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if (isMobile) {// 是移动端不变 if (isMobile) {// 是移动端不变
// console.log("是移动端不变")
}else{ }else{
win.addEventListener(resizeEvt, recalc, false); if(window.location.pathname=='/h5/supplier/dispatch/kpiIndex'){
doc.addEventListener('DOMContentLoaded', recalc, false); // console.log("执行了执行了")
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
}
/*else{
console.log("走着了这种饿 ")
}*/
} }
// console.log("isMobile",isMobile)
})(document, window); })(document, window);
</script> </script>
</body> </body>
</html> </html>