Commit c55c8d8f authored by 张浩然's avatar 张浩然

'SwitchWeatherDataSource'

parent 1fed3570
......@@ -12,11 +12,17 @@
<div class="tian_qi">
<div class="tian_qi_title">实时气象数据</div>
<div class="tian_qi_body">
<span style="font-size: 2vw"> <img src="@/assets/images/tian_qi2.png" alt="" /> {{ tian_qi_data.tem }}°C</span>
<!-- <span style="font-size: 2vw"> <img src="@/assets/images/tian_qi2.png" alt="" /> {{ tian_qi_data.tem }}°C</span>
<span>{{ tian_qi_data.tem1 }}°C / {{ tian_qi_data.tem2 }}°C</span>
<span>空气{{ tian_qi_data.air_level }}</span>
<span>{{ tian_qi_data.wea }}</span>
<span>{{ tian_qi_data.win + tian_qi_data.win_speed }}</span>
<span>{{ tian_qi_data.win + tian_qi_data.win_speed }}</span> -->
<div style="font-size: 2vw">
<img src="@/assets/images/tian_qi2.png" alt="" />
</div>
<span>{{ tian_qi_data.air_level }}</span>
<span>{{ tian_qi_data.temp }}</span>
<span>{{ tian_qi_data.wea }}</span>
</div>
</div>
</div>
......@@ -46,9 +52,25 @@ export default {
}).then(res => {
this.tian_qi_data = res.data
}) */
var that = this;
weather({}).then(function(res){
console.log('weather ________________ ', res);
if(res.replace(/\s+/g, '')){
var str = res.replace(/(\r\n)|(\n)/g, '&').split(/&&|&/g);
var todayStr = str[1];
if(todayStr){
var items = todayStr.split(/。/g);
var tempStr = items[1];
var temp = tempStr && tempStr.match("") ? tempStr.split(/:/g)[1] : tempStr;
var item3Str = items[2];
var item3 = item3Str && item3Str.match("") ? item3Str.split(/:/g)[1] : item3Str;
var data = {
temp: temp,
air_level: items[0],
wea:item3
};
that.tian_qi_data = data;
};
};
})
this.dept()
......
......@@ -318,6 +318,7 @@ export default {
bottom: 0;
right: 0;
width: 12%;
min-width:188px;
background-color: #030c2a;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment