(function (a) { if (typeof define === "function" && define.amd) { define(["jquery"], a); } else { a(jQuery); } }(function (a) { a.fn.addBack = a.fn.addBack || a.fn.andSelf; a.fn.extend({ actual: function (b, l) { if (!this[b]) { throw '$.actual => The jQuery method "' + b + '" you called does not exist'; } var f = { absolute: false, clone: false, includeMargin: false, display: "block" }; var i = a.extend(f, l); var e = this.eq(0); var h, j; if (i.clone === true) { h = function () { var m = "position: absolute !important; top: -1000 !important; "; e = e.clone().attr("style", m).appendTo("body"); }; j = function () { e.remove(); }; } else { var g = []; var d = ""; var c; h = function () { c = e.parents().addBack().filter(":hidden"); d += "visibility: hidden !important; display: " + i.display + " !important; "; if (i.absolute === true) { d += "position: absolute !important; "; } c.each(function () { var m = a(this); var n = m.attr("style"); g.push(n); m.attr("style", n ? n + ";" + d : d); }); }; j = function () { c.each(function (m) { var o = a(this); var n = g[m]; if (n === undefined) { o.removeAttr("style"); } else { o.attr("style", n); } }); }; } h(); var k = /(outer)/.test(b) ? e[b](i.includeMargin) : e[b](); j(); return k; } }); })); ; (function ($, window, document) { "use strict"; var defaults = { deVal: 0, className: 'dataNums', digit: '' }; function rollNum(obj, options) { this.obj = obj; this.options = $.extend(defaults, options); this.init = function () { this.initHtml(obj, defaults); } } rollNum.prototype = { initHtml: function (obj, options) { var strHtml = ''; obj.html(strHtml); } this.scroNum(obj, options); }, scroNum: function (obj, options) { var number = options.deVal; var $num_item = $(obj).find('.' + options.className).find('.tt'); var h = $(obj).find('.dataBoc').height(); $num_item.css('transition', 'all 2s ease-in-out'); var numberStr = number.toString(); if (numberStr.length <= $num_item.length - 1) { var tempStr = ''; for (var a = 0; a < $num_item.length - numberStr.length; a++) { tempStr += '0'; } numberStr = tempStr + numberStr; } var numberArr = numberStr.split(''); $num_item.each(function (i, item) { setTimeout(function () { $num_item.eq(i).css('top', -parseInt(numberArr[i]) * h - h * 10 + 'px'); }, i * 100) }); } } $.fn.rollNum = function (options) { var $that = this; var rollNumObj = new rollNum($that, options); rollNumObj.init(); }; })(jQuery, window, document); function pimg(id) { var _plist; if (id == null) { _plist = document.getElementsByClassName("_pimg") $('._pimg').each(function () { $(this).attr("_width", $(this).actual('width')); }); } else { _plist = document.getElementById(id.replace("#", "")).getElementsByClassName("_pimg") $(id).find('._pimg').each(function () { $(this).attr("_width", $(this).actual('width')); }); } var h = 0.1; for (var i = 0; i < _plist.length; i++) { h = pimgOnload(_plist[i], h); } } function pimgOnload(el, pheight) { try { var t = 0, d = 0, l = 0, r = 0; if (el.attributes["_m"]) { var m = el.attributes["_m"].value.trim().split(" "); switch (m.length) { case 1: t = m[0]; r = m[0]; d = m[0]; l = m[0]; break; case 2: t = m[0]; r = m[1]; d = m[0]; l = m[1]; break; case 3: t = m[0]; r = m[1]; d = m[2]; break; case 4: t = m[0]; r = m[1]; d = m[2]; l = m[3]; break; default: } } var width = el.offsetWidth; if (width == 0) width = el.attributes["_width"].value; var height = width / el.attributes["_w"].value * el.attributes["_h"].value; if (height > pheight) { if (height - pheight <= 0.5) { height = pheight; } } else if (pheight > height) { if (pheight - height <= 0.5) { height = pheight; } } el.style.height = height - t - d + "px"; el.style.marginBottom = d + "px"; el.style.marginTop = t + "px"; var img = el.getElementsByClassName("_img")[0]; var div = el.getElementsByClassName("_div")[0]; div.style.paddingBottom = height / width * 100 + "%"; div.style.width = width - l - r + "px"; div.style.marginLeft = l + "px"; img.setAttribute("_maxh", height); img.onload = function () { if (this.offsetHeight > 0) { var mheight = this.attributes["_maxh"].value; if (this.offsetHeight < mheight || this.attributes["_b"]) { this.style.width = this.offsetWidth * (mheight / this.offsetHeight) + "px"; this.style.height = mheight + "px"; this.setAttribute("_b", 0); } } } img.onload(); return height; } catch (e) { console.log("pimg错误", el) } return 0; } window.onresize = function () { pimg(null) AOS.refresh(); } function _baidumap(){ if ($('._mapbox').length > 0) { if (window.TILE_VERSION == undefined) { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = "http://api.map.baidu.com/getscript?v=2.0&ak=PGgBx2t0wST5E8OI3dmIYVrzLkurz1BW&services=&t=20140825185308"; document.getElementsByTagName('head')[0].appendChild(script); } for (var i = 0; i < $('._mapbox').length; i++) { $('._mapbox').eq(i).attr('id', "_mapcontent" + i); var style = document.createElement('style'); if ($('._mapbox').eq(i).find('style').length > 0) { style.innerHTML = $('._mapbox').eq(i).find('style').html().split('.').join("\r\n#_mapcontent" + i + " ."); document.getElementsByTagName('head')[0].appendChild(style); } _loadmap(i) } } } function pageInit() { pimg(null); _baidumap(); AOS.init({ easing: 'ease-out-sine', disable: 'mobile' }); } var _scrollot = null, _scroll_os = 0, _scroll_oe = 0, _scroll_h = 0; window.onscroll = function () { if (_scrollot == null) { _scrollot = $("._scrollot"); if (_scrollot.length > 0) { _scroll_os = _scrollot.attr("_s") * 0.01; _scroll_oe = _scrollot.attr("_e") * 0.01; _scroll_h = parseFloat(_scrollot.attr("_h")); } } if (_scrollot != null) { var scrollTop = parseFloat($(document).scrollTop()); if (scrollTop < _scroll_h) { if (_scroll_os < _scroll_oe) { var opacity = scrollTop / _scroll_h * (_scroll_oe - _scroll_os) + _scroll_os; _scrollot.css("opacity", opacity); } else if (_scroll_os > _scroll_oe) { var opacity = _scroll_os - (scrollTop / _scroll_h * (_scroll_os - _scroll_oe)); _scrollot.css("opacity", opacity); } } else { _scrollot.css("opacity", 1); } if (scrollTop > 50) { $("._s50h").hide(); $("._s50s").show(); } else if (scrollTop < 50) { $("._s50h").show(); $("._s50s").hide(); } if (scrollTop > 100) { $("._s100h").hide(); $("._s100s").show(); } else if (scrollTop < 100) { $("._s100h").show(); $("._s100s").hide(); } if (scrollTop > 150) { $("._s150h").hide(); $("._s150s").show(); } else if (scrollTop < 150) { $("._s150h").show(); $("._s150s").hide(); } if (scrollTop > 200) { $("._s200h").hide(); $("._s200s").show(); } else if (scrollTop < 200) { $("._s200h").show(); $("._s200s").hide(); } if (scrollTop > 250) { $("._s250h").hide(); $("._s250s").show(); } else if (scrollTop < 250) { $("._s250h").show(); $("._s250s").hide(); } if (scrollTop > 300) { $("._s300h").hide(); $("._s300s").show(); } else if (scrollTop < 300) { $("._s300h").show(); $("._s300s").hide(); } } } function _popup(_this) { var _html = _this.find('._html').html(); if ($('#_popup').length == 0) { var _popHtml = '
\
\
\
+
\
\
'; $('html').append(_popHtml); } $('#_popup ._html_con').html(_html); $('#_popup').fadeIn(); } function _popupHide() { $('#_popup ._html_con').html(''); $('#_popup').fadeOut(); } function _loadmap(id) { if (window.TILE_VERSION) { parameterMap("_mapcontent" + id); $("_mapcontent" + id).removeClass("_mapbox"); } else { window.setTimeout("_loadmap(" + id + ")", 1000); } } //获取参数并初始化地图 function parameterMap(mapid) { var _map = $("#" + mapid); var _coordinate = _map.attr('data-coordinate').split(','); //坐标 var _level = "17"; //级别 if (_map.attr('data-level')) { _level = _map.attr('data-level'); } var _icon = "icon-1.png"; //图标 var _icon_w = 19;//图标宽度 var _icon_h = 25;//图标高度 if (_map.attr('data-icon')) { _icon = _map.attr('data-icon'); _icon_w = _map.attr('data-icon-w'); _icon_h = _map.attr('data-icon-h'); } var _tit = ""; //标题 if (_map.find('.mapTit').length > 0) { _tit = _map.find('.mapTit').html(); } var _intro = ""; //内容 if (_map.find('.mapIntro').length > 0) { _intro = _map.find('.mapIntro').html(); } var _style = "normal"; //样式 if (_map.attr('data-style')) { _style = _map.attr('data-style'); } var _open = 0; //弹窗默认关闭 if (_map.attr('data-open')) { _open = _map.attr('data-open'); } initMap(mapid, _tit, _intro, _coordinate, _open, _icon, _icon_w, _icon_h, _level, _style);//创建和初始化地图 } //创建和初始化地图函数: function initMap(mapid, _tit, _intro, _coordinate, _open, _icon, _icon_w, _icon_h, _level, _style) { createMap(mapid, _coordinate, _level, _style);//创建地图 setMapEvent();//设置地图事件 addMapControl();//向地图添加控件 //标注点数组 var markerArr = [{ title: _tit, content: _intro, point: _coordinate[0] + "," + _coordinate[1], isOpen: _open, icon: { w: _icon_w, h: _icon_h, l: 0, t: 0, x: 6, lb: 5 } }]; addMarker(markerArr, _icon);//向地图中添加marker } //创建地图函数: function createMap(mapid, _coordinate, _level, _style) { var map = new BMap.Map(mapid);//在百度地图容器中创建一个地图 var point = new BMap.Point(_coordinate[0], _coordinate[1]);//定义一个中心点坐标 map.setMaxZoom(18) map.centerAndZoom(point, _level);//设定地图的中心点和坐标并将地图显示在地图容器中 window.map = map;//将map变量存储在全局 var mapStyle = { //features: ["road", "building", "water", "land"],//隐藏地图上的poi style: _style //设置地图风格为高端黑 } map.setMapStyle(mapStyle); } //地图事件设置函数: function setMapEvent() { map.enableDragging();//启用地图拖拽事件,默认启用(可不写) map.enableScrollWheelZoom();//启用地图滚轮放大缩小 map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写) map.enableKeyboard();//启用键盘上下左右键移动地图 } //地图控件添加函数: function addMapControl() { //向地图中添加缩放控件 var ctrl_nav = new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE }); map.addControl(ctrl_nav); //向地图中添加缩略图控件 var ctrl_ove = new BMap.OverviewMapControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT, isOpen: 0 }); map.addControl(ctrl_ove); //向地图中添加比例尺控件 var ctrl_sca = new BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT }); map.addControl(ctrl_sca); } //创建marker function addMarker(markerArr, _icon) { for (var i = 0; i < markerArr.length; i++) { var json = markerArr[i]; var p0 = json.point.split(",")[0]; var p1 = json.point.split(",")[1]; var point = new BMap.Point(p0, p1); var iconImg = createIcon(json.icon, _icon); var marker = new BMap.Marker(point, { icon: iconImg }); var iw = createInfoWindow(i, markerArr); var label = new BMap.Label(json.title, { "offset": new BMap.Size(json.icon.lb - json.icon.x + 10, -20) }); marker.setLabel(label); map.addOverlay(marker); label.setStyle({ borderColor: "#808080", color: "#333", cursor: "pointer" }); (function () { var index = i; var _iw = createInfoWindow(i, markerArr); var _marker = marker; _marker.addEventListener("click", function () { this.openInfoWindow(_iw); }); _iw.addEventListener("open", function () { _marker.getLabel().hide(); }) _iw.addEventListener("close", function () { _marker.getLabel().show(); }) label.addEventListener("click", function () { _marker.openInfoWindow(_iw); }) if (json.isOpen == 1) { if (json.title.length > 0) { label.hide(); } else { label.remove(); } _marker.openInfoWindow(_iw); } })() } } //创建InfoWindow function createInfoWindow(i, markerArr) { var json = markerArr[i]; var iw = new BMap.InfoWindow("" + json.title + "
" + json.content + "
"); return iw; } //创建一个Icon function createIcon(json, _icon) { var icon = new BMap.Icon(_icon, new BMap.Size(json.w, json.h), { imageOffset: new BMap.Size(-json.l, -json.t), infoWindowOffset: new BMap.Size(json.lb + 5, 1), offset: new BMap.Size(json.x, json.h) }) return icon; }