surprise
2023-12-29 18377dc5d61caf3a6a0835e17015ac2601f8709d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
var yyfx_currentTime = '';
var yyfx_currentSpeed = '1x';
var timer = null;
var sgworld = parent.sgworld;
 
 
$('#speed').on('input propertychange', function (event) {
    yyfx_currentSpeed = $(this).html();
});
 
$('#timeShadow').on('input propertychange', function (event) {
    yyfx_handleSetCurrentTime($(this).html());
});
$(document).click(function (e) {
    if($('.dateBox').css('display') == 'none') return;
    var e = e || window.event;
    if(e.target.id == 'timeShadow') return;
    window.parent.fnLayerHauto(window.parent.SmartEarthPopupData.layerProp,'290')
})
 
// 时间设置
function yyfx_handleSetCurrentTime(params) {
    timer = sgworld.Command.execute(3, 0, params);
    clearInterval(timer);
    timer = null;
    yyfx_handleGetCurrentTime();
}
 
// 时间获取
function yyfx_handleGetCurrentTime() {
    sgworld._Viewer.shadows = true;
    yyfx_currentSpeed = $(parent.document).find('.cesium-viewer-animationContainer .cesium-animation-svgText tspan').eq(2).html();
    $('#speed').val(yyfx_currentSpeed);
    clearInterval(timer);
    timer = null;
    timer = setInterval(() => {
        yyfx_currentTime = utcToBeijing(sgworld._Viewer.animation.viewModel.dateLabel, sgworld._Viewer.animation.viewModel.timeLabel);
        $('#timeShadow').val(yyfx_currentTime);
    }, 1000);
}
 
// 加速
function yyfx_handleSpeedIncress() {
    sgworld.Command.execute(3, 1);
    yyfx_currentSpeed = $(parent.document).find('.cesium-viewer-animationContainer .cesium-animation-svgText tspan').eq(2).html();
    $('#speed').val(yyfx_currentSpeed);
    if ((yyfx_currentSpeed[0] != '-') && (parent.currentPlayMode != '0')) {
        parent.currentPlayMode = '1';
    }
}
 
// 减速
function yyfx_handleSpeedDecress() {
    sgworld.Command.execute(3, 2);
    yyfx_currentSpeed = $(parent.document).find('.cesium-viewer-animationContainer .cesium-animation-svgText tspan').eq(2).html();
    $('#speed').val(yyfx_currentSpeed);
    if ((yyfx_currentSpeed[0] == '-') && (parent.currentPlayMode != '0')) {
        parent.currentPlayMode = '2';
    }
}
 
// 往前播放
function yyfx_handleForword() {
    sgworld.Command.execute(3, 3);
    parent.currentPlayMode = '1';
    if (yyfx_currentSpeed[0] == '-') {
        yyfx_currentSpeed = yyfx_currentSpeed.slice(1);
        $('#speed').val(yyfx_currentSpeed);
    }
}
 
// 往后播放
function yyfx_handleBacword() {
    sgworld.Command.execute(3, 4);
    parent.currentPlayMode = '2';
    if (yyfx_currentSpeed[0] != '-') {
        yyfx_currentSpeed = '-' + yyfx_currentSpeed;
        $('#speed').val(yyfx_currentSpeed);
    }
}
 
// 暂停
function yyfx_handlePause() {
    if(parent.currentPlayMode !== '0'){
        sgworld.Command.execute(3, 5);
        parent.currentPlayMode = '0';
    }
}
 
// utc时间转为北京时间
function utcToBeijing(date, time) {
    // 转为正常的时间格式 年-月-日 时:分:秒
    date = date.replace(/January|Jan/, '01').replace(/February|Feb/, '02')
        .replace(/March|Mar/, '03').replace(/April|Apr/, '04')
        .replace(/May/, '05').replace(/June|Jun/, '06')
        .replace(/July|Jul/, '07').replace(/August|Aug/, '08')
        .replace(/September|Sept/, '09').replace(/October|Oct/, '10')
        .replace(/November|Nov/, '11').replace(/December|Dec/, '12');
 
    const dateArr = date.split(' ');
    date = `${dateArr[2]}-${dateArr[0]}-${dateArr[1]}`;
 
    const timeArr = time.split(' ');
    time = timeArr[0];
    let timestamp = new Date(Date.parse(`${date} ${time}`));
    timestamp = timestamp.getTime();
    timestamp = timestamp / 1000;
 
    // 增加8个小时,北京时间比utc时间多八个时区
    timestamp = timestamp + 8 * 60 * 60;
 
    // 时间戳转为时间
    var beijing_datetime = new Date(parseInt(timestamp) * 1000).toLocaleString('chinese', {hour12: false}).replace(/年|月|\//g, "-").replace(/日/g, " ");
    return beijing_datetime; // 2017-03-31 16:02:06
}