var isPC = IsPC();//獲取是否為PC端
if (!isPC) {//如果是移動端加載
(function (win) {
var doc = win.document;
var docEl = doc.documentElement;
var tid;
function refreshRem() {
var width = docEl.getBoundingClientRect().width;
// if (width > 750) { // 最大寬度
// width = 750;
// }
var rem = width / 7.5;
docEl.style.fontSize = rem + 'px';
}
win.addEventListener('resize', function () {
clearTimeout(tid);
tid = setTimeout(refreshRem, 300);
}, false);
win.addEventListener('pageshow', function (e) {
if (e.persisted) {
clearTimeout(tid);
tid = setTimeout(refreshRem, 300);
}
}, false);
refreshRem();
})(window);
$().ready(function () {
// 移動檢索
$('.button_so').on("click", function () {
var display = $(".mobile_search").css("display");
if (display == 'none') {
$('.mobile_search').css('display', 'block');
$('.button_so').css('background', 'url(../../../../images/zwfw-close.png)');
} else {
$('.mobile_search').css('display', 'none');
$('.button_so').css('background', 'url(../../../../images/zwfw-zwfwmh_sj_so.png)');
}
});
// 移動導航
$('.mnav').click(function () {
$('.monavber>.container>ul').slideToggle();
$('.search_main').hide();
$('.search_main').css({ left: '-100%' });
$('.search').html('');
});
$(".navbar>li").each(function () {
if ($(this).find("li").length > 0) {
$(this).append('
');
}
$(this).find(".toggle-btn").click(function () {
var _this = this;
$(_this).find(".nav_add").css("transform", 'rotate(0)');
$(_this).prev("ul").slideToggle(200);
});
});
$('.toggle-btn').click(function (event) {
event.stopPropagation(); // 阻止事件冒泡
var _this = this;
if ( _this.rotate == 45) {
_this.rotate = 0
$(_this).find(".nav_add").css("transform", 'rotate(45deg)');
} else {
_this.rotate = 45
$(_this).find(".nav_add").css("transform", 'rotate(0)');
}
})
$('.button_menu').click(function(event) {
event.stopPropagation(); // 阻止事件冒泡
var _this = this
if($('.navbar').css("display") == 'none') {
$('.navbar').css("display", 'block');
} else {
$('.navbar').css("display", 'none');
}
})
$(document).click(function() {
$('.navbar').css("display", 'none');
})
})
} else {
$().ready(function () {
$('.box1').on("mouseenter", function () {
console.log()
$('.boxbg').css('width', '0');
$('.box1_nr').css('width', '580px');
$('.box').css('width', '80px');
});
$('.box2').on("mouseenter", function () {
$('.boxbg').css('width', '0');
$('.box2_nr').css('width', '580px');
$('.box').css('width', '80px');
});
$('.box3').on("mouseenter", function () {
$('.boxbg').css('width', '0');
// $('.box3_nr').css('width', '580px');
$('.box').css('width', '179px');
});
$('.box4').on("mouseenter", function () {
$('.boxbg').css('width', '0');
// $('.box4_nr').css('width', '580px');
$('.box').css('width', '179px');
});
$('.box5').on("mouseenter", function () {
$('.boxbg').css('width', '0');
// $('.box5_nr').css('width', '580px');
$('.box').css('width', '179px');
});
$('.box6').on("mouseenter", function () {
$('.boxbg').css('width', '0');
$('.box6_nr').css('width', '580px');
$('.box').css('width', '80px');
});
})
}
function IsPC() {//獲取設備是否為PC的方法
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) >= 0) {
flag = false;
break;
}
}
return flag;
};
function dynamicLoadCss(url) {//加載css方法
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = url;
head.appendChild(link);
}
function dynamicLoadJs(url, callback) {//加載js方法
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
if (typeof (callback) == 'function') {
script.onload = script.onreadystatechange = function () {
if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
callback();
script.onload = script.onreadystatechange = null;
}
};
}
head.appendChild(script);
}