fuchengshen
2022-07-09 3a25c05b5ab837714f30469cdcb1e2a77d8d7f6c
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
<template>
  <mars-pannel :visible="true" right="10" top="10">
    <div class="f-mb">
      <a-space>
        <span>日期选择:</span>
        <mars-date-picker v-model:value="currDate" valueFormat="YYYY-MM-DD" />
      </a-space>
    </div>
 
    <div class="f-mb">
      <a-space>
        <span>时间选择:</span>
        <mars-slider @change="timeChange" v-model:value="timeVal" :min="0" :max="1440" :step="1" />
      </a-space>
    </div>
 
    <div class="f-mb">
      <a-space>
        <span>当前时间:</span>
        <span>{{ currDate }} {{ hours }} 时 {{ minutes }}分</span>
      </a-space>
    </div>
 
    <div class="f-mb">
      <a-space>
        <span>自动播放:</span>
        <mars-button @click="startPlay">播放</mars-button>
        <mars-button @click="stopPlay">暂停</mars-button>
      </a-space>
    </div>
  </mars-pannel>
</template>
 
<script setup lang="ts">
import { computed, onMounted, ref } from "vue"
import dayjs from "dayjs"
import * as mapWork from "./map.js"
 
const currDate = ref<string>(dayjs().format("YYYY-MM-DD"))
const timeVal = ref<number>(420)
 
const hours = computed(() => Math.floor(timeVal.value / 60))
const minutes = computed(() => Math.floor(timeVal.value % 60))
 
mapWork.eventTarget.on("changeShadows", (event: any) => {
  const date = event.shadowTime
  timeVal.value = date.getHours() * 60 + date.getMinutes()
})
 
onMounted(() => {
  timeChange()
})
 
const timeChange = () => {
  mapWork.setShadows(currDate.value, hours.value, minutes.value)
}
 
const startPlay = () => {
  mapWork.startPlay(currDate.value, hours.value, minutes.value)
}
const stopPlay = () => {
  mapWork.stopPlay()
}
</script>
<style scoped lang="less">
.mars-pannel-item-label {
  width: 55px;
}
.ant-slider {
  width: 128px;
}
</style>