燕山石化溯源三维电子沙盘-【前端】-Web
1
WX
2023-09-08 5a4c6108b5c30d22d41d614c6212711607920c92
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<template>
  <div id="weather">
    <div>
      <el-row>
        <el-col :span="8" class="el-col1">
          <div class="sun" title="晴天" @click="weather('sun')"></div>
        </el-col>
        <el-col :span="8">
          <div class="rain" title="雨天" @click="weather('rain')"></div>
        </el-col>
        <el-col :span="8" class="el-col3">
          <div class="snow" title="雪天" @click="weather('snow')"></div>
        </el-col>
      </el-row>
      <div class="bar">
        <div
          class="barpoint"
          :class="{
            sunPoint: data.currentType == 'sun',
            rainPoint: data.currentType == 'rain',
            snowPoint: data.currentType == 'snow',
          }"
        ></div>
      </div>
    </div>
 
    <!-- <div class="time-box">
      <div class="title">选择时间</div>
      <div style="width: 80%">
        <time-box :state="data.timestatus" @changeTime="changeTime"></time-box>
      </div>
    </div> -->
  </div>
</template>
 
<script>
import { reactive, onMounted, watch } from "vue";
import timeBox from "@/components/time.vue";
import { queryWeatherList } from "@/api/api.js";
import axios from "axios";
export default {
  components: { timeBox },
  props: ["weatherData"],
  created() {},
  mounted() {
    //     var tem = window.sessionStorage.getItem("weatherType");
    // if(tem){
    //   this.currentType=tem;
    // };
  },
  setup(props, { emit }) {
    let data = reactive({
      currentType: undefined,
      timestatus: "",
    });
    // 设置天气
    function weather(type) {
      window.sgworld.Analysis.createWeather(type, true);
      // sgworld.Core.postMessage({"weather":type})
      data.currentType = type;
      // if (type == data.currentType) {
      //   window.sgworld.Analysis.createWeather("snow", true);
      //   data.currentType = undefined;
      // } else {
      //   window.sgworld.Analysis.createWeather(type, true);
      //   data.currentType = type;
      // }
      // window.sessionStorage.setItem("weatherType", data.currentType);
    }
 
    //天气获取接口
    // async function queryWeather(time) {
    //   let arr = time.split(/\s+/);
    //   let Hour = arr[1].split(":");
    //   let headers = { "Cache-Control": "no-cache" };
    //   const dt = await axios.get(
    //     `${jsonUrl}/json/yssh_weather.json`,
    //     {},
    //     headers
    //   );
 
    //   dt.data.forEach((e) => {
    //     if (e.time == `${arr[0]}-${Hour[0]}:00:00`) {
    //       emit("changeWeather", e);
    //       switch (e.weatherCondition) {
    //         case "Sunny":
    //           weather("sun");
    //           break;
    //         case "snowy":
    //           weather("snow");
    //           break;
    //         case "wet":
    //           weather("rain");
    //           break;
    //       }
    //     }
    //   });
    // }
    function changeTime(val) {
      // queryWeather(val.data);
      emit("timeData", val);
    }
    watch(
      () => props.weatherData,
      (nVal, oVal) => {
        data.currentType = nVal;
        weather(nVal);
      },
      { deep: true }
    );
    onMounted(() => {
      data.timestatus = "t";
    });
    return { data, weather, changeTime };
  },
};
</script>
<style lang="less" scoped>
//@import url(); 引入公共css类
 
#weather {
  width: 650px;
  position: absolute;
  z-index: 10;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.box {
  // width: 500px;
  // margin: 0 auto;
}
.el-button {
  font-size: 30px;
}
.bar {
  // width: 98%;
  height: 20px;
  line-height: 20px;
  margin-left: 15px;
  margin-top: 20px;
  border-radius: 10px;
  position: relative;
  background: linear-gradient(
    to right,
    rgba(0, 132, 255, 0.25),
    rgba(0, 132, 255, 1)
  ) !important;
}
 
.barpoint {
  position: absolute;
  width: 36px;
  height: 36px;
  top: -8px;
  left: 0;
  border-radius: 18px;
  /* border: 1px solid white; */
  background: white;
}
.sunPoint {
  left: 0;
}
.rainPoint {
  left: 45%;
}
.snowPoint {
  left: unset;
  right: 0;
}
.sun,
.rain,
.snow {
  width: 63px;
  height: 66px;
  background: url("../assets/img/sun.png") no-repeat center;
  background-size: 100% 100%;
  cursor: pointer;
}
.rain {
  background: url("../assets/img/rain.png") no-repeat center;
  background-size: 100% 100%;
}
.snow {
  background: url("../assets/img/snow.png") no-repeat center;
  background-size: 100% 100%;
  cursor: pointer;
}
.time-box {
  width: 100%;
  margin-top: 40px;
  // width: 500px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  .title {
    color: white;
    font-size: 20px;
    // margin-bottom: 20px;
  }
}
.el-col {
  display: flex;
  align-items: center;
  justify-content: center;
}
.el-col1 {
  justify-content: flex-start;
}
.el-col3 {
  justify-content: flex-end;
}
</style>