//空间天气 define(['html!templates/meteo/spaceWeather'], function (html) { function init() { //--------------添加布局---------------- $('body').append(html); require(['meteoDir/other/jquery.easyui.min'], function () { $('.meteo-popup').draggable(); }); //----------------功能开启/关闭---------------- $('#meteo-bt-space').click(function () { if ($('.meteo-sw-box').is(':hidden')) { //设置zIndex 为最高 var zIndex = ONEMAP.M.sideBar.getZIndex(); $('#meteo-control-sweatherList').css({zIndex: zIndex}); ONEMAP.D.currentSideBarMod = 'atlas'; //开启侧栏 ONEMAP.C.publisher.publish('handShow', 'layout::sideBar'); getDate(); $('.meteo-sw-box').show(); } else { $('.meteo-sw-box').hide(); } }); map2DViewer.map.on('click', function () { $('.meteo-sw-box').hide(); //点击地图关闭弹窗 }) $('#meteo-sw-close').click(function () { $('.meteo-sw-box').hide(); //点击X关闭弹窗 }); //------------下一张以及上一张------------- $('#meteo-sw-next').click(function (e) { next(); }) $('#meteo-sw-last').click(function (e) { last(); }) } //获取列表数据 function getDate() { meteo.c.http.httpFunction(meteo.c.http.space, null, '', function (json) { var list = json['image']; var data = json['data']; var listHtml = ''; for (var i = 0; i < list.length; i++) { var elem = "'" + list[i]['elem'] + "'"; var odate = "'" + list[i]['odate'] + "'"; var sinElem = list[i]['elem']; sinElem = sinElem.indexOf('proton') != -1 ? '质子数据' : sinElem.indexOf('dscovr_mag') != -1 ? '卫星磁场' : sinElem.indexOf('dscovr_plasma') != -1 ? '卫星等离子体' : sinElem.indexOf('electro') != -1 ? '电子数据' : sinElem.indexOf('kp') != -1 ? '地磁指数数据' : sinElem.indexOf('sdo') != -1 ? 'SDO太阳极紫外图' : sinElem.indexOf('xray') != -1 ? 'X射线流量' : elem ; //listHtml += '
' + sinElem + '
'; listHtml += '
  • ' + '"' + sinElem; listHtml += '
  • '; } $('#meteo-sw-general').html('        ' + data.data); // $('#meteo-sw-list').html(listHtml); $('#meteo-list-spaWeather').html(listHtml); getElemData(list[0]['odate'], list[0]['elem']); //获取第一条详细数据 $("#meteo-swe-item0").parent().addClass('current'); $('.meteo-sw-item').click(function (e) { var data = e.currentTarget.attributes; getElemData(data.odate.value, data.elem.value); //添加列表点击事件 $(this).parent().addClass('current'); $(this).parent().siblings().removeClass('current'); }) }, function () { }) } var elemData; //获取详细数据 /根据事件及elem function getElemData(odate, elem) { var param = { dateStr: odate, elem: elem }; meteo.c.http.httpFunction(meteo.c.http.spaceInfo, null, param, function (json) { elemData = []; for (var i = 0; i < json.length; i++) { if(!json[i].image) continue; for (var j = 0; j < json[i].image.length; j++) { if (elemData.length >= 10) break; //数据可能有很多,目前最多取10条 var tElem = json[i].image[j]; if (json[i].desc && json[i].desc.data) { tElem.desc = json[i].desc.data; } else { tElem.desc = '暂无描述'; } elemData[elemData.length] = tElem; } } showIndex = 0; showElemData(); }, function () { }) } var showIndex = 0; function showElemData() { //更换当前显示的数据 $('#meteo-sw-img').attr("src", elemData[showIndex].data); // $('#meteo-sw-img').attr("src", 'http://107.1.170.200:10000/space/space_20190304_000012_1024_0094.jpg'); $('#meteo-sw-top').html(elemData[showIndex].odate + " " + elemData[showIndex].elem); $('#meteo-sw-gen').html(elemData[showIndex].desc); } function next() { if (showIndex == elemData.length - 1) return; showIndex++; showElemData(); } function last() { if (showIndex == 0) return; showIndex--; showElemData(); } init(); meteo.f.spWeather = { init: init, }; return meteo.f.spWeather; });