123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- //空间天气
- 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 += '<div class="meteo-sw-item" odate=' + odate + ' elem=' + elem + ' >' + sinElem + '</div>';
- listHtml += '<li class="meteo-twoLi meteo-lastLi">' +
- '<a href="javascript:;" id="meteo-swe-item' + i + '" class="meteo-twoBtn meteo-lastBtn meteo-sw-item"' +
- ' odate= '+ odate + ' elem= ' + elem + ' >"' + sinElem;
- listHtml += '</a></li>';
- }
- $('#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;
- });
|