123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- // 默认显示宠物和医院
- $(function(){
- setTime();
- // 初始化数据
- initData();
- // 初始化大屏样式
- initScreen();
- var isFirstLoadding = localStorage.getItem('isFirstLoadding');
- // 第一次加载
- if (isFirstLoadding === null) {
- $('#pets_distribute').attr('checked','checked');
- localStorage.setItem('isShowPets',true);
- $('#pets_hospital').attr('checked','checked');
- localStorage.setItem('isShowHospital',true);
- localStorage.setItem('isFirstLoadding',false);
- } else {
- localStorage.getItem('isShowPets') && $('#pets_distribute').attr('checked','checked');
- localStorage.getItem('isShowHospital') && $('#pets_hospital').attr('checked','checked');
- }
- // 初始化地图
- initBdMap();
-
- });
- //时间
- var timer = null;
- function setTime(){
- if(timer !== null){
- clearTimeout(timer);
- }
- setTimeout(function () {
- $("#date").text(getTime()[0]);
- $("#time").text(getTime()[1] +" "+ getTime()[2]);
- setTime();
- },1000);
- }
- // 初始化数据
- function initData() {
- getHospitalData();
- getPetData();
- getSearchPetsData();
- getRecordPetsPieData();
- getRecordRankingData();
- }
- // 初始化大屏
- function initScreen() {
- $('#position_left').text() && $('#position_left').html('');
- $('#position_top').text() && $('#position_top').html('');
- $('#position_right').text() && $('#position_right').html('');
- // 头部导航
- initTopNav();
- // 上牌排名
- initRecordRank();
- // 数据统计
- initStatistics();
- // 备案宠物品种统计
- initRecordPetsPie();
- // 寻宠轮播
- initSearchPets();
- // 初始化tips
- initStyle();
- }
- // 窗口尺寸改变
- $(window).resize(function(e){
- initStyle();
- });
- // 设置悬浮图标Css
- function initStyle() {
- var window_w = $(window).width();
- var position_left_w = $('#position_left').width();
- var position_right_w = $('#position_right').width();
-
- if ( window_w < 1200 + 40 ) {
- $('#position_top').css({left:"10px",width:"99%"});
- $('#position_left').css({top:"150px"});
- $('#position_right').css({top:"150px"});
- } else {
- $('#position_top').css({left: (position_left_w + 20) +"px",width: (window_w - position_left_w - position_right_w - 40) +"px"});
- $('#position_left').css({top:"90px"});
- $('#position_right').css({top:"90px"});
- }
- $('#cityOpt').css({left:(position_left_w + 20) +"px"});
- }
- // 显示/隐藏城市
- function showCityOpt() {
- $('#cityOpt').show();
- }
- function hideCityOpt() {
- $('#cityOpt').hide();
- }
- // 寻宠轮播
- setInterval(function(){
- var times = searchPetsData.length;
- if (times <= 1) {
- return;
- }
- $('#pets-carousel-item'+searchPetsIndex).hide();
- searchPetsIndex++;
- if (searchPetsIndex == times) {
- searchPetsIndex = 0;
- }
- $('#pets-carousel-item'+searchPetsIndex).show();
- },searchPetsInterval * 1000);
- // 全屏模式
- function fullScreen() {
- var e = document.documentElement
- , a = e.requestFullScreen || e.webkitRequestFullScreen || e.mozRequestFullScreen || e.msRequestFullscreen;
- "undefined" != typeof a && a && a.call(e)
- }
- function exitScreen() {
- document.documentElement;
- document.exitFullscreen ? document.exitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitCancelFullScreen ? document.webkitCancelFullScreen() : document.msExitFullscreen && document.msExitFullscreen()
- }
- $('.nav-full-screen').on('click',function(e){
- var a = "nav-icon-screen-full"
- , t = "nav-icon-screen-restore";
- $(this).hasClass(a) ? (fullScreen(),$(this).addClass(t).removeClass(a).attr('src',compbase + '/icon/min-screen.png')) : (exitScreen(),$(this).addClass(a).removeClass(t).attr('src',compbase + '/icon/full-screen.png'));
- });
- // 显示/隐藏宠物覆盖物
- $(document).on('click','#pets_distribute',function(){
- var isChecked = $(this).attr('checked');
- if (isChecked) {
- $(this).removeAttr('checked');
- localStorage.removeItem('isShowPets');
- } else {
- $(this).attr('checked','checked');
- localStorage.setItem('isShowPets',true);
- }
- initBdMap();
- });
- // 显示/隐藏宠物医院覆盖物
- $(document).on('click','#pets_hospital',function(){
- var isChecked = $(this).attr('checked');
- if (isChecked) {
- $(this).removeAttr('checked');
- localStorage.removeItem('isShowHospital');
- } else {
- $(this).attr('checked','checked');
- localStorage.setItem('isShowHospital',true);
- }
- initBdMap();
- });
- // 切换城市
- $(document).on('click','.city-choose',function(e){
- var cityid = $(this).data('cityid');
- cityData.some(function(item1){
- if (item1.id == cityid) {
- curCityInfo = item1;
- return true;
- }
- item1.sub && item1.sub.some(function(item2){
- if (item2.id == cityid) {
- curCityInfo = item2;
- return true;
- }
- })
- });
- localStorage.setItem('curCityInfo',JSON.stringify(curCityInfo));
- // 重新加载数据
- getHospitalData();
- getPetData();
- getSearchPetsData();
- getRecordPetsPieData();
- getRecordRankingData();
- initScreen();
- initBdMap();
- });
|