Commit 836b7e0e by liangjianmin

feat(weather): 添加天气图标并更新天气数据获取方式

- 在页面中添加天气图标元素
- 更新天气数据接口为 wttr.in
- 显示当前温度和天气图标
parent 0087062a
Showing with 6 additions and 3 deletions
......@@ -31,6 +31,7 @@
<span>北京时间&nbsp;&nbsp;</span>
<span class="color" id="time">00:00:00</span>
<span class="ml">深圳&nbsp;&nbsp;</span>
<img id="weatherIcon" src="" alt="" style="width:20px;height:20px;vertical-align:middle;margin-right:4px;display:none;" />
<span class="color" id="wendu"></span>
</p>
<span class="title"></span>
......
......@@ -259,13 +259,15 @@
$("#day").text((day < 10) ? ('0' + day) : day);
$("#week").text(week[weekDay]);
$.ajax({
url: "http://wthrcdn.etouch.cn/weather_mini?city=深圳",
url: "https://wttr.in/深圳?format=j1",
dataType: 'json',
type: "get",
success: function (res) {
$("#wendu").text(res.data.wendu + "℃");
var condition = res.current_condition[0];
$("#wendu").text(condition.temp_C + "℃");
var iconUrl = condition.weatherIconUrl[0].value;
$("#weatherIcon").attr("src", iconUrl).css("display", "inline-block");
}
})
setInterval(function () {
var myDate = new Date;
......
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 sign in to comment