// 前端模板 ! function(a) { "use strict"; var b = function(a, c) { var d = /[^\w\-\.:]/.test(a) ? new function(b.arg + ",tmpl", "var _e=tmpl.encode" + b.helper + ",_s='" + a.replace(b.regexp, b.func) + "';return _s;") : b.cache[a] = b.cache[a] || b(b.load(a)); return c ? d(c, b) : function(a) { return d(a, b) } }; b.cache = {}, b.load = function(a) { return document.getelementbyid(a).innerhtml }, b.regexp = /([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\s]+?)%\})|(\{%)|(%\})/g, b.func = function(a, b, c, d, e, f) { return b ? { "\n": "\\n", "\r": "\\r", " ": "\\t", " ": " " } [b] || "\\" + b : c ? "=" === c ? "'+_e(" + d + ")+'" : "'+(" + d + "==null?'':" + d + ")+'" : e ? "';" : f ? "_s+='" : void 0 }, b.encreg = /[<>&"'\x00]/g, b.encmap = { "<": "<", ">": ">", "&": "&", '"': """, "'": "'" }, b.encode = function(a) { return (null == a ? "" : "" + a).replace(b.encreg, function(a) { return b.encmap[a] || "" }) }, b.arg = "o", b.helper = ",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}", "function" == typeof define && define.amd ? define(function() { return b }) : a.tmpl = b }(this); // 迷你发布订阅系统 (function($) { var o = $({}); $.subscribe = function() { o.on.apply(o, arguments); }; $.unsubscribe = function() { o.off.apply(o, arguments); }; $.publish = function() { o.trigger.apply(o, arguments); }; }($)); /*hgc缓慢滚动函数(不能删除)*/ function scrolltonaverslowly(naverjqele, duration = 1000) { var windowwidth = $(window).width() var movenum = 0 if (windowwidth > 1182) { movenum = 120 if (windowwidth >= 1920) { movenum = 150 } } else { movenum = 60 if (windowwidth >= 768) { movenum = 80 } } try { var scrolltop = (naverjqele.offset().top) - movenum $('html,body').animate({ scrolltop: scrolltop }, duration); } catch(e) { } } $(function() { 'use strict'; var win = window; win.global = win.global || {}; win.hr = win.hr || {}; win.hr.version = '1.6.12'; win.hr.page = win.hr.page || {}; win.hr.component = win.hr.component || {}; /** * @description 注册组件 * @param {string} name 组件名字 * @param {object} obj 组件 javascript 逻辑,json 格式 * @return {object} 返回 window.hr.component 对象 * @example * hr.regcomponent('组件名', { * init: function () { // 此 init 方法为必需,组件注册后会执行的方法 * this.someaction(); * }, * someaction: function () { * // 组件 javascript 逻辑,可以根据需要写多个 function * } * }); * 组件注册后如果要再次调用,可以用 hr.component.组件名 获取组件对象 */ win.hr.regcomponent = function(name, obj) { if (typeof name == 'string' && name !== '') { win.hr.util._createnamespace(name.split('.'), obj, win.hr.component); } }; /** * @description 注册页面 * @param {string} name 页面名字 * @param {object} obj 页面 javascript 逻辑,json 格式 * @return {object} 返回 window.hr.page 对象 * @example * hr.regpage('页面名', { * init: function () { // 此 init 方法为必需,组件页面后会执行的方法 * this.someaction(); * }, * someaction: function () { * // 页面 javascript 逻辑,可以根据需要写多个 function * } * }); * 页面注册后如果要再次调用,可以用 hr.page.页面名 获取页面对象 */ win.hr.regpage = function(name, obj) { if (typeof name == 'string' && name !== '') { win.hr.util._createnamespace(name.split('.'), obj, win.hr.page); } }; win.hr.util = { /** * @description 渲染模板 * @param {json} opt 包含以下内容 * @param {string} opt.tmpl 模板区域的 id 名 * @param {object} opt.data 要渲染的 json 数据 * @param {object} opt.to 要追加进的 jquery dom 对象 * @param {object} opt.insertto 要插入到其之前或之后的 jquery dom 对象 * @param {string} opt.method 渲染的方式,包括 replace、append 和 prepend,当同时有 insertto 时,是以 insertto 为基准 * @param {function} opt.callbackfn 回调函数 */ rendertmpl: function(opt) { var strtargettmpl = opt.tmpl || ''; var jsondata = opt.data || {}; var $target = opt.to; var method = opt.method || 'append'; var $insertto = opt.insertto || null; if ($target) { var tmpled = tmpl(strtargettmpl, jsondata); switch (method) { case 'replace': $target.html(tmpled); break; case 'append': if ($insertto) { $(tmpled).insertafter($insertto); } else { $target.append(tmpled); } break; case 'prepend': if ($insertto) { $(tmpled).insertbefore($insertto); } else { $target.prepend(tmpled); } break; default: break; } } $.isfunction(opt.callbackfn) && opt.callbackfn(); }, /** * @description 从 url 中获取指定参数值 * @param {string} str 要从 url 中获取的参数值 */ geturlparam: function(str) { var s = location.search; var tmp = []; var value = ''; if (s) { tmp = s.substr(1).split('&'); } for (var i = 0; i < tmp.length; i++) { if (tmp[i].substring(0, tmp[i].indexof('=')) === str) { value = tmp[i].substr(tmp[i].indexof('=') + 1); break; } } return value; }, /** * @description 使用 rem 单位时自动计算 html 初始字体尺寸。比如设计稿是 750px 的,那么对应的 1rem 就等于 100px;如果设计稿是非标准尺寸,比如 844px,那么可以传入参数 basewidth 844,这样可以保证 1rem 等于 100px,便于计算。 * @param {number} basewidth 基准尺寸 */ resizepage: function(basewidth) { var basew = basewidth || 750; var docel = document.documentelement, resizeevt = 'orientationchange' in win ? 'orientationchange' : 'resize', recalc = function() { var clientwidth = docel.clientwidth; if (!clientwidth) { return; } if (clientwidth > basew) { clientwidth = basew; } docel.style.fontsize = 100 * (clientwidth / basew) + 'px'; }; if (!document.addeventlistener) { return; } win.addeventlistener(resizeevt, recalc, false); recalc(); }, /** * @description 内部方法,创建一个命名空间 */ _createnamespace: function(parts, obj, parent) { var obj = obj || { init: function() {} }; var i = 0; if (parts[0] === 'hr') { parts = parts.slice(1); } for (i = 0; i < parts.length; i++) { if (typeof parent[parts[i]] == 'undefined') { parent[parts[i]] = obj; // 组件或页面注册后执行 obj.init(); } parent = parent[parts[i]]; } }, nav: function() { // hgc 2021-02-07 22:02调整 $('.main').css('padding-top', '60px') if ($(window).width() > 1182) { // 因导航常驻,需要补充100px用于存放导航,防止main内容被遮挡 $('.main').css('padding-top', '100px') $('.header').addclass('active'); // 用于子菜单的显示 $('.ul-nav li').on('mouseenter', function() { $(this).find('.child').stop().slidedown(150); }) // 用于子菜单的隐藏 $('.ul-nav li').on('mouseleave', function() { $(this).find('.child').stop().slideup(150); }) $(window).on('scroll', function() { if ($(window).scrolltop() > 100) { $('.header').addclass('active'); } else { // $('.header').removeclass('active'); } }) // $('.header').on('mouseenter', function() { // if ($(window).scrolltop() <= 100) { // $(this).addclass('active'); // } // // }) // $('.header').on('mouseleave', function() { // if ($(window).scrolltop() <= 100) { // $(this).removeclass('active'); // } // // }) } $('.ul-nav li a.v1').on('click', function() { if ($(window).width() < 1200 && $(this).siblings('.child').size() > 0) { $(this).siblings('.child').stop().slidetoggle(150); $(this).toggleclass('active'); return false; } }) $('.footer .ft-top .item h4').on('click', function() { if ($(window).width() < 1200 && $(this).siblings('.link').size() > 0) { $(this).siblings('.link').stop().slidetoggle(150); $(this).toggleclass('active'); return false; } }) $('.menubtn').on('click', function() { $(this).toggleclass('active'); $('.header .r-con').stop().slidetoggle(150); }) }, //wow wowinit: function() { new wow().init(); }, /* *返回顶部 */ gotop: function() { $(".footer .ft-backtop").click(function() { $("html,body").animate({ scrolltop: 0 }, 500); }); }, }; win.hr.init = function() { // todo 这里放页面初始化时需要执行的代码 hr.util.nav(); hr.util.wowinit(); hr.util.gotop(); // 解决锚点跳转被导航遮挡的问题 begin if (location.hash.indexof('#') >= 0) { settimeout(function(){ scrolltonaverslowly($(location.hash), 0) }, 150) } // 解决锚点跳转被导航遮挡的问题 end }; win.hr.init(); });