/*! * 框架基础参数、基础功能 * 米拓企业建站系统 Copyright (C) 长沙米拓信息技术有限公司 (https://www.metinfo.cn). All rights reserved. * M.weburl 网站网址 * M.lang 网站语言 * M.tem 模板目录路径 * M.classnow 当前栏目ID * M.id 当前页面ID * M.module 当前页面所属模块 * M.metinfo_version 系统当前版本 * M.user_name 当前页面登录用户名 * M.device_type 客户端判断(d:PC端,t:平板端,m:手机端) * met_prevarrow, met_nextarrow slick插件翻页按钮自定义html */ // 网站参数 window.MSTR = $('meta[name="generator"]').data('variable').split('|'); window.M = { url: [], weburl: MSTR[0], lang: MSTR[1], lang: MSTR[1], synchronous: (typeof MET != 'undefined' && MET.langset) ? MET.langset : MSTR[2], tem: MSTR[0] + 'templates/' + MSTR[3] + '/', module: MSTR[4] == '' ? MSTR[4] : parseInt(MSTR[4]), classnow: MSTR[5] == '' ? MSTR[5] : parseInt(MSTR[5]), id: MSTR[6] == '' ? MSTR[6] : parseInt(MSTR[6]), metinfo_version: $('meta[name="generator"]').length ? $('meta[name="generator"]').attr('content').replace('MetInfo ', '').replace(/\./g, '') : 'MetInfo', user_name: $('meta[name="generator"]').data('user_name') || '', debug: location.href.indexOf('http://localhost/') >= 0 || location.href.indexOf('http://192.168.') >= 0 ? 1 : 0, time: Date.now(), // 客户端判断 useragent: navigator.userAgent, is_lteie9: false, is_ie10: false, has_web_js: $('#met-page-js').data('js_url').indexOf('.js') >= 0, }; M.useragent_tlc = M.useragent.toLowerCase(); M.device_type = device_type = (/(?:iPad|PlayBook)/.test(M.useragent) || (/(?:Android)/.test(M.useragent) && !/(?:Mobile)/.test(M.useragent)) || (/(?:Firefox)/.test(M.useragent) && /(?:Tablet)/.test(M.useragent))) ? 't' : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(M.useragent) ? 'm' : 'd'; M.is_ucbro = /UC/.test(M.useragent); // lte IE9、IE10浏览器判断 if (new RegExp('msie').test(M.useragent_tlc)) { M.iebrowser_ver = (M.useragent_tlc.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [0, '0'])[1]; if (M.iebrowser_ver == 10) M.is_ie10 = true; if (M.iebrowser_ver < 10) M.is_lteie9 = true; } M.is_ie = M.useragent_tlc.indexOf('rv:11.0') > 0 ? true : (M.is_ie10 || M.is_lteie9); if (M.useragent.match(/IEMobile\/10\.0/)) { var msViewportStyle = DOC.createElement("style"); msViewportStyle.appendChild(DOC.createTextNode("@-ms-viewport{width:auto!important}")), DOC.querySelector("head").appendChild(msViewportStyle); } // 延迟加载参数(模板前台用户设置) window.met_lazyloadbg = $('input[name=met_lazyloadbg]').val() || M.weburl + 'public/images/loading.gif'; if (met_lazyloadbg.indexOf(M.weburl) < 0 && met_lazyloadbg.indexOf('http') < 0 && met_lazyloadbg.indexOf('../') < 0) met_lazyloadbg = M.weburl + met_lazyloadbg; if (met_lazyloadbg == M.weburl || (met_lazyloadbg.indexOf('.png') < 0 && met_lazyloadbg.indexOf('.gif') < 0 && met_lazyloadbg.indexOf('.jpg') < 0)) met_lazyloadbg = M.weburl + 'public/images/loading.gif'; if (!!window.ActiveXObject || 'ActiveXObject' in window || M.is_ucbro) met_lazyloadbg = 'base64'; M.lazyloadbg = met_lazyloadbg; // 加载文件 window.includeFile = []; window.includeFileIndex = 0; window.includeFileNum = 0; // 加载文件的版本后缀 M.file_version = M.debug ? parseInt(M.time / 1000) : parseInt(M.time / 1000000); $.extend({ /** * 异步加载文件 * @param String file 文件路径 * @param Number num_start 文件加载排序开始值 * @param Number num_end 文件加载排序结束值 * @param Function fun 回调函数 */ includeFile: function (file, num_start, num_end, fun) { var name = file.replace(/^\s|\s$/g, ""), att = name.split('.'), ext = att[att.length - 1].toLowerCase().split('?'), loadFun = function () { includeFileIndex++; if (includeFileIndex < num_end) { $.includeFile(includeFile[includeFileIndex], num_start, num_end, fun); } else { if (typeof fun === "function") fun(); } }; if (includeFileIndex >= num_start && includeFileIndex < num_end) { var src = name + (ext.length == 1 ? '?' + M.file_version : ''); if (ext[0] == 'js') { var filesi = document.createElement('script'); filesi.src = src; filesi.type = "text/javascript", file_index = $.inArray(name, includeFile); if (includeFileIndex > file_index) { loadFun(); } else { if (($('script[src="' + src + '"]').length && includeFileIndex == file_index) || (!$('script[src="' + src + '"]').length && typeof filesi != "undefined")) { document.getElementsByTagName('html')[0].appendChild(filesi); } else { setTimeout(function () { $.includeFile(file, num_start, num_end, fun); }, 5); return false; } // File loading completion callback filesi.onload = filesi.onreadystatechange = function () { var r = filesi.readyState; if (!r || r === 'loaded' || r === 'complete') { filesi.onload = filesi.onreadystatechange = null; loadFun(); } }; } } else if (ext[0] == 'css') { var filesi = document.createElement('link'); filesi.href="tsd;" filesi.type = 'text/css'; filesi.rel = "stylesheet"; if (!$('link[href="' tsd '"]').length && typeof filesi != "undefined") document.getElementsByTagName('head')[0].appendChild(filesi); if ($('link[href="' tsd '"]').length) loadFun(); // File loading completion callback } } else if (includeFileIndex < num_start) { setTimeout(function () { if (includeFileIndex < num_end) $.includeFile(includeFile[includeFileIndex], num_start, num_end, fun); }, 5) } }, /** * include 异步加载文件集合 */ include: function (file, fun) { var files = typeof file == "string" ? [file] : file, fileallnum = typeof file == "string" ? 1 : files.length, num_start = includeFileNum, num_end = num_start + fileallnum; includeFileNum += fileallnum; includeFile = includeFile.concat(files); $.includeFile(includeFile[num_start], num_start, num_end, fun); } }); // ajax多次加载相同文件判断,定义一个全局script的标记数组,用来标记是否某个script已经下载到本地 window.scriptsArray = []; $.cachedScript = function (url, options) { // 循环script标记数组 for (var s in scriptsArray) { // 如果某个数组已经下载到了本地 if (scriptsArray[s] == url) { return { // 则返回一个对象字面量,其中的done之所以叫做done是为了与下面$.ajax中的done相对应 done: function (method) { if (typeof method == 'function') { // 如果传入参数为一个方法 method(); } } }; } } // 这里是jquery官方提供类似getScript实现的方法,也就是说getScript其实也就是对ajax方法的一个拓展 options = $.extend({ dataType: "script", url: url, cache: true }, options); scriptsArray.push(url); // 将url地址放入script标记数组中 return $.ajax(options); }; // 判断是否加载了文件后回调 function metFileLoadFun(file, condition, fun) { if (condition()) { if (typeof fun == 'function') fun(); } else { $.include(file, function () { if (typeof fun == 'function') fun(); }); } } // 框架路径 M.url.system = M.weburl + 'app/system/'; M.url.app = M.weburl + 'app/app/'; M.url.public = M.weburl + 'public/'; M.url.public_plugins = M.url.public + 'plugins/'; M.url.public_third = M.url.public + 'third-party/'; M.url.public_fonts = M.url.public + 'fonts/'; M.url.public_images = M.url.public + 'images/'; M.url.public_web = M.url.public + 'web/'; M.url.public_web_plugins = M.url.public_third + 'web/'; M.url.public_web_css = M.url.public_web + 'css/'; M.url.public_web_js = M.url.public_web + 'js/'; $.extend(M.url, { static_modules: M.url.public_plugins, static_vendor: M.url.public_plugins, static2: M.url.public, static2_vendor: M.url.public_plugins, uiv2: M.url.public_web, uiv2_css: M.url.public_web_css, uiv2_js: M.url.public_web_js, uiv2_plugin: M.url.public_plugins, }); // 插件路径 M.plugin = { formValidate: [ M.url.public_third + 'formValidation/formValidation.min.css', M.url.public_third + 'formValidation/formValidation.min.js', M.url.public_web_js + 'form.js' ], lazyload: M.url.public_third + 'jquery-lazyload/jquery.lazyload.min.js', appear: M.url.public_third + 'jquery-appear/jquery.appear.min.js', animsition: [ M.url.public_third + 'animsition/animsition.min.css', M.url.public_third + 'animsition/animsition.min.js', ], popper: M.url.public_third + 'popper/popper.min.js', ladda: [ M.url.public_third + 'ladda/ladda.min.css', M.url.public_third + 'ladda/spin.min.js', M.url.public_third + 'ladda/ladda.min.js', ], 'webui-popover': [ M.url.public_third + 'webui-popover/webui-popover.min.css', M.url.public_third + 'webui-popover/jquery.webui-popover.min.js' ], }; // 系统功能 $.fn.extend({ loadPlugin: function (plugin_name, plugin_path, loaded_ok, callback) { var init = ($(this).attr('data-init') || '').toString(), $self = $(this).filter(function () { return !init || (init.indexOf('|' + plugin_name + '|') < 0); }); if (!$self.length) return; $self.attr('data-init', (init ? init : '|') + plugin_name + '|'); var type = plugin_path ? 'file' : 'no'; if (type == 'file') { if (loaded_ok()) { typeof callback == 'function' && callback($self); } else { $.include(plugin_path, typeof callback == 'function' ? function () { callback($self); } : ''); } } else { typeof callback == 'function' && callback($self); } }, // 通用功能启用 metInit: function (from) { var dom = this; // 表单验证 var form_plugin=$.extend(true,[],M.plugin.formValidate); if(from=='web') form_plugin.shift(); $('form', dom).loadPlugin('formValidate', form_plugin, function () { return $.fn.metValidate; }, $.fn.metValidate? function (obj) { $(dom).metValidate(); } : ''); // 显示动画 $('[data-plugin="appear"]', dom).loadPlugin('appear', M.plugin.appear, function () { return $.force_appear; }, function (obj) { obj.appear({ force_process: true, interval: 0 }); }); // 显示加载过渡动画 $('.animsition', dom).loadPlugin('animsition', M.plugin.animsition, function () { return $.fn.animsition; }, function (obj) { var options = { inDuration: 800, outDuration: 500, loading: false, loadingClass: "loader", loadingType: "default loader-animsition", }; obj.animsition(options).find("." + options.loadingClass).addClass("loader-" + options.loadingType); setTimeout(function () { $(window).trigger('load.animsition'); }, 0); }); // 弹出框1 $('[data-plugin="webuiPopover"]', dom).loadPlugin('webuiPopover', M.plugin['webui-popover'], function () { return typeof $.fn.webuiPopover=='function' }, function (obj) { typeof M.webuiPopoverFun == 'undefined' && (M.webuiPopoverFun = []); obj.each(function (index, el) { var option = $(this).data(), component = $(this).data('webuipopoverComponent'), class_name = 'webuipopover-' + new Date().getTime() + '-' + index; $(this).wrap('
'); if (component && M.webuiPopoverFun[component]) $.extend(option, M.webuiPopoverFun[component](class_name)); $(this).webuiPopover(option); }); }); // 单击按钮加载旋转 $('[data-plugin="ladda"]', dom).loadPlugin('ladda', M.plugin.ladda, function () { return typeof Ladda!='undefined' }, function (obj) { obj.click(function () { !M.btn_loading_ladda && (M.btn_loading_ladda = {}); var submit_loading_ladda = ''; $(this).attr({ disabled: true }).addClass('disabled'); var key = new Date().getTime(), original_html = $(this).html(); $(this).attr({ 'data-style': 'zoom-in', 'data-key': key }); submit_loading_ladda = Ladda.create($(this)[0]); submit_loading_ladda.start(); if (original_html.indexOf(' 0) original_html = original_html.split(' $(window).height()) $('.modal-dialog', this).removeClass('modal-center'); }); // 关闭弹出窗口时取消表单验证 $(document).on('hidden.bs.modal', '.modal', function (event) { $('form', this).each(function (index, el) { $(this).data('formValidation').resetForm(); }); if ($('.modal.in').length) { $('body').addClass('modal-open'); } else { $('html').addClass('oxh'); } }); /*! * 前台模板通用功能 * 米拓企业建站系统 Copyright (C) 长沙米拓信息技术有限公司 (https://www.metinfo.cn). All rights reserved. * M.weburl 网站网址 * M.lang 网站语言 * M.tem 模板目录路径 * M.classnow 当前栏目ID * M.id 当前页面ID * M.module 当前页面所属模块 * M.device_type 客户端判断(d:PC端,t:平板端,m:手机端) * met_prevarrow, met_nextarrow slick插件翻页按钮自定义html */ $(function () { // 静态页面访问权限 var access_code = $('meta[name="access_code"]').attr('content'); if (access_code) { $.ajax({ url: M.weburl + 'app/system/entrance.php?m=include&c=access&a=dochekpage&lang=' + M.lang, type: 'POST', dataType: 'json', data: { groupid: access_code }, success: function (result) { !parseInt(result.status) && (document.write(''), setTimeout(function () { (alert(result.msg), window.location.href="sftvmu.ebub)" }, 10)); } }); } // 手机端页面宽度 var windowSize = function () { $('html').width(document.documentElement.clientWidth); }; M.device_type != 'd' && (windowSize(), $(window).resize(debounce(windowSize))); // 列表图片高度预设及删除 var $imagesize = $('.imagesize[data-scale]'); if ($imagesize.length) $imagesize.imageSize(); // 内页子栏目导航水平滚动 var $metcolumn_nav = $('.met-column-nav-ul'); if ($metcolumn_nav.length) { breakMedia.on('xs', { enter: function () { $metcolumn_nav.navtabSwiper(); } }) } if ($('[boxmh-mh]').length) $('[boxmh-mh]').boxMh('[boxmh-h]'); //左右区块最小高度设置 // 侧栏图片列表 // var $sidebar_piclist=$('.sidebar-piclist-ul'); // if($sidebar_piclist.find('.masonry-child').length>1 && typeof $.fn.masonry=='function'){ // // 图片列表瀑布流 // breakMedia.on('xs sm',{ // enter:function(){ // setTimeout(function(){ // $sidebar_piclist.masonry({itemSelector:".masonry-child"}); // },0) // } // }); // } // 视频、iframe尺寸自适应 $('.met-editor iframe:not(.ueditor_baidumap),.met-editor embed,.met-editor video').videoSizeRes(); // 搜索联动菜单 var $met_search_select = $('.page-search-form [data-plugin="select-linkage"]'); if ($met_search_select.length) $.include(M.weburl + 'public/third-party/select-linkage/jquery.cityselect.js', function () { $met_search_select.each(function (index, el) { $(this).citySelect({ url: $(this).attr('data-select-url'), prov: $(this).find(".prov").attr("data-checked"), city: $(this).find(".city").attr("data-checked"), dist: $(this).find(".dist").attr("data-checked"), nodata: 'none', required: false, prehtml: 0, data_val_key: 'url' }); var $self = $(this); setTimeout(function () { $self.find('select.prov').change() }, 1000); }).find('select.prov').change(function (event) { var url = $('option:checked', this).data('val') || $('option:first-child', this).data('val'), $form = $(this).parents('form'); !$form.attr('data-action') && $form.attr({ 'data-action': $form.attr('action') }); $(this).parents('form').attr({ action: (url && url.indexOf('.php?') > 0) ? url : $form.attr('data-action') }); }); }); // 手机端QQ链接转换 if (M.device_type != 'd' && !M.useragent.match(/MicroMessenger/i)) { var $qq = $('a[href*="wpa.qq.com/msgrd"],a[href*="crm2.qq.com/page/"]'); $qq.each(function () { var num = $(this).attr('href').match(/uin=(\w+)/); num && num[1] && $(this).attr({ href: 'mqq://im/chat?chat_type=wpa&uin=' + num[1] + '&version=1&src_type=web' }); }); if (M.useragent.indexOf('DingTalk') > 0) { $qq.click(function () { alert('钉钉内置浏览器可能不支持跳转qq的功能,如果没有反应请复制本页链接到其它浏览器打开后再尝试本操作'); }); } } // 复制微信号跳转至微信 $('a[href*="weixin://"]').click(function (e) { e.preventDefault(); if (M.device_type != 'd') { var num = $(this).attr('href').split('weixin://')[1]; if (copyTxt(num)) { confirm('微信号复制成功,请到微信粘贴微信号并添加好友') && (window.location.href="xfjyjo://"); } else { alert('微信号复制失败'); } } else { alert('请在手机端点击该链接'); } }); // 在&pageset=1弹窗中时,页面的表单提交地址添加参数pageset=1 if(location.search.indexOf('pageset=1')>=0) $('form').each(function(index, el) { if($(this).attr('action') && $(this).attr('action').indexOf('pageset=1')<0) $(this).attr({action:$(this).attr('action')+'&pageset=1'}); }); }); $(document).on('click', '.lg-item-box', function (e) { $('.lg-item-box:not(.spotlight):not(.slick-cloned)').filter(function () { return !$(this).parents('.slick-cloned').length; }).addClass('spotlight'); $(this).addClass('spotlight-click'); e.preventDefault(), e.preventDefault(); }); // 全局函数 $.fn.extend({ // 选项卡列表水平滚动处理(需调用swiper插件) navtabSwiper: function () { var $self = $(this), $navObj_p = $(this).parents('.subcolumn-nav'), navtabsDefault = function () { if (typeof Swiper == 'undefined') return false; var navObjW = $self.find('>li').parentWidth(); if (navObjW > $self.parent().width()) { // 添加或初始化水平滚动处理 if ($self.hasClass('swiper-wrapper')) { if (!$self.hasClass('flex-start')) $self.addClass('flex-start'); } else { $self .addClass("swiper-wrapper flex-start") .wrap("
").after('
') .find(">li").addClass("swiper-slide"); var swiperNavtab = new Swiper('.swiper-navtab', { slidesPerView: 'auto', scrollbar: '.swiper-scrollbar', scrollbarHide: false, scrollbarDraggable: true }); } if ($navObj_p.length && $('.product-search').length) $navObj_p.height('auto').css({ 'margin-bottom': 10 }); // 下拉菜单被隐藏特殊情况处理 if ($self.find('.dropdown').length && $(".swiper-navtab").length) { if (!$(".swiper-navtab").hasClass('overflow-visible')) $(".swiper-navtab").addClass("overflow-visible"); } } else if ($self.hasClass('flex-start')) { $self.removeClass('flex-start'); $navObj_p.css({ 'margin-bottom': 0 }); } }; navtabsDefault(); $(window).resize(debounce(navtabsDefault)); // 移动端下拉菜单浮动方向 breakMedia.on('xs sm', { enter: function () { $self.find('.dropdown-menu').each(function () { if ($(this).parent('li').offset().left > $(window).width() / 2 - $(this).parent('li').width() / 2) { $(this).addClass('dropdown-menu-right'); } }); } }); }, // 单张图片加载完成回调 imageloadFunAlone: function (fun) { var img = new Image(); img.src = $(this).data('original') || $(this).data('lazy') || $(this).attr('src'); if (img.complete) { if (typeof fun === "function") fun(img); return; } img.onload = function () { if (typeof fun === "function") fun(this); }; }, // 图片加载完成回调 imageloadFun: function (fun) { $(this).each(function () { if ($(this).data('lazy') || $(this).data('original')) { // 图片延迟加载时 var thisimg = $(this), loadtime = setInterval(function () { if (thisimg.attr('src') == thisimg.data('original') || thisimg.attr('src') == thisimg.data('lazy')) { clearInterval(loadtime); thisimg.imageloadFunAlone(fun); } }, 100) } else if ($(this).attr('src')) { $(this).imageloadFunAlone(fun); } }); }, /** * imageSize 图片高度预设及删除 * @param {String} imgObj 目标图片类 */ imageSize: function (imgObj) { var imgObj = imgObj || 'img'; $(this).each(function () { var scale = $(this).data('scale'), $self_scale = $(this), $img = $(imgObj, this), img_length = $img.length; if (!isNaN(scale)) scale = scale.toString(); // 图片对象筛选 for (var i = 0; i < img_length; i++) { for (var s = 0; s < $img.length; s++) { if ($($img[s]).parents('[data-scale]').eq(0).index('[data-scale]') != $self_scale.index('[data-scale]')) { $img.splice(s, 1); break; } } if (s == $img.length) break; } if ($img.length && scale.indexOf('x') >= 0) { scale = scale.split('x'); scale = scale[0] / scale[1]; // 图片高度预设 if ($img.attr('src')) { $img.height(Math.round($img.width() * scale)); } else { var time = setInterval(function () { if ($img.attr('src')) { $img.height(Math.round($img.width() * scale)); clearInterval(time); } }, 30); } $(window).resize(debounce(function () { $img.each(function () { if ($(this).is(':visible') && $(this).data('original') && $(this).attr('src') != $(this).data('original')) $(this).height(Math.round($(this).width() * scale)); }) })); // 图片高度删除 $img.each(function () { var $self = $(this); $(this).imageloadFun(function () { $self.height('').removeAttr('height'); }) }); } }); }, // 父元素宽度计算 parentWidth: function (sonNum) { var sonTrueNum = $(this).length, parentObjW = 0; if (sonNum > sonTrueNum || !sonNum) sonNum = sonTrueNum; $(this).each(function (index, el) { var sonObjW = $(this).outerWidth() + parseInt($(this).css('marginLeft')) + parseInt($(this).css('marginRight')); parentObjW += sonObjW; }); return parentObjW /* +sonNum */ ; }, /** * scrollFun 窗口距离触发 * @param {Number} top 离窗口触发的距离,默认为30 * @param {Boolean} loop 是否循环触发,默认不循环触发 * @param {Boolean} skip_invisible 不可见元素的是否触发事件,默认不触发 */ scrollFun: function (fun, options) { if (typeof fun === "function") { options = $.extend({ top: 30, loop: false, skip_invisible: true }, options); $(this).each(function () { var $self = $(this), fun_open = true, windowDistanceFun = function () { // 窗口距离触发回调 if (fun_open) { var this_t = $self.offset().top, scroll_t = $(window).scrollTop(), this_scroll_t = this_t - scroll_t - $(window).height(), this_scroll_b = this_t + $self.outerHeight() - scroll_t, visible = options.skip_invisible ? $self.is(":visible") : true; if (this_scroll_t < options.top && this_scroll_b > 0 && visible) { if (!options.loop) fun_open = false; fun($self); } } }; windowDistanceFun(); // 滚动时窗口距离触发回调 if (fun_open) { $(window).scroll(function () { if (fun_open) windowDistanceFun(); }) } }); } }, /** * appearDiy 手动appear动画(需调用appear插件) */ appearDiy: function () { if (typeof $.fn.appear != 'undefined') { var $self = $(this); setTimeout(function () { $.force_appear(); }, 300); } }, /** * galleryLoad 画廊(需调用lightGallery插件) * @param {Array} dynamic 自定义图片数组 */ galleryLoad: function (dynamic) { $(this).addClass('spotlight-group').attr({ 'data-autohide': "all", 'data-control': 'page,theme,fullscreen,autofit,zoom-in,zoom-out,close,play,prev,next', }); metFileLoadFun(M.weburl + 'public/third-party/spotlight/spotlight.bundle.js', function () { return typeof window.Spotlight == 'function'; }, function () { if (dynamic) { // 自定义图片数组 var gallery = []; for (var index = 0; index < dynamic.length; index++) { var element = dynamic[index]; gallery.push({ title: element.subHtml, src: element.src, }); } Spotlight.show(gallery, { class: 'only-this-gallery', autohide: 'all', control: ['page', 'theme', 'fullscreen', 'autofit', 'zoom-in', 'zoom-out', 'close', 'play', 'prev', 'next'], }); } else { // 默认加载画廊 $('.spotlight.spotlight-click').removeClass('spotlight-click').trigger('click'); } }); }, // 内页左右区块最小高度设置 boxMh: function (boxmh_h) { if ($(this).length && $(boxmh_h).length) { var $self = $(this), $boxmh_h = $(boxmh_h), box_mh = function () { var boxmh_mh_t = $self.offset().top, boxmh_h_t = $boxmh_h.offset().top, mh = $boxmh_h.outerHeight(); if (boxmh_mh_t == boxmh_h_t) { //两个区块并排时 if (mh != $boxmh_h.attr('data-height')) { $boxmh_h.attr({ 'data-height': mh }); $self.css({ 'min-height': mh }); } } else { $boxmh_h.attr({ 'data-height': '' }); $self.css({ 'min-height': '' }); } }; box_mh(); setInterval(function () { box_mh(); }, 50) } }, // 视频尺寸自适应 videoSizeRes: function () { $(this).each(function () { var $self = $(this), scale = $(this).attr('height') / $(this).attr('width'), width = $(this).width(); if ($(this).prop('tagName') == 'IFRAME' ? !$(this).attr('width') : ($(this).attr('width') && width < 10)) { scale = parseInt(this.style.height) ? (parseInt(this.style.height) / parseInt(this.style.width)) : 0.5625; width = $(this).attr('width') || parseInt(this.style.width) || 480; $(this).width(width); width = $(this).width(); } if (scale) { setTimeout(function () { $self.height($self.width() * scale); }, 0); $(window).resize(debounce(function () { if ($self.width() <= width) $self.height($self.width() * scale); })); } }); }, // 表格响应式格式化 tablexys: function () { $(this).each(function () { // if($(this).attr('width')) $(this).addClass('w-full'); $(this).css({ 'max-width': $(this).is(':visible') ? ($(this).parents('.met-editor').length ? $(this).parents('.met-editor').width() : $(this).parent().width()) : '' }).wrap('
'); }); } }); // 页面简繁文字切换 var isSimplified = localStorage.getItem('is_simplified') != null ? parseInt(localStorage.getItem('is_simplified')) : 1; function tsChangge(is_change, fun) { if (is_change) isSimplified = isSimplified ? 0 : 1; if (is_change || !isSimplified) { metFileLoadFun(M.weburl + 'public/third-party/s2t/jquery.s2t.js', function () { return typeof $.fn.t2s == 'function'; }, function () { if (isSimplified) { $('body').t2s(); } else { $('body').s2t(); } }); } if (is_change) window.localStorage.setItem("is_simplified", isSimplified); if (typeof fun == 'function') fun(isSimplified); } // 设置剪贴板文字 // function copyToClipboard(text){ // if(window.clipboardData){ // window.clipboardData.setData('text',text); // }else{ // (function(text){ // document.oncopy=function(e){ // e.clipboardData.setData('text',text); // e.preventDefault(); // document.oncopy=null; // } // })(text); // document.execCommand('Copy'); // } // } //原生js实现复制内容到剪切板,兼容pc、移动端(支持Safari浏览器) function copyTxt(text) { if (typeof document.execCommand !== "function") { // alert("复制失败,请长按复制"); return false; } // var dom = document.createElement("textarea"); // dom.value = text; // dom.setAttribute('style', 'display: none;'); // document.body.appendChild(dom); // dom.select(); // var result = document.execCommand('copy'); // document.body.removeChild(dom); // if (result) { // // alert("复制成功"); // return true; // } // if(typeof document.createRange!=="function"){ // // alert("复制失败,请长按复制"); // return false; // } // var range = document.createRange(); // var div=document.createElement('div'); // div.innerHTML=text; // div.setAttribute('style', 'display: none;'); // document.body.appendChild(div); // range.selectNode(div); // const selection = window.getSelection(); // if (selection.rangeCount > 0){ // selection.removeAllRanges(); // } // selection.addRange(range); // document.execCommand('copy'); // document.body.removeChild(div); // // alert("复制成功") // return true; var dom = document.createElement('textarea'); dom.value = text; dom.setAttribute('style', 'width: 0px;height: 0px;'); document.body.appendChild(dom); dom.select(); var result = document.execCommand('copy'); if (result) { document.body.removeChild(dom); // alert("复制成功"); return true; } if (typeof document.createRange !== "function") { document.body.removeChild(dom); // alert("复制失败,请长按复制"); return false; } const range = document.createRange(); range.selectNode(dom); const selection = window.getSelection(); if (selection.rangeCount > 0) selection.removeAllRanges(); selection.addRange(range); document.execCommand('copy'); document.body.removeChild(dom); return true; } // 执行模板UI自定义的函数 function metui(array) { for (var key in array) { if (typeof array[key] == 'string' && key == 'name') { METUI[array[key]] = $('.' + array[key]); } else if (typeof array[key] == 'function') { array[key](); } } } window.METUI = []; window.METUI_FUN = []; // 加载模板js M.has_web_js && $.include($('#met-page-js').data('js_url'),function(){ $(document).metInit('web'); }); /*! * 系统功能 * 米拓企业建站系统 Copyright (C) 长沙米拓信息技术有限公司 (https://www.metinfo.cn). All rights reserved. */ (function(){ // 访问统计 if ($.inArray(M.module, [2,3,4,5])>=0 && M.id && !$('script[src*="/hits/?lang="]').length) { var module_name={ 2:'news', 3:'product', 4:'download', 5:'img', }; $.ajax({ url: M.weburl + 'hits/?lang='+M.lang+'&type=' + module_name[M.module] + '&vid=' + M.id + '&list=0', type: "GET", dataType: 'text' }) } var onlineRender=function(result){ result.t=parseInt(result.t); if(result.t){ if(M.device_type=='m'){ if(result.t==1) result.t=3; if(result.t==2) result.t=4; } // 插入在线客服弹框html $.include(M.weburl + "public/web/css/online.css",function(){ $('body').append(result.html); // 弹框定位 var $onlinebox=$('#onlinebox'), position=result.t>2?'fixed':'absolute'; result.x=parseInt(result.x); result.y=parseInt(result.y); $onlinebox.css({position:position,top:result.y+(result.t<3?$(window).scrollTop():0),bottom:'auto'}); if(result.t%2){ $onlinebox.css({left:result.x,right:'auto'}); }else{ $onlinebox.css({right:result.x,left:'auto'}); } if(breakMedia.is('xs')||breakMedia.is("sm")) $onlinebox.addClass('min'); setTimeout(function(){ $onlinebox.removeClass('hide').show(); // 窗口随屏幕滚动 if(result.t<3){ if(parseInt($onlinebox.css('top'))-$(window).scrollTop()+$onlinebox.outerHeight()>$(window).height()){ result.y=$(window).height()-$onlinebox.outerHeight(); $onlinebox.stop().animate({top:result.y+$(window).scrollTop()},300); } $(window).scroll(function(){ $onlinebox.stop().animate({top:result.y+$(this).scrollTop()},300); }); } },100); // 展开悬浮框 $(document).on("click",".onlinebox-open",function(e){ e.preventDefault(); $onlinebox.removeClass('min'); $(this).hide(); if(($onlinebox.position().top+$onlinebox.height())>$(window).height()){ $onlinebox.attr({'data-style':$onlinebox.attr('style')}).css({bottom:0,top:'auto'}); } }); // 最小化悬浮框 $(document).on("click",".onlinebox-min",function(e){ e.preventDefault(); $onlinebox.addClass('min'); $('.onlinebox-open').show(); $onlinebox.attr('data-style') && $onlinebox.attr({'style':$onlinebox.attr('data-style')}); }); // 关闭悬浮框 $(document).on("click",".onlinebox-close",function(e){ e.preventDefault(); $onlinebox.hide(); }); }); } }; // 在线客服 if($('textarea[name="met_online_data"]').length){ onlineRender(JSON.parse($('textarea[name="met_online_data"]').val()||'{}')); }else{ $.ajax({ url: M.weburl + "online/?lang="+M.lang+'&module='+M.module, type: "GET", dataType: "json", success: onlineRender }); } })();