js实现天气预报模板

合集下载

jsp天气预报查询课程设计

jsp天气预报查询课程设计

jsp天气预报查询课程设计一、课程目标知识目标:1. 学生能够理解JSP技术的基本原理和网页开发流程。

2. 学生能够掌握如何在JSP页面中嵌入Java代码,实现动态数据展示。

3. 学生能够学习并运用数据库连接和SQL查询,实现天气预报信息的调用与展示。

4. 学生了解Web服务器的基本配置和使用方法。

技能目标:1. 学生能够运用HTML、CSS和JavaScript等技术,设计并实现具有良好交互性的Web界面。

2. 学生能够通过JSP和Java语言编写程序,实现天气预报的查询和显示功能。

3. 学生能够使用数据库存储和管理数据,实现天气预报信息的更新与维护。

4. 学生能够运用所学知识解决实际项目中遇到的问题,提高项目实践能力。

情感态度价值观目标:1. 学生培养对编程和网络技术的兴趣,提高主动学习和探究的精神。

2. 学生培养团队协作意识,学会在项目开发中与他人沟通与协作。

3. 学生提高问题解决能力,增强自信心,培养勇于克服困难的品质。

4. 学生认识到编程技术在现实生活中的应用价值,激发对科技创新的热情。

课程性质:本课程为信息技术课程,以项目实践为主要教学方式,结合理论讲解,让学生在实际操作中掌握JSP技术。

学生特点:学生具备一定的Java基础,了解Web开发基本概念,但对JSP技术及其在实际项目中的应用尚不熟悉。

教学要求:结合学生特点,注重实践操作,鼓励学生动手实践,培养其编程思维和项目实践能力。

在教学过程中,关注学生个体差异,提供个性化指导,确保每个学生都能在课程中取得进步。

二、教学内容1. JSP技术原理及基本概念:介绍JSP技术的工作原理,理解JSP的生命周期,掌握JSP的内置对象及其作用。

- 相关教材章节:第3章 JSP技术基础2. Web服务器配置与使用:学习如何配置Web服务器,如Tomcat,并了解其基本操作。

- 相关教材章节:第2章 Web服务器与应用服务器3. HTML、CSS和JavaScript基础:复习Web开发基本技术,为后续页面设计打下基础。

基于Swift语言及JSON的天气预报APP的设计与实现

基于Swift语言及JSON的天气预报APP的设计与实现

基于Swift语言及JSON的天气预报APP的设计与实现任健(上海信息技术学校,上海200331)摘要:随着大数据时代的来临,各类智能终端在人们的日常生活中发挥着日益重要的作用.本文研究的基于Swift 语言及JSON的天气预报APP是上海信息技术学校信息技术系软件与信息服务专业《程序设计特长(1)》课程的项目教学实例,通过一体化的教学引导学生完成界面设计、天气预报API的使用、JSON数据包的解析等,最终将天气信息呈现给用户。

关键词:Swift;JSON;天气预报;项目教学实例中图分类号:TP311.56文献标识码:A文章编号:1003-9767(2021)05-170-04Design and implementation of weather forecast APP based on Swift languageand JSONREN Jian(Shanghai Information Technology College,Shanghai200331,China)Abstract:With the advent of the Internet+big data era,various smart terminals are playing an increasingly important role in people's daily lives.The weather forecast app based on Swift language and JSON studied in this paper is a project teaching example of the program design specialty(1)course for the Software and Information Service Department of the Information Technology Department of Shanghai Information Technology School.It guides students through integrated plete interface design,use of weather forecast API,analysis of JSON data package,etc.,and finally present weather information to users.Keywords:Swift;JSON;weather forecast;project teaching examples0引言上海信息技术学校的软件与信息服务专业的学制为四年,三年级的学生已经完成了一系列专业课程的学习,具备较好的编码能力。

VB 天气预报源代码

VB 天气预报源代码
Private Sub fengli_Click()
On Error Resume Next
If ph >= 20 Then
ph = ph - 10
Else
ph = 100
End If
SetPh
End Sub
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const WS_EX_LAYERED As Long = &H80000
Private Const LWA_ALPHA As Long = &H2
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1
riqi.Caption = "今天是:" & Date & GetWeekDay
Me.Height = 5600
IsGetIp = False

微信小程序天气预报开发实例代码源码

微信小程序天气预报开发实例代码源码

微信⼩程序天⽓预报开发实例代码源码微信⼩程序天⽓预报实例主要功能1. ⾃动定位所在城市2. 根据所定位的城市获取天⽓信息3. 显⽰未来⼏天的天⽓情况4. 查看当天天⽓的详情信息先看效果图微信⼩程序-天⽓⾸页微信⼩程序-天⽓详情页思路及编码部份⾃动定位所在城市wx.getLocation:通过官⽅⽂档的API中可以看到wx.getLocation可以获取到当前的地理位置和速度,不过获取到的地理位置只是经纬度,⽽不是真正的城市名称,但我们可以根据这个经纬度来获取城市名称等信息(需要⽤到第三⽅接⼝),再通过城市名称和城市ID获取对应的天⽓信息。

在.js逻辑层增加函数:data:{weatherApikey:'', //天⽓apikey,在 上申请city:'', //城市名称areaid:'', //城市对应的idcurWd:{}, //当天天⽓情况indexs:{}, //当天天⽓详情说明forecast:{} //未来4天的天⽓情况},onLoad:function(options){// ⽣命周期函数--监听页⾯加载this.setData({weatherApikey:getApp().globalData.weatherApikey});this.loadLocation();},//获取当前的位置信息,即经纬度loadLocation: function() {var page = this;wx.getLocation({type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可⽤于 wx.openLocation 的坐标success: function(res){// successvar latitude = titude;var longitude = res.longitude;//获取城市page.loadCity(latitude, longitude);}})},//通过经纬度获取城市loadCity: function(latitude, longitude) {var page = this;//这个key是⾃⼰在上申请的var key = "XSWBZ-EVQ3V-UMLPA-U4TP6-6MQFZ-UUFSL";var url = "/ws/geocoder/v1/?location="+latitude+","+longitude+"&key="+key+"&get_poi=1";wx.request({url: url,data: {},method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT// header: {}, // 设置请求的 headersuccess: function(res){// successvar city = res.data.result.address_component.city;city = city.replace("市", ""); //将“市”去掉,要不然取不了天⽓信息page.setData({city: city});page.loadId(city);}})},//通过城市名称获取城市的唯⼀IDloadId: function(city) {var page = this;var url = "/apistore/weatherservice/citylist";wx.request({url: url,data: {cityname: city},header: {apikey:page.data.weatherApikey},method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECTsuccess: function(res){// successvar cityid = res.data.retData[0].area_id;page.setData({areaid: cityid});page.loadWeather(city, cityid);}})},//通过城市名称和城市ID获取天⽓情况loadWeather: function(city, areaId) {var page = this;var url = "/apistore/weatherservice/recentweathers";wx.request({url: url,data: {cityname:city,cityid: areaId},header: {apikey: page.data.weatherApikey},method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECTsuccess: function(res){// successpage.setData({curWd : res.data.retData.today, indexs: res.data.retData.today.index, forecast:res.data.retData.forecast});}})},//事件绑定,跳转到天⽓详情页⾯gotoDetail: function(event) {// console.log(this.data.areaid+"==在这⾥跳转=="+this.data.city);wx.navigateTo({url: '../detail/detail?city='+this.data.city+"&cityid="+this.data.areaid})}注意:page.setData或this.setData都是⽤来设置data中的数据值的。

原生JS实现天气预报

原生JS实现天气预报

原⽣JS实现天⽓预报本⽂实例为⼤家分享了JS实现天⽓预报的具体代码,供⼤家参考,具体内容如下HTML代码<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title><link rel="stylesheet" href="tianqi.css" ><link rel="stylesheet" href="iconfont/iconfont.css" ></head><body><!-- 搜索 --><div class="search"><span>Tq</span><form target="sou" id="search_from"><input type="search" placeholder="输⼊搜索的城市"><iframe name="sou" style = "display: none"></iframe></form><div class="search-btn"><img src="images/search.png" alt=""></div></div><!-- 历史记录--><div class="history"><div class="la"><span>历史查询</span><img src="images/more.png" alt=""></div><div class="historys"><!-- 历史记录 --></div><div class="clearbtn">清除历史记录</div></div><!-- 今⽇天⽓ --><div class="information"></div><!-- 天⽓预报 --><div class="forecast"></div><!-- ⽣活指数 --><div class="lifestyle"><h2>⽣活指数</h2><div class="lifestyle-box"><div class="lifestyle-item" data-indexs="0"><i class="iconfont icon-shushidu"></i><span>舒适度指数</span></div><div class="lifestyle-item" data-indexs="1"><i class="iconfont icon-3chuanyixiguan"></i><span>穿⾐指数</span></div><div class="lifestyle-item" data-indexs="2"><i class="iconfont icon-ganmaoyaowu"></i><span>感冒指数</span></div><div class="lifestyle-item" data-indexs="3"><i class="iconfont icon-yundong"></i><span>运动指数</span></div><div class="lifestyle-item" data-indexs="4"><i class="iconfont icon-lvyou"></i><span>旅游指数</span></div><div class="lifestyle-item" data-indexs="5"><i class="iconfont icon-iconset0451"></i><span>紫外线指数</span></div><div class="lifestyle-item" data-indexs="6"><i class="iconfont icon-xiche"></i><span>洗车指数</span></div><div class="lifestyle-item" data-indexs="7"><i class="iconfont icon-kongqiwuranfenxi"></i><span>空⽓污染扩散条件指数</span></div></div></div><!-- ⽣活指数弹窗 --><div class="lifestyle-tc"></div><script src="rem.js"></script><script src="Ajax.js"></script><script src="tianqi.js"></script></body></html>CSS代码* {margin: 0;padding: 0;}ul,li {list-style: none;}body {background-size: 120%;color: white;}.search {position: fixed;width: 100%;height: 0.5rem;background-color: rgba(0,0,0,.0);display: flex;justify-content: space-between;align-items: center;}#search_from {width: 2.8rem;height: 0.4rem;position: relative;}.search > span {width: 0.5rem;font-size: 0.25rem;line-height: 0.5rem;text-align: center;font-family: "Segoe UI Symbol";color: white;}.search #search_from > input {width: 2.8rem;height: 0.4rem;border-radius: 0.1rem;text-indent: 0.1rem;outline: none;position: absolute;border: none;border-bottom: 0.01rem solid white;background-color: rgba(255,255,255,.05);color: white;}.search #search_from > input::-webkit-input-placeholder { color: white;}.search > .search-btn {width: 0.5rem;position: relative;}.search > .search-btn > img {width: 0.25rem;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);}.history {height: 0.9rem;overflow: auto;background-color: rgba(255,255,255,.05); transition-duration: 0.5s;}.historys {margin-top: 0.8rem;overflow: hidden;}.history .history-item {display: flex;height: 0.4rem;border-bottom: 0.01rem dashed #cccccc; align-items: center;justify-content: space-evenly;}.history .history-item > .history-time {font-size: 0.14rem;}.history .history-item > .history-city {font-size: 0.18rem;}.history .la {height: 0.3rem;display: flex;position: fixed;top: 0.45rem;width: 90%;background-color: rgba(255,255,255,.0); justify-content: space-between;font-size: 0.16rem;border-bottom: 0.01rem solid white;margin: 0.1rem 0.2rem;font-family: 幼圆;line-height: 0.3rem;}.history .la > span {color: white;}.history .la > img {width: 0.2rem;height: 0.2rem;padding: 0.03rem;border: 0.01rem solid #cccccc;border-radius: 0.05rem;}.clearbtn {height: 0.3rem;text-align: center;text-decoration: underline;font-size: 0.2rem;margin-top: 0.1rem;line-height: 0.3rem;}.information {/*background-color: gold;*/}.now {padding-top: 0.2rem;display: flex;flex-direction: column;}.now .city {font-size: 0.4rem;text-align: center;}.now .situation {padding-top: 0.2rem;display: flex;justify-content: space-evenly;font-size: 0.15rem;align-items: center;}.now .situation > img {width: 1rem;height: 1rem;vertical-align: bottom;}.now .temp {display: flex;flex-direction: column;align-items: center;}.now .temp > h3 {font-size: 0.2rem;margin-top: 0.1rem;}.forecast {background-color: rgba(0,0,0,.3);margin: 0 0.2rem;border-radius: 0.1rem;}.forecast-item {height: 0.3rem;display: flex;justify-content: space-between;margin: 0.1rem 0.2rem 0;padding-top: 0.1rem;}.forecast-item:last-of-type {padding-bottom: 0.1rem;}.forecast-item .forecast-situation > img {width: 0.2rem;height: 0.2rem;}.forecast-item .forecast-situation {font-size: 0.16rem;}.forecast-temp {font-size: 0.18rem;}.lifestyle {display: none;margin: 0 0.2rem;background-color: rgba(0,0,0,.3);border-radius: 0.1rem;}.lifestyle > h2 {text-align: center;margin-top: 0.2rem;font-size: 0.2rem;padding-top: 0.15rem;font-family: 幼圆;}.lifestyle .lifestyle-box {display: flex;flex-wrap: wrap;justify-content: space-between;}.lifestyle .lifestyle-box .lifestyle-item {display: flex;flex-direction: column;width: 0.7rem;height: 0.4rem;font-size: 0.14rem;text-align: center;padding-top: 0.1rem;padding-bottom: 0.05rem;}.lifestyle .lifestyle-box .lifestyle-item > i {font-size: 0.2rem;}.lifestyle .lifestyle-box .lifestyle-item > span {white-space: nowrap;text-overflow:ellipsis;overflow:hidden;}.lifestyle-tc {height: 100vh;position: fixed;top: 0;left: 0;background-color: gold;font-family: 幼圆;line-height: 0.4rem;}.lifestyle-tc .fanghui {width: 0.3rem;height: 0.3rem;position: absolute;left: 0.2rem;top: 0.1rem;}.lifestyle-tc .fanghui > img {width: 100%;}.lifestyle-tc > h2 {font-size: 0.3rem;width: 2.2rem;margin: 0.3rem auto 0;text-align: center;}.lifestyle-tc > span {width: 100%;font-size: 0.2rem;margin-top: 1.5rem;display: block;font-weight: 700;text-indent: 0.16rem;}.lifestyle-tc > p {text-indent: 0.32rem;font-size: 0.2rem;}JS代码let searchtext = document.querySelector('.search #search_from > input');let searchbtn = document.querySelector('.search-btn');let information = document.querySelector('.information'); //当前天⽓divlet forecast = document.querySelector(".forecast"); //获取天⽓预报 divlet lifestyle = document.querySelector('.lifestyle');if (localStorage.tq == undefined) { /*如果默认没搜索过就⾃动搜索普宁*/var tqList = [];let defauleCity = "普宁";autorend(defauleCity);} else { /*如果有搜索记录,就⾃动搜索最后⼀次机城市*/var tqList = JSON.parse(localStorage.tq);let endcityName = tqList[tqList.length - 1].cityName;autorend(endcityName);}/* ⾃动渲染⽅法*/function autorend (cityName) {let nowurl = "https:///s6/weather/now?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b";let dailyurl = "https:///s6/weather/forecast?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b"; let lifestyleurl = "https:///s6/weather/lifestyle?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b"; console.log("执⾏⾃动渲染")rendweather(nowurl,cityName,dailyurl,lifestyleurl);}function getTime() {let date = new Date();let year = date.getFullYear();let month = date.getMonth() + 1;let day = date.getDate();let house = date.getHours();house = house < 10 ? '0' + house : house;let minutes = date.getMinutes();minutes = minutes < 10 ? '0' + minutes : minutes;let second = date.getMinutes();second = second < 10 ? '0' + second : second;let time = year + "年 - " + month + "⽉ - " + day + "⽇ - " + house + ":" + minutes + ":" + second;return time;}/*搜索按钮事件*/searchbtn.addEventListener('click',function () {let time = getTime();let cityName = searchtext.value;/*如果输⼊框不为空才执⾏不加这条件会导致传⼊⼀个空的字符串导致历史记录添加到⼀个空的*/if (cityName != "") {let List = {"cityName" : cityName,"time" : time}tqList.push(List);localStorage.tq = JSON.stringify(tqList);rendhistory(tqList);let nowurl = "https:///s6/weather/now?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b";let dailyurl = "https:///s6/weather/forecast?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b"; let lifestyleurl = "https:///s6/weather/lifestyle?location="+cityName+"&key=26be256aca2c43a7bb7f9a72e0f99a6b"; rendweather(nowurl,cityName,dailyurl,lifestyleurl); /*调⽤渲染⽅法*/searchtext.value = "";}});/*⼿机键盘搜索键事件*/document.getElementById('search_from').onsubmit = function () {searchbtn.click();document.activeElement.blur();}/*主页⾯渲染*/function rendweather (nowurl,cityName,dailyurl,lifestyleurl) {/*获取今⽇天⽓信息*/getAjax(nowurl,function (xhr) {let databoj = JSON.parse(xhr.response);let now = databoj.HeWeather6[0].now;if (now == undefined) { /* 如果获取到的为now 说明⽤户输⼊的城市有误*/if (tqList.length > 1) {//如果长度⼤于1 说明之前⽤户正确输⼊过城市tqList.splice(tqList.length - 1 , 1 ); //执⾏删除最后⼀个元素即输⼊错误的城市rendhistory(tqList); // 执⾏历史记录渲染cityName = tqList[tqList.length - 1].cityName; //将城市名赋值为数组最后⼀个元素即最后⼀次正确搜索的城市} else if (tqList.length == 1) { /* 如果长度为1 说明现在为⽌⽤户没输⼊⼀个正确的城市*/cityName = "普宁"; //将城市名赋值为普宁// tqList.splice(tqList.length - 1 , 1 );tqList.pop(); //删除输⼊错误的⽂字rendhistory(tqList); //执⾏历史记录渲染}autorend(cityName); //最后执⾏⾃动渲染} else { //如果以上都没错误说明⽤户输⼊的城市正确正常执⾏代码/* 渲染今⽇天⽓*/information.innerHTML = `<div class="now"><span class="city">${cityName}</span><div class="situation"><img src="https:///cond_icon/${now.cond_code}.png" alt=""> <!-- 天⽓图标 --><h1 class="text">${now.cond_txt}</h1> <!-- 天⽓状况 --><div class="temp"><h3 class="tmp">温度:${now.tmp}℃</h3> <!-- 温度 --><h3 class="fl">体感温度:${now.fl}℃</h3> <!-- 体感温度 --></div></div>`;/*渲染背景图⽚*/let nowcondtxt = now.cond_code;switch(nowcondtxt) {case "101":case "102":case "103":case "104":document.body.style.backgroundImage = "url('images/2.jpg')";break;case "100":case "200":case "201":case "202":case "203":case "204":document.body.style.backgroundImage = "url('images/1.jpg')"; break;case "205":case "206":case "207":case "208":case "209":document.body.style.backgroundImage = "url('images/7.jpg')"; break;case "210":case "211":case "212":case "213":document.body.style.backgroundImage = "url('images/8.jpg')"; break;case "300":case "301":case "302":case "303":case "304":case "305":case "306":case "307":case "308":case "309":case "310":case "311":case "312":case "313":case "314":case "315":case "316":case "317":case "318":case "399":document.body.style.backgroundImage = "url('images/3.jpg')"; break;case "400":case "401":case "402":case "403":case "404":case "405":case "406":case "407":case "408":document.body.style.backgroundImage = "url('images/4.jpg')"; break;case "500":case "501":case "502":case "503":case "504":case "505":case "506":case "507":case "508":document.body.style.backgroundImage = "url('images/5.jpg')"; break;case "509":case "510":case "511":case "512":case "513":case "514":case "515":document.body.style.backgroundImage = "url('images/6.jpg')"; break;default:document.body.style.backgroundImage = "url('images/9.jpg')";}/*获取天⽓预告信息*/getAjax(dailyurl,function (xhr) {forecast.innerHTML = ""; /*清除之前的渲染*/let databoj = JSON.parse(xhr.response);let daily = databoj.HeWeather6[0].daily_forecast;daily.forEach(function (item,index) {/*如果当天天⽓早上和晚上⼀样就输出⼀个如果不⼀样就早上转晚上(天⽓类型)*/var txt = item.cond_txt_d == item.cond_txt_n ? item.cond_txt_d : item.cond_txt_d + "转" + item.cond_txt_n; let date = '今天'; /*默认今天*/if (index == 1) { /* 第⼆个赋值为明天*/date = "明天";} else if (index == 2) { /* 第三个赋值为后天*/date = "后天";}/*渲染天⽓预报*/forecast.innerHTML += `<div class="nowday forecast-item"><div class="forecast-situation"><img src="https:///cond_icon/${item.cond_code_d}.png" alt="">${date} * <span class="txt">${txt}</span></div><div class="forecast-temp"><span class="max">${item.tmp_max}°/</span><span class="min">${item.tmp_min}°</span></div></div>`;})});lifestyle.style.display = 'block'; /*显⽰⽣活指数模板*//*获取⽣活指数*/getAjax(lifestyleurl,function (xhr) {let databoj = JSON.parse(xhr.response);let lifestyle = databoj.HeWeather6[0].lifestyle;lifestyleclick(lifestyle); /*调⽤⽣活指数渲染⽅法*/});}});}/*⽣活指数渲染⽅法*/let lifestyleitem = document.querySelectorAll('.lifestyle-item');function lifestyleclick (lifestyle) {for (let j = 0; j < lifestyleitem.length; j ++) {lifestyleitem[j].onclick = function () {let index = lifestyleitem[j].dataset.indexs;let li = lifestyle[index];let lifestyletc = document.querySelector('.lifestyle-tc');lifestyletc.innerHTML = `<div class="fanghui"><img src="images/fanghui.png" alt=""></div><h2>${lifestyleitem[j].children[1].childNodes[0].data}</h2><span>${li.brf}</span><p>"${li.txt}"</p>`;lifestyletc.style.display = 'block';/*关闭按钮*/let fanghuibtn = document.querySelector('.fanghui');console.log(fanghuibtn);fanghuibtn.onclick = function () {lifestyletc.style.display = 'none';}}}}//历史记录事件let historys = document.querySelector('.historys');function rendhistory(tqList) {historys.innerHTML = ""; /*每次执⾏历史记录渲染都清除之前的记录防⽌出现重复*/tqList.forEach(function (item,index) {/*将历史记录写⼊*/historys.innerHTML += `<div class="history-item" data-indexs="${index}"><span class="history-time">${item.time}</span><span class="history-city">${item.cityName}</span></div>`;})/*获取历史记录div 添加点击事件* 点击后跳转点击的城市* */let historyitem = document.querySelectorAll('.history-item');for (let j = 0; j < historyitem.length; j ++) {historyitem[j].onclick = function() {let index = historyitem[j].dataset.indexs;let thecityName = tqList[index].cityName;let time = getTime();let List = {"cityName" : thecityName,"time" : time}tqList.push(List);localStorage.tq = JSON.stringify(tqList);rendhistory(tqList);autorend(thecityName);}}}rendhistory(tqList);xiala();//下拉菜单事件function xiala () {let historybtn = document.querySelector('.la > img');let historyDiv = document.querySelector('.history');let clearhistory = document.querySelector('.clearbtn');let flag = true;historybtn.addEventListener('click',function () {if (flag) {flag = false;historybtn.style.backgroundColor = "rgba(0,0,0,.3)";let height = (tqList.length * 0.4) + 1.7;historyDiv.style.height = height + 'rem';} else {flag = true;historybtn.style.backgroundColor = "rgba(0,0,0,.0)";historyDiv.style.height = '0.9rem';}});clearhistory.addEventListener('click',function () { /*清除历史记录事件*/localStorage.removeItem('tq'); /*删除本地存储*/tqList = []; /*将数组清空*/rendhistory(tqList); /*渲染历史记录*/historybtn.click(); /*执⾏下拉按钮点击*/});searchtext.addEventListener('click',function () { //点击输⼊框如果下拉菜单打开就关闭if (!flag) {historybtn.click();}});}以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

留言板与天气预报模块网站开发实训

留言板与天气预报模块网站开发实训

《网站开发》实训报告题目一天气预报模块题目二留言板模块教学院计算机学院专业班级(一)姓名指导教师2014 年12 月 5 日目录目录------------------------------------------------------------------------------------------------------------------------ 1一概述 ---------------------------------------------------------------------------------------------------------------------- 2一. 天气预报模块 -------------------------------------------------------------------------------------------------- 21.天气预报模块的介绍 ------------------------------------------------------------------------------------- 22.天气预报模块的要求 ------------------------------------------------------------------------------------- 2二.留言板模块 ----------------------------------------------------------------------------------------------------- 31. 留言板模块的介绍 --------------------------------------------------------------------------------------- 32.留言板模块的要求----------------------------------------------------------------------------------------- 3二总体设计 ---------------------------------------------------------------------------------------------------------------- 4一.天气预报模块---------------------------------------------------------------------------------------------------- 41.天气预报模块设计思路 ---------------------------------------------------------------------------------- 42.天气预报模块流程图 ------------------------------------------------------------------------------------- 43.实现方法以及主要技术特点 ---------------------------------------------------------------------------- 64.天气预报模块功能介绍以及我的任务---------------------------------------------------------------- 7二.留言板模块------------------------------------------------------------------------------------------------------- 71.整体思路 ----------------------------------------------------------------------------------------------------- 72.留言板模块流程图----------------------------------------------------------------------------------------- 83.实现方法及主要技术 ------------------------------------------------------------------------------------- 94.主要功能 ----------------------------------------------------------------------------------------------------- 95.我所承担设计部分--------------------------------------------------------------------------------------- 10三详细设计 -------------------------------------------------------------------------------------------------------------- 10一. 天气预报模块 ------------------------------------------------------------------------------------------------ 101.具体功能 --------------------------------------------------------------------------------------------------- 102.重要的实验代码------------------------------------------------------------------------------------------ 103.控件表如下 ------------------------------------------------------------------------------------------------ 154.实验运行截图如下--------------------------------------------------------------------------------------- 15二.留言板模块----------------------------------------------------------------------------------------------------- 15四网站的调试与运行结果说明 ------------------------------------------------------------------------------------- 18一.天气预报模块运行结果说明 ----------------------------------------------------------------------------- 18二.留言板模块结果说明 ---------------------------------------------------------------------------------------- 181.留言板数据库的设计 ----------------------------------------------------------------------------------- 182.网页实现效果--------------------------------------------------------------------------------------------- 19五实训小结 -------------------------------------------------------------------------------------------------------------- 23参考文献------------------------------------------------------------------------------------------------------------------- 24一概述一. 天气预报模块1.天气预报模块的介绍在当今时代天气预报对人类有着及其重要的作用,天气预报的服务手段也变得越来越广泛,而其有效的服务手段有:报刊登载,电台广播,电视播送,天气电话咨询等。

基于Android及JSON的天气预报APP设计与实现

基于Android及JSON的天气预报APP设计与实现

第30卷第1期苏州市职业大学学报V ol.30,No.1 2019年3月Journal of Suzhou V ocational University Mar.,2019DOI:10.16219/ki.szxbzk.2019.01.006基于Android及JSON的天气预报APP设计与实现史桂红(苏州健雄职业技术学院 软件与服务外包学院,江苏 太仓 215400)摘 要:为了方便人们用智能手机查看天气预报信息,在Android平台下设计并实现了天气预报客户端的开发,主要包括天气预报JSON文档的获取与解析、天气预报信息在Android 平台上的呈现等技术,用户通过客户端查询全国城市天气信息和未来天气基本信息。

APP主要功能模块包括城市定位、天气查询及天气显示。

经过测试,结果表明该APP使用方便,完全能满足人们日常对天气信息的需求。

关键词:A ndroid;JSON;JsonFormat;天气预报;Gson中图分类号:TP391 文献标志码:A文章编号:1008-5475(2019)01-0027-06Design and Implementation of Weather Forecast APPBased on Android and JSONSHI Guihong(School of Software and Services Outsourcing,Suzhou Chien-Shiung Institute of Technology,Taicang 215400,China)Abstract:In order to facilitate people’s checking of weather forecast information on smart phones, a weather forecast APP is designed via the Android platform, used for the acquisition and analysis of weather forecast JSON documents and the presentation of weather forecast information on the Android platform and so on. Via the client terminal, its users can request basic weather information nationwide for the time being or to be. Its major functions include urban location module, weather query and display module. The tests results show that the software is easy to use and able to meet people’s needs for weather information.Keywords:Android;JSON;Json Format;weather forecast;Gson天气信息和人们的日常生活息息相关,及时精确地获取天气信息对于人们出行和生活尤为重要,天气预报已经成为人们日常生活不可缺少的一部分。

Java实现天气预报

Java实现天气预报

Java实现天⽓预报通过Java实现天⽓预报,该⽅法必须联⽹import org.apache.http.client.config.RequestConfig;import org.apache.http.client.methods.CloseableHttpResponse;import org.apache.http.client.methods.HttpGet;import org.apache.http.impl.client.CloseableHttpClient;import org.apache.http.impl.client.HttpClientBuilder;import org.apache.http.util.EntityUtils;import java.io.IOException;public class GetWeather {public static String getResult(String url) {try (CloseableHttpClient httpClient = HttpClientBuilder.create().build();CloseableHttpResponse response = httpClient.execute(new HttpGetConfig(url))) {String result = EntityUtils.toString(response.getEntity(),"utf-8"); //设置编码,防⽌乱码return result;} catch (IOException e) {e.printStackTrace();return "";}}}class HttpGetConfig extends HttpGet {public HttpGetConfig(String url) {super(url);setDefaultConfig();}private void setDefaultConfig() {this.setConfig(RequestConfig.custom().setConnectionRequestTimeout(1000 * 10).setConnectTimeout(1000 * 10).setSocketTimeout(1000 * 10).build());this.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0"); }}import org.jsoup.Jsoup;import org.jsoup.nodes.Document;import org.jsoup.nodes.Element;import org.jsoup.select.Elements;import java.util.ArrayList;import java.util.LinkedHashMap;import java.util.List;import java.util.Map;public class GetWeatherMain {// public static void main(String[] args) {// GetWeatherMain htmlUtilTest= new GetWeatherMain();// htmlUtilTest.searchWeather("101110200");// }/**** @param* @return获取未来7天的天⽓预报*/public List<Map<String,String>> searchWeather(String id){String result= GetWeather.getResult("/weather/"+id+".shtml");Document document= Jsoup.parse(result);Elements elements;// 获取⽇期和星期elements=document.select("h1");List<String> dateList=new ArrayList<>();List<String> dayList=new ArrayList<>();for (int i = 0; i < 7; i++) {String text=elements.get(i).text();int length=text.length();dateList.add(text.substring(0,length-4));dayList.add(text.substring(length-3,length-1));}//System.out.println(dateList);//System.out.println(dayList);// 获取天⽓elements=document.select("p[class=wea]");List<String> weatherList=new ArrayList<>();for (Element item : elements) {weatherList.add(item.text());}//System.out.println(weatherList);// 获取温度,最⾼温和最低温elements=document.select("p[class=tem]");int i=0;List<String> highTempList=new ArrayList<>();List<String> lowTempList=new ArrayList<>();for (Element item : elements) {highTempList.add(item.select("span").text()+"℃");lowTempList.add(item.select("i").text());}//System.out.println(highTempList);//System.out.println(lowTempList);// 封装结果,每天⼀⾏,未来7天List<Map<String,String>> list=new ArrayList<>();for (int j = 0; j < 7; j++) {Map<String,String> map=new LinkedHashMap<>();map.put("⽇期",dateList.get(j));map.put("day",dayList.get(j));map.put("天⽓",weatherList.get(j));map.put("最⾼温度",highTempList.get(j));map.put("最底温度",lowTempList.get(j));list.add(map);}//list.forEach(System.out::println);return list;}}测试类public static void main(String[] args){String msg = "";GetWeatherMain getWeatherMain = new GetWeatherMain();List<Map<String,String>> list = getWeatherMain.searchWeather("101240101"); //这⾥需要传⼊城市ID,可以通过该链接进⾏查看msg = "【南昌地区天⽓预报】\n"+ list.get(0).toString() +"\n"+ "-----------------------------" + "\n" + list.get(1).toString(); //这⾥只获取两天的天⽓预报 msg = msg.replace('=',':').replace('{',' ').replace('}',' ').replace(',','\n');System.out.println(msg);}。

使用JS调用腾讯接口获取天气

使用JS调用腾讯接口获取天气

使⽤JS调⽤腾讯接⼝获取天⽓想做个直接通过JS获取某个城市的天⽓。

本来想通过直接调⽤中国⽓象⽹的接⼝:1function Weather() {};23 Weather.prototype = {45 getWeather: function (city, callback) {6var that = this,7 cities = Weather.cityParse(),8 code = cities[city] ? cities[city] : 125, // 默认使⽤北京城市9 url = '/weather/inc/minisite2_' + code + '.js'; // 腾讯天⽓API jsonp接⼝1011this.createJsonp(url, function (para) {12var desc = that.weatherParse(para); // 通过jsonp获取天⽓相关信息13 callback(desc);14 });15 },16 // jsonp17 createJsonp: function (url, callback) {18var script = document.createElement('script');19 script.type = 'text/javascript';20 script.src = url;2122 script.onreadystatechange = function () {23if (script.readyState === 'loaded' || script.readyState === 'complete') {24 callback(__minisite2__weather__);2526 script.onreadystatechange = null;27 script.onload = null;28 }29 };3031 script.onload = function () {32 callback(__minisite2__weather__);33 script.onreadystatechange = null;34 script.onload = null;35 };3637 document.body.appendChild(script);38 },3940 weatherParse: function (para) {4142try {43var params = para.split(' ');44var weather = {45 city: params[0],46 temperature: params[1],47 range: params[2],48 describe: params[3]49 };5051return weather;52 } catch (e) {5354 }55 }56 };57 // 将城市及其对应代码解析成hash形式58 Weather.cityParse = function () {59var cities = {},60 prop,62 item;6364for (prop in this.city) {65 item = Weather.city[prop]; 66for (var city in item) {67if (city !== '_') {68 code = item[city];69 city = city.slice(0, -1);70 cities[city] = code;71 }72 }73 }7475return cities;76 };7778 Weather.city = {79 "北京市": {80 "_": 125,81 "北京市": 12582 },83 "上海市": {84 "_": 252,85 "上海市": 25286 },87 "天津市": {88 "_": 127,89 "天津市": 127,90 "塘沽区": 13291 },92 "重庆市" : {93 "_": 212,94 "奉节区": 201,95 "重庆市": 212,96 "涪陵区": 21397 },98 "⾹港": {99 "_": 1,100 "⾹港": 1101 },102 "澳门": {103 "_": 2,104 "澳门": 2105 },106 "台湾省": {107 "_": 280,108 "台北市": 280109 },110 "云南省": {111 "_": 179,112 "昭通市": 173,113 "丽江市": 174,114 "曲靖市": 175,115 "保⼭市": 176,116 "⼤理州": 177,117 "楚雄州": 178,118 "昆明市": 179,119 "瑞丽市": 180,120 "⽟溪市": 181,121 "临沧市": 182,122 "思茅市": 184,123 "红河州": 185,124 "⽂⼭州": 369,125 "西双版纳州": 370, 126 "德宏州": 371,127 "怒江州": 372,128 "迪庆州": 373130 "内蒙古": {131 "_": 69,132 "呼伦贝尔市": 4,133 "兴安盟": 7,134 "锡林郭勒盟": 16,135 "巴彦淖尔市": 63,136 "包头市": 64,137 "呼和浩特市": 69,138 "锡林浩特市": 99,139 "通辽市": 101,140 "⾚峰市": 106,141 "乌海市": 382,142 "鄂尔多斯市": 383,143 "乌兰察布市": 384144 }145 };146 // 主要是些事件处理相关的⽅法包装147var Util = {148 addEvent: function (element, type, handler) {149if (element.addEventListener) {150 element.addEventListener(type, handler, false);151 } else if (element.attachEvent) {152 element.attachEvent('on' + type, handler);153 }154 },155156 getEvent: function (event) {157return event || window.event;158 },159160 getTarget: function (event) {161return event.target || event.srcElement;162 },163164 getComputedStyle: function (element) {165if (element.currentStyle) {166return element.currentStyle;167 } else {168return document.defaultView.getComputedStyle(element, null);169 }170 },171172 getBoundingClientRect: function (element) {173var scrollTop = document.documentElement.scrollTop;174var scrollLeft = document.documentElement.scrollLeft;175176if (element.getBoundingClientRect) {177if (typeof arguments.callee.offset != 'number') {178var temp = document.createElement('div');179 temp.style.cssText = 'position: absolute; left: 0; top: 0;';180 document.body.appendChild(temp);181 arguments.callee.offset = -temp.getBoundingClientRect().top - scrollTop; 182 document.body.removeChild(temp);183 temp = null;184 }185186var rect = element.getBoundingClientRect();187var offset = arguments.callee.offset;188189return {190 left: rect.left + offset,191 rigth: rect.right + offset,192 top: rect.top + offset,193 bottom: rect.bottom + offset194 };195 } else {196var offset = this.getElementOffset(element);197198return {199 left: offset.left - scrollLeft,200 right: offset.left + element.offsetWidth - scrollLeft,201 top: offset.top - scrollTop,202 bottom: offset.top + element.offsetWidth - scrollTop203 };204 }205 },206207 getElementOffset: function (element) {208var actualLeft = element.offsetLeft;209var actualTop = element.offsetTop;210var current = element.offsetParent;211212while (current !== null) {213 actualLeft += current.offsetLeft;214 actualTop += current.actualTop;215 current = current.offsetParent;216 }217218return {219 left: actualLeft,220 top: actualTop221 };222 }223 };HTML页⾯的代码如下:1<!DOCTYPE html>2<html>3 <head>4 <title>weather</title>5 <meta http-equiv="Content-Type" content="text/html; charset=gbk;" />6 <style type="text/css" >7 #city {8 width: 150px;9 heigth: 30px;10}11 #inputCity {12 position: absolute;13 width: 130px;14 heigth: 25px;15}16 </style>17 </head>18 <body>19 <h1>Weather</h1>20 <fieldset>21 <legend> 获取时间 </legend>22 <label for="city">请选择城市:</label>23 <select name="city" id="city">24 <!--<option selected="selected"></option>-->25 <option>北京</option>26 <option>⼤连</option>27 <option>福州</option>28 </select>29 <input type="text" id="inputCity" value = '请输⼊或选择城市' />30 <input type="button" id="getWeather" value="获取天⽓" />31 </fieldset>32 <div id="showWeather">3334 </div>35 <script type="text/javascript" src="weather.js"></script>36 <script>37 (function(){112113 var city = document.getElementById('city');114 var getWeather = document.getElementById('getWeather');115 var inputCity = document.getElementById('inputCity');116 var tip = inputCity.value;117 var cities = Weather.cityParse();118119120 var pos = Util.getBoundingClientRect(city);121 var volumn = Util.getComputedStyle(city);122 console.log(pos);123124 // 设置输⼊⽂本框的位置125 inputCity.style.left = pos.left + 'px';126 inputCity.style.top = pos.top + 'px';127128 Util.addEvent(city, 'change', function (event) {129 var value = city.options[city.selectedIndex].value;130 inputCity.value = value;131});132133 Util.addEvent(inputCity, 'focus', function (event) {134 Util.getTarget(event).select();135});136137 Util.addEvent(inputCity, 'change', function () {138139 var city = inputCity.value;140 if ( city.slice(-1) === '市') {141 city = city.slice(0, -1);142}143 if ( city && !cities[city] ) {144 alert('⽬前⽆法获取' + city + '的天⽓,请输⼊其它城市');145} else if ( !city ) {146 inputCity.value = tip;147}148149 });150151 Util.addEvent(getWeather, 'click', function (event) {152 var city = inputCity.value;153 if ( city && !cities[city] ) {154 alert('⽬前⽆法获取' + city + '的天⽓,请输⼊其它城市');155 return false;156}157 // 天⽓获取158 (new Weather()).getWeather(city, function(param){159160 var showWeather = document.getElementById('showWeather'); 161 showWeather.innerHTML = '城市:' + param.city +162 '<br /> 温度:' + param.temperature +163 '<br /> 温度范围:' + param.range +164 '<br /> 描述:' + param.describe;165});166 });168169 })();170 </script>171 </body>172</html>。

微信小程序实现天气预报功能(附源码)

微信小程序实现天气预报功能(附源码)

微信⼩程序实现天⽓预报功能(附源码)⽬录前⾔效果图天⽓API获取微信⼩程序后台域名配置页⾯代码注意问题(必看)前⾔最近在学⼩程序开发,刚好学到天⽓预报功能的制作,于是给⼤家分享下。

效果图天⽓API获取这⾥我⽤的是,打开官⽹注册或者登陆你的账号进⼊控制台,新建应⽤这是刚刚我们创建好的应⽤,点击添加KEY选择WebAPI这注册好我们的API了微信⼩程序后台域名配置登陆⼩程序后台,分别点击开发和开发设置页⾯代码.wxml<view class="header"><view class="top"><view class="city">{{city}}</view><view class="search"><input placeholder="输⼊城市名" bindinput="bindKeyInput" placeholder-style="color:white"></input><view class="bt_search" bindtap="search"><icon type="search" size="18" color="white"></icon></view></view></view><view class="center"><view class="tmp">{{tmp}}°</view><image mode="widthFix" class="cond-image" src="https://moyv.top/wechat/images/weather/{{imgsrc}}.png"> </image></view><view class="bottom"><view>{{wind_dir}} {{wind_sc}}级</view><view>湿度 {{hum}}%</view><view>⽓压 {{pres}}Pa</view></view></view><view class="container"><view class="hourly_title">24⼩时预报</view><scroll-view scroll-x="true" class="hourly"><view class="h_item" wx:for="{{hourly}}" wx:key="index"><text class="h_time">{{item.time}}</text><view class="h_img"><image mode="widthFix" src="https://moyv.top/wechat/images/weather/{{item.imgsrc}}.png"></image> </view><text class="h_tmp">{{item.tmp}}°</text><text class="h_wind_dir">{{item.wind_dir}}</text><text class="h_wind_sc">{{item.wind_sc}}级</text></view></scroll-view><view class="hourly_title">7天预报</view><scroll-view scroll-x="true" class="daily"><view class="d_item" wx:for="{{daily_forecast}}" wx:key="index"><text class="d_txt">{{item.d_txt}}</text><text class="d_date">{{item.d_date}}</text><view class="h_img"><image mode="widthFix" src="https://moyv.top/wechat/images/weather/{{item.imgsrc_d}}.png"></image> </view><text class="h_tmp">{{item.tmp_min}}°~{{item.tmp_max}}°</text><view class="h_img"><image mode="widthFix" src="https://moyv.top/wechat/images/weather/{{item.imgsrc_n}}.png"></image> </view><text class="d_wind_dir">{{item.wind_dir}}</text><text class="d_wind_sc">{{item.wind_sc}}级</text></view></scroll-view></view><view class="footer">-天⽓数据来⾃和风天⽓api-</view>.wxsspage {background-color: #f6f6f6;}.header {background-color:#64c8fa;/* background-image: linear-gradient(to right, #64a0f8, #64c8fa); */height: 450rpx;padding-top: 32rpx;text-align: center;}.top {display: flex;justify-content: space-between;align-content: center;align-items: center;}.city {text-align: center;color: white;display: inline-block;font-size: 52rpx;margin-left: 32rpx;}.search {margin-right: 32rpx;border-radius: 8rpx;display: inline-flex;justify-content: center;align-content: center;align-items: center;background-color: rgba(0, 0, 0, 0.1);height: 70rpx;}.search input {width: 200rpx;padding: 18rpx 32rpx;text-align: left;color: white;display: inline-block;}.bt_search {border-radius: 0 8rpx 8rpx 0;height: 100%;background-color: rgba(0, 0, 0, 0.1);display: inline-flex;justify-content: center;align-content: center;align-items: center;}.bt_search icon {margin: 8rpx 18rpx;}.center {display: flex;justify-content: space-between;align-content: center;align-items: center;}.tmp {margin-left: 18rpx;display: inline-block;font-size: 180rpx;color: white;}.cond-image{width: 200rpx;margin-right: 32rpx;margin-top: 32rpx;}.bottom{display: flex;justify-content: space-between;align-content: center;align-items: center;}.bottom view{color: white;margin: 32rpx;}.hourly_title{font-weight: bold;font-size: 42rpx;padding: 18rpx 32rpx;}.hourly {width: 718rpx;margin: 0 18rpx;border-radius: 18rpx;box-shadow: 0.1rem 0.1rem 0.5rem rgba(0, 0, 0, 0.15);white-space: nowrap;background-color: white;}.h_item {margin: 18rpx 0;display: inline-block;width: 143.5rpx;text-align: center;font-size: 28rpx;}.h_img {margin: 64rpx 0;}.h_img image {width: 60rpx;}.h_item text {display: block;}.h_time {color: gray;}.h_wind_dir {margin-top: 32rpx;}.h_wind_sc {color: gray;}.h_tmp {color: #027aff;}.daily {width: 718rpx;white-space: nowrap;margin: 0 18rpx;background-color: white;border-radius: 18rpx;box-shadow: 0.1rem 0.1rem 0.5rem rgba(0, 0, 0, 0.15);}.d_item {margin: 18rpx 0;display: inline-block;width: 179.5rpx;text-align: center;font-size: 28rpx;}.d_item text {display: block;}.d_date {color: gray;}.d_wind_dir {margin-top: 32rpx;}.d_wind_sc {color: gray;}.footer{font-size: 28rpx;color: gray;text-align: center;margin-top: 50rpx;margin-bottom: 18rpx;}.jsPage({/*** 页⾯的初始数据*/data: {search_city: '',imgsrc:100},/*** 根据城市获取天⽓预报*/getWeather(city) {let that = this//获取实况天⽓wx.request({url: 'https:///s6/weather/now?key=你后台的key&location=' + city, success: function(res) {if (res.data.HeWeather6[0].status == 'unknown location') {wx.showToast({title: '抱歉!没有该城市的天⽓预报',icon: 'none',duration: 2000})return;}console.log(res)that.setData({city: city,tmp: res.data.HeWeather6[0].now.tmp,imgsrc: res.data.HeWeather6[0].now.cond_code,wind_dir: res.data.HeWeather6[0].now.wind_dir,wind_sc: res.data.HeWeather6[0].now.wind_sc,hum: res.data.HeWeather6[0].now.hum,pres: res.data.HeWeather6[0].now.pres})//获取24⼩时天⽓预报wx.request({url: 'https:///s6/weather/hourly?key=你后台的key&location=' + city,success: function(res) {var arr = res.data.HeWeather6[0].hourlyvar hourly = []for (var i = 0; i < arr.length; i++) {hourly[i] = {"imgsrc": arr[i].cond_code,"tmp": arr[i].tmp,"time": arr[i].time.substring(11),"wind_dir": arr[i].wind_dir,"wind_sc": arr[i].wind_sc}}that.setData({hourly: hourly})var weekArray = new Array("周⽇", "周⼀", "周⼆", "周三", "周四", "周五", "周六");//获取未来7天天⽓预报wx.request({url: 'https:///s6/weather/forecast?key=你后台的key&location=' + city,success: function(result) {//console.log(result)var arr = result.data.HeWeather6[0].daily_forecastvar daily_forecast = []for (var i = 0; i < arr.length; i++) {daily_forecast[i] = {d_txt: i == 0 ? "今天" : weekArray[new Date(arr[i].date).getDay()],d_date: arr[i].date.substring(5),imgsrc_d: arr[i].cond_code_d,imgsrc_n: arr[i].cond_code_n,wind_dir: arr[i].wind_dir,wind_sc: arr[i].wind_sc,tmp_max: arr[i].tmp_max,tmp_min: arr[i].tmp_min,cond_txt_d: arr[i].cond_txt_d}}that.setData({daily_forecast: daily_forecast})}})}})}})},bindKeyInput(e) {this.setData({search_city: e.detail.value})},search() {this.getWeather(this.data.search_city)},/*** ⽣命周期函数--监听页⾯加载*/onLoad: function(options) {this.getWeather("⼴州")},}).json{"usingComponents": {},"navigationBarTitleText": "天⽓预报"}注意问题(必看)由于我的项⽬有⽤到天⽓预报的逐⼩时预报和7天预报,和风天⽓⼜必须实名才能获取到此数据,所以请登录和风天⽓后台进⾏实名认证到此这篇关于微信⼩程序实现天⽓预报功能(附源码)的⽂章就介绍到这了,更多相关⼩程序实现天⽓预报内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!。

“移动应用开发”实验报告---天气预报

“移动应用开发”实验报告---天气预报

“移动应用开发”实验报告1数据代码即运行结果截图一、整体架构、本次实验我分配的任务是查看某地区天气的活动代码编写和添加权限与注册的相关代码,具体的过程在下面:1、活动(Activity)整体结构2、设计界面(layout)整体结构二、数据代码本次作业(天气预报)的设计界面效果图如下:2接着需要编写遍历省市县的活动,即MainActivity。

代码如下:package com.example.chen.weatherforecast;import android.app.ProgressDialog;import android.content.Intent;import android.content.SharedPreferences;import android.preference.PreferenceManager;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.text.TextUtils;import android.view.View;import android.view.Window;import android.widget.AdapterView;import android.widget.ArrayAdapter;import android.widget.ListView;import android.widget.TextView;import android.widget.Toast;3import java.util.ArrayList;import java.util.List;import DB.CoolWeatherDB;import model.City;import model.County;import model.Province;import unity.HttpCallbackLinster;import unity.HttpUtil;import util.Utility;public class MainActivity extends AppCompatActivity {public static final int LEVEL_PROVINCE = 0; //省级public static final int LEVEL_CITY = 1; //市级public static final int LEVEL_COUNTY = 2; //县级private ProgressDialog progressDialog;private ListView listView; //显示省市县的数据private TextView title_text; //标题内容private ArrayAdapter<String> adapter; //listView 的适配器private List<String> datalist = new ArrayList<String>();private List<Province> provinceList; //省列表private List<City> cityList; //市列表private List<County> countyList; //县列表private CoolWeatherDB coolWeatherDB;private Province selectProvince; //选中的省private City selectCity; //选中的市private int currentLevel; //选中的县private Boolean isFromWeatherActivity;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(yout.activity_main);isFromWeatherActivity =getIntent().getBooleanExtra("from_weather_activity",false);SharedPreferences pref =PreferenceManager.getDefaultSharedPreferences(MainActivity.this);if(pref.getBoolean("city_cheeked",false)&& !isFromWeatherActivity ) { Intent intent = new Intent(this,LookWeather.class);startActivity(intent);finish();4} listView = (ListView)findViewById(R.id.list_view);title_text = (TextView)findViewById(R.id.title_text);adapter = newArrayAdapter<String>(MainActivity.this,yout.simple_list_item_1, datalist);listView.setAdapter(adapter);coolWeatherDB = CoolWeatherDB.getInstance(this);listView.setOnItemClickListener(newAdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {if(currentLevel == LEVEL_PROVINCE) {selectProvince = provinceList.get(position);querCity(); //选中省,则查找该省的市} else if(currentLevel == LEVEL_CITY) {selectCity = cityList.get(position);querCounty(); //选中市,则查找该市的县} else if(currentLevel == LEVEL_COUNTY) //选中县,则查找该县所对应的天气{String countyCode = countyList.get(position).getCountycode();Intent intent = new Intent(MainActivity.this,LookWeather.class); intent.putExtra("county_code",countyCode);startActivity(intent);finish();} } });querProvince();} //查找省,如果在数据库中没有找到,则在服务器上找private void querProvince() {provinceList = coolWeatherDB.loadProvince();if(provinceList.size() > 0) {datalist.clear();for(Province province : provinceList) {datalist.add(province.getProvinceName());}adapter.notifyDataSetChanged();listView.setSelection(0);title_text.setText("中国");currentLevel = LEVEL_PROVINCE;} else{ //在服务器上查找5querfromServer(null, "province");} } //查找市,如果在数据库中没有找到,则在服务器上找private void querCity() {cityList = coolWeatherDB.loadCity(selectProvince.getId());if(cityList.size() > 0) {datalist.clear();for(City city : cityList) {datalist.add(city.getCityName());}adapter.notifyDataSetChanged();listView.setSelection(0);title_text.setText(selectProvince.getProvinceName());currentLevel = LEVEL_CITY;} else{ querfromServer(selectProvince.getProvinceCode(),"city");} } //查找县,如果在数据库中没有找到,则在服务器上找private void querCounty() {countyList = coolWeatherDB.loadCounty(selectCity.getId());if(countyList.size() > 0) {datalist.clear();for(County county : countyList) {datalist.add(county.getCountyName());} adapter.notifyDataSetChanged();listView.setSelection(0);title_text.setText(selectCity.getCityName());currentLevel = LEVEL_COUNTY;} else{ querfromServer(selectCity.getCityCode(),"county");} } //根据传入的代号和类型在服务器上查找数据private void querfromServer(final String code,final String type){ String address;if(!TextUtils.isEmpty(code)) { address ="/data/list3/city" + code +".xml";} else{ address = "/data/list3/city.xml";} showProgressDialog();HttpUtil.sendRequstWithURLConnection(address, newHttpCallbackLinster() {@Overridepublic void onFinish(String response) { boolean result = false;if ("province".equals(type)) { result =Utility.handleProvince(coolWeatherDB, response);6} else if ("city".equals(type)) { result =Utility.handleCity(coolWeatherDB, response, selectProvince.getId());} else if ("county".equals(type)) { result =Utility.handleCounty(coolWeatherDB, response, selectCity.getId());} if (result) { runOnUiThread(new Runnable() { @Overridepublic void run() { closeProgressDialog();if ("province".equals(type)) { querProvince();} else if ("city".equals(type)) { querCity();} else if ("county".equals(type)) { querCounty();} } });} } public void onError(Exception e) { runOnUiThread(new Runnable() { @Overridepublic void run() { closeProgressDialog();Toast.makeText(MainActivity.this,"加载失败",Toast.LENGTH_SHORT).show();} });} });} private void showProgressDialog() { if(progressDialog == null){ progressDialog = new ProgressDialog(MainActivity.this);progressDialog.setMessage("正在加载...");progressDialog.setCanceledOnTouchOutside(false);} progressDialog.show();} private void closeProgressDialog() {if(progressDialog != null) {progressDialog.dismiss();} } //捕获返回键,来判断此时应直接返回省,市列表还是返回到显示天气的页面public void onBackPressed() {if(currentLevel == LEVEL_COUNTY) {querCity();}else if(currentLevel == LEVEL_CITY) {querProvince();}else { if (isFromWeatherActivity) {Intent intent = new Intent(MainActivity.this, LookWeather.class); startActivity(intent);} finish();} } }还要加上权限声明和注册Activity,即AndroidManifest.xml的代码:7<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="/apk/res/android"package="com.example.chen.weatherforecast"><uses-permission android:name="android.permission.INTERNET"/><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/AppTheme"><activity android:name=".MainActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="UNCHER" /> </intent-filter></activity><activity android:name=".LookWeather"> </activity></application></manifest>2、获取省、市、县的天气数据在Utility类中添加解析JSON数据与处理。

Dreamweaver中时间、天气预报、滚动新闻条的制作

Dreamweaver中时间、天气预报、滚动新闻条的制作

Dreamweaver中时间、天气预报、滚动新闻条的制作时间的制作<SCRIPT language=javaScript src="Include/time.js" type=text/javascript></SCRIPT> // JavaScript Document<!--var lunarInfo=new Array(/* 1900 */0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x 055d2,0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x 14977,0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x 04970,0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x 0b557,0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x 06aa0,0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x 056a0,0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x 195a6,0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x 09570,0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x 092e0,0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x 0a930,0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x 0dd45,0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x 0ada0,/* 2049 *///下面的是从 2050 到 2100 年的0x14b63, /* 2050 */0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, /* 2055 */0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, 0x0a2e0, /* 2060 */0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, /* 2065 */0x05d55, 0x056a0, 0x0a6d0, 0x055d4, 0x052d0, /* 2070 */0x0a9b8, 0x0a950, 0x0a4a0, 0x0b6a6, 0x0ad50, /* 2075 */0x055a0, 0x0aba0, 0x0a5b0, 0x052b0, 0x0b273, /* 2080 */0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, /* 2085 */0x04b60, 0x0a570, 0x054e4, 0x0d260, 0x0e968, /* 2090 */0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, /* 2095 */0x0a9d4, 0x0a4d0, 0x0d150, 0x0f252, 0x0d520 /* 2100 */);var Animals=new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"); var Gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");var Zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");var now = new Date();var SY = now.getYear();var SM = now.getMonth();var SD = now.getDate();//==== 传入 offset 传回干支, 0=甲子function cyclical(num){return(Gan[num%10]+Zhi[num%12]);}//==== 传回农历 y年的总天数function lYearDays(y){var i, sum = 348;for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i) ? 1 : 0;return(sum+leapDays(y));}//==== 传回农历 y年闰月的天数function leapDays(y){if(leapMonth(y)) return((lunarInfo[y-1900] & 0x10000) ? 30 : 29);else return(0);}//==== 传回农历 y年闰哪个月 1-12 , 没闰传回 0function leapMonth(y){return(lunarInfo[y-1900] & 0xf);}//====================================== 传回农历 y年m月的总天数function monthDays(y, m){return (lunarInfo[y-1900] & (0x10000>>m))? 30 : 29;}//==== 算出农历, 传入日期物件, 传回农历日期物件//==== 该物件属性有 .year .month .day .isLeap .yearCyl .dayCyl .monCylfunction Lunar(objDate){var i, leap=0, temp=0;var baseDate = new Date(1900,0,31);var offset = (objDate - baseDate)/86400000;this.dayCyl = offset + 40;this.monCyl = 14;for (i = 1900; i<2050 && offset>0; i++){temp = lYearDays(i);offset -= temp;this.monCyl += 12;}if (offset < 0){offset += temp;i--;this.monCyl -= 12;}this.year = i;this.yearCyl = i-1864;leap = leapMonth(i); //闰哪个月this.isLeap = false;for (i = 1; i < 13 && offset > 0; i++){//闰月if (leap > 0 && i == (leap+1) && this.isLeap == false)--i;this.isLeap = true;temp = leapDays(this.year);}else{temp = monthDays(this.year, i);}//解除闰月if (this.isLeap == true && i == (leap+1)) {this.isLeap = false;}offset -= temp;if (this.isLeap == false){this.monCyl++;}}if (offset == 0 && leap > 0 && i == leap + 1) {if (this.isLeap){this.isLeap = false;}elsethis.isLeap = true;--i;--this.monCyl;}}if (offset < 0){offset += temp;--i;--this.monCyl;}this.month = i;this.day = offset + 1;}function YYMMDD(){var cl = '<font color="#000000">';if (now.getDay() == 0) cl = '<font color="#000000">';if (now.getDay() == 6) cl = '<font color="#000000">';return(cl+SY+'年'+(SM+1)+'月'+'</font>');}function weekday(){var day = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");var cl = '<font color="#000000">';if (now.getDay() == 0) cl = '<font color="#000000">';if (now.getDay() == 6) cl = '<font color="#000000">';return(cl+ day[now.getDay()]+ '</font>');}//==== 中文日期function cDay(m, d){var nStr1 = new Array('日','一','二','三','四','五','六','七','八','九','十'); var nStr2 = new Array('初','十','廿','卅','');var s;if (m > 10){s = '十' + nStr1[m-10];}else{s = nStr1[m];}s += '月';switch (d){case 10:s += '初十'; break;case 20:s += '二十'; break;case 30:s += '三十'; break;default:s += nStr2[Math.floor(d/10)]; s += nStr1[d%10];}return(s);}function solarDay1(){var sDObj = new Date(SY, SM, SD);var lDObj = new Lunar(sDObj);var cl = '<font color="#000000" >';var tt = '【' + Animals[(SY-4)%12] + '】' + cyclical(lDObj.monCyl) + '月 ' + cyclical(lDObj.dayCyl++) + '日';return(cl+tt+'</font>');}function solarDay2(){var sDObj = new Date(SY, SM, SD);var lDObj = new Lunar(sDObj);var cl = '<font color="#000000" >';//农历BB'+(cld[d].isLeap?'闰 ':' ')+cld[d].lMonth+' 月 '+cld[d].lDay+' 日var tt = cyclical(SY-1900+36)+'年 '+cDay(lDObj.month,lDObj.day);return(cl+tt+'</font>');}function solarDay3(){var sTermInfo = newArray(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,2 40693,263343,285989,308563,331033,353350,375494,397447,419210,440795,4622 24,483532,504758);var solarTerm = new Array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至");var lFtv = new Array("0101*春节","0115 元宵节","0505 端午节","0707 七夕情人节","0715 中元节","0815 中秋节","0827 MM的生日","0909 重阳节","1208 腊八节","1224 小年","0100*除夕");var sFtv = new Array("0101*元旦","0214 情人节","0308 妇女节","0312 植树节","0315 消费者权益日","0401 愚人节","0407 偶今天又长一岁拉","0501 劳动节","0504 青年节","0512 护士节","0601 儿童节","0701 建党节香港回归纪念","0801 建军节","0808 父亲节","0909 毛席逝世纪念","0910 教师节","0928 孔子诞辰","1001*国庆节","1006 老人节","1024 联合国日","1112 孙中山诞辰","1220 澳门回归纪念","1225 圣诞节","1226 毛席诞辰");var sDObj = new Date(SY, SM, SD);var lDObj = new Lunar(sDObj);var lDPOS = new Array(3);var festival='',solarTerms='',solarFestival='',lunarFestival='',tmp1,tmp2;//农历节日for (i in lFtv)if (lFtv[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) {tmp1=Number(RegExp.$1)-lDObj.month;tmp2=Number(RegExp.$2)-lDObj.day;if(tmp1==0 && tmp2==0) lunarFestival=RegExp.$4;}//国历节日for (i in sFtv)if (sFtv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/)){tmp1 = Number(RegExp.$1)-(SM+1);tmp2 = Number(RegExp.$2)-SD;if (tmp1==0 && tmp2==0) solarFestival = RegExp.$4;}//节气tmp1 = new Date((31556925974.7*(SY-1900)+sTermInfo[SM*2+1]*60000)+Date.UTC(1900,0,6,2,5));tmp2 = tmp1.getUTCDate();if (tmp2 == SD) solarTerms = solarTerm[SM*2+1];tmp1 = new Date((31556925974.7*(SY-1900)+sTermInfo[SM*2]*60000)+Date.UTC(1900,0,6,2,5));tmp2 = tmp1.getUTCDate();if (tmp2 == SD) solarTerms = solarTerm[SM*2];return('<font color="green" STYLE="font-size:9pt;">'+festival+'</font>'); }//显示当前时间function CurentTime(){var now = new Date();var hh = now.getHours();var mm = now.getMinutes();var ss = now.getTime() % 60000;ss = (ss - (ss % 1000)) / 1000;var clock = hh+':';if (mm < 10) clock += '0';clock += mm+':';if (ss < 10) clock += '0';clock += ss;return(clock);}function refreshCalendarClock() //{document.all.ClockTime.innerHTML = CurentTime();}//显示当前时间function setCalendar(){document.write("<table border='0' cellspacing='0' style='color:#000000;font-size:12px;' cellpadding='0'");document.write("<tr><td width='10'></td><td>"+YYMMDD()+SD+"日"+"&nbsp;&nbsp;");document.write(weekday()+"<span style='display:none;'>"+"<fontid=ClockTime >"+CurentTime()+"</font>"+"</span>"+"&nbsp;&nbsp;");document.write("<spanstyle='display:none;'>"+solarDay1()+"</span>"+solarDay2()+"&nbsp;"+"<span style='display:none;'>"+solarDay3()+"</span>"+"</td></tr></table>");}setCalendar();setInterval('refreshCalendarClock()', 1000);//1秒钟刷新1次当前时间(不刷新日期) //-->天气预报的制作在网页中嵌入下列代码,修改id即可<IFRAME marginWidth=0 marginHeight=0src="/m/p2/weather1.htm?id=101080701T" frameBorder=0 width=200 scrolling=no height=24 allowTransparency></IFRAME>滚动新闻条的制作<iframe name=sina_roll src=/o/allnews/input/index.html height=11 width=100% frameborder=No border=0 marginwidth=0 marginheight=0 scrolling=No></iframe>。

综合实践教案:设计天气预报小程序,提高学生综合能力

综合实践教案:设计天气预报小程序,提高学生综合能力

综合实践作为一种具有实践性、综合性和探究性的教学模式,在当今教育中得到了广泛的推广和应用。

从提高学生的综合能力、培养学生的创新和实践能力等方面来看,综合实践教育无疑是非常重要的。

在这篇文章中,我将从综合实践教育的角度出发,介绍一种设计天气预报小程序的实践案例,并探讨这种教学模式在提高学生综合能力方面的应用。

一、案例介绍本实践案例以设计天气预报小程序为例,通过让学生熟悉HTML、CSS、JavaScript以及手机APP开发流程,掌握API数据接口的使用等技能,提高学生对互联网技术的理解和掌握。

主要步骤如下:1、了解天气预报接口数据来源2、搭建项目开发环境(VSCode + Node.js)3、熟悉HTML、CSS、JavaScript基础语法和数据结构4、设计和实现天气预报小程序界面5、实现和调试基本功能(例如通过城市名获取天气信息展示)6、优化小程序性能并发布上线在实践中,小组成员需要充分发挥创新性和团队合作精神,提高信息查找和解决问题的能力,同时还需要理解和应用项目协作工具(例如Git、Trello等),同时着重培养实践能力和沟通能力。

二、综合能力提高1. 提高问题解决能力在项目设计过程中,学生需要通过网络检索数据和技术资料,根据实际情况解决问题。

这种实践能够培养学生的快速学习和解决问题的能力,同时提高其独立思考和创新能力。

例如,在实现小程序基本功能时,需要利用API数据接口实现通过城市名获取天气信息,需要学生自主寻找相关数据源和接口文档来实现业务需求。

2. 培养团队合作能力项目实践中,学生通常需要以小组形式完成任务,这可以帮助学生学会分工、沟通和协作。

在该实践案例中,小组成员需要了解学习相应技术后进行任务分配,密切协作以实现小程序的规划和实施。

这可以增强学生的合作精神,提高团队工作效能。

3. 提高实践操作能力在设计天气预报小程序时,学生必须深入理解所学技术和API数据接口的原理和应用。

通过自主设计、实现和调试程序,对互联网技术有了更深入、更具体的理解。

基于Android及JSON的天气预报APP设计与实现

基于Android及JSON的天气预报APP设计与实现

基于Android及JSON的天气预报APP设计与实现基于Android及JSON的天气预报APP设计与实现一、引言天气对于人们的日常生活和活动有着重要的影响。

人们需要了解天气情况,以便合理安排出行计划、衣物搭配和户外活动等。

为了方便用户随时获取天气信息,本文设计并实现了一款基于Android及JSON的天气预报APP。

二、需求分析1.必要功能需求(1)用户注册和登录:用户可以通过注册账号来使用该APP,并通过登录进行身份验证;(2)天气查询:用户可以查询指定地点的天气情况,并实时更新;(3)天气预警:用户可以收到相关地区的天气预警信息;(4)天气趋势分析:用户可以查看多天天气趋势,根据过去天气进行未来天气的预测。

2.可选功能需求(1)定位功能:自动获取用户当前位置,方便快捷地查询当地天气;(2)城市切换:用户可以手动切换所查询的城市;(3)天气分享:用户可以将查询到的天气信息分享至社交媒体;(4)个性化设置:用户可以自定义APP的主题风格和其他设置。

三、技术选型1.开发平台:Android Studio2.数据交互:使用JSON数据格式进行数据传输和解析3.天气数据接口:调用第三方天气数据接口,如心知天气API 等四、系统设计1.登录与注册模块(1)用户需要通过注册账号来使用该APP,注册过程需要基本的用户信息,并进行验证;(2)用户可以通过输入注册信息进行登录,验证账号和密码是否匹配。

2.天气查询模块(1)用户可以通过输入地理信息查询对应地点的天气情况;(2)APP向第三方天气数据接口发送请求,获取JSON格式的天气数据;(3)解析JSON数据,提取出相应的天气信息,并在APP界面上展示出来。

3.天气预警模块(1)APP定时向天气数据接口查询当前地区是否有天气预警信息;(2)如果有天气预警信息,APP将在用户界面上及时显示出来。

4.天气趋势分析模块(1)用户可以选择多天日期,查看该地区的天气趋势分析;(2)根据历史数据进行未来天气的预测,为用户提供参考。

天气预报代码

天气预报代码

qq.htm代码如下:引用:<html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>迷你天气预报</title><style>body{margin:0;padding:0;background:#fff;font-size:12px;}form{margin:0;padding:0;}img{border:0;}*{overflow:hidden;line-height:150%:}a{color:#666666;text-decoration:none;}a:visited{color:#666666}a:hover{color:#666666;text-decoration:underline;}#Head_Area {BACKGROUND: url() 10% top; MARGIN-BOTTOM: 0px; OVERFLOW: hidden; WIDTH: 230px;HEIGHT: 15px}#Head_Area #Wealth {FLOAT: left; WIDTH: 230px; LINE-HEIGHT: 15px; PADDING-TOP: 0px;}#Head_Area #Wealth A {COLOR: #666666}</style><!--[if ie 7]><style>.cl{height:0;}</style><![endif]--><script type="text/javascript" src="../js/j.minisite.weather.js"></script></head><body onLoad="document.execCommand('BackgroundImageCache',false,true);"> <div id="Head_Area"><div id="Wealth"></div><script type="text/javascript">/*<![CDATA[*/MiniSite.Weather.print("Wealth");/*]]>*/</script></div></body></html>j.minisite.weather.js如下:引用:/** created by WangSo at 2008-4-9*/var MiniSite = new Object();MiniSite.Browser = {ie: /msie/.test(erAgent.toLowerCase()),moz: /gecko/.test(erAgent.toLowerCase()),opera: /opera/.test(erAgent.toLowerCase())};MiniSite.$ = function(s){return (typeof s == 'object') ? s: document.getElementById(s);};MiniSite.JsLoader = {load: function(sUrl, fCallback){var _script = document.createElement('script');_script.setAttribute('type', 'text/javascript');_script.setAttribute('src', sUrl);document.getElementsByTagName('head')[0].appendChild(_script);if (MiniSite.Browser.ie){_script.onreadystatechange = function(){if (this.readyState=='loaded' || this.readyState=='complete'){fCallback();}};}else if (MiniSite.Browser.moz){_script.onload = function(){fCallback();};}else{fCallback();}}};MiniSite.Cookie = {set: function(name, value, expires, path, domain){if (typeof expires == "undefined"){expires = new Date(new Date().getTime() + 365*24*3600*100);}document.cookie = name + "=" + escape(value) +((expires) ? "; expires=" + expires.toGMTString() : "") +((path) ? "; path=" + path : "; path=/") +((domain) ? "; domain=" + domain : "");},get: function(name){var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));if (arr != null){return unescape(arr[2]);}return null;},clear: function(name, path, domain){if (this.get(name)){document.cookie = name + "=" +((path) ? "; path=" + path : "; path=/") +((domain) ? "; domain=" + domain : "") +";expires=Fri, 02-Jan-1970 00:00:00 GMT";}}};MiniSite.Weather = {defaultCity: 125,city: {"北京市": {"_": 125,"北京市": 125},"上海市": {"_": 252,"上海市": 252},"天津市": {"_": 127,"天津市": 127,"塘沽区": 132},"重庆市" : {"_": 212,"奉节区": 201,"重庆市": 212,"涪陵区": 213},"香港": {"_": 1,"香港": 1},"澳门": {"_": 2,"澳门": 2},"台湾省": {"_": 280,"台北市": 280},"云南省": {"_": 179,"昭通市": 173,"丽江市": 174,"曲靖市": 175,"保山市": 176,"大理州": 177,"楚雄州": 178,"昆明市": 179,"瑞丽市": 180,"玉溪市": 181,"临沧市": 182,"思茅市": 184,"红河州": 185,"文山州": 369,"西双版纳州": 370,"怒江州": 372,"迪庆州": 373},"内蒙古": {"_": 69,"呼伦贝尔市": 4,"兴安盟": 7,"锡林郭勒盟": 16,"巴彦淖尔市": 63,"包头市": 64,"呼和浩特市": 69,"锡林浩特市": 99,"通辽市": 101,"赤峰市": 106,"乌海市": 382,"鄂尔多斯市": 383,"乌兰察布市": 384 },"吉林省": {"_": 103,"辽源市": 34,"通化市": 36,"白城市": 37,"松原市": 96,"长春市": 103,"吉林市": 104,"桦甸市": 109,"延边州": 110,"集安市": 118,"白山市": 119,"四平市": 385},"四川省": {"_": 166,"甘孜州": 162,"阿坝州": 163,"成都市": 166,"雅安市": 168,"峨眉山市": 170,"乐山市": 171,"宜宾市": 172,"巴中市": 199,"达州市": 200,"遂宁市": 204,"南充市": 205,"泸州市": 216,"自贡市": 359,"攀枝花市": 360,"德阳市": 361,"广元市": 362,"内江市": 363,"广安市": 364,"眉山市": 365,"资阳市": 366,"凉山州": 367 },"宁夏": {"_": 78,"石嘴山市": 54,"银川市": 78,"吴忠市": 83,"固原市": 209 },"安徽省": {"_": 248,"淮南市": 75,"马鞍山市": 76,"淮北市": 77,"铜陵市": 92,"滁州市": 95,"巢湖市": 100,"池州市": 102,"宣城市": 105,"亳州市": 238,"阜阳市": 241,"六安市": 242,"蚌埠市": 243,"合肥市": 248,"芜湖市": 249,"安庆市": 253,"黄山市": 254 },"山东省": {"_": 140,"德州市": 134,"滨州市": 135,"烟台市": 136,"聊城市": 139,"济南市": 140,"泰安市": 141,"淄博市": 142,"潍坊市": 143,"青岛市": 144,"济宁市": 146,"日照市": 147,"泰山市": 156,"枣庄市": 159,"东营市": 160,"威海市": 164,"莱芜市": 165,"临沂市": 183,"菏泽市": 206 },"山西省": {"_": 84,"长治市": 9,"晋中市": 22,"朔州市": 70,"大同市": 72,"吕梁市": 80,"忻州市": 81,"阳泉市": 85,"临汾市": 88,"运城市": 93,"晋城市": 94,"五台山市": 381 },"广东省": {"_": 292,"南雄市": 235,"韶关市": 283,"清远市": 284,"梅州市": 285,"肇庆市": 291,"广州市": 292,"河源市": 293,"****市": 294,"深圳市": 296,"汕尾市": 297,"湛江市": 300,"阳江市": 301,"茂名市": 302,"佛冈市": 322,"梅县市": 323,"电白市": 324,"高要市": 325,"珠海市": 330,"佛山市": 331,"江门市": 332,"东莞市": 334,"中山市": 335,"潮州市": 336,"揭阳市": 337,"云浮市": 338 },"广西": {"_": 295,"桂林市": 232,"柳州市": 282,"百色市": 288,"贵港市": 289,"梧州市": 290,"南宁市": 295,"钦州市": 298,"北海市": 299,"防城港市": 339,"玉林市": 340,"贺州市": 341,"来宾市": 342,"崇左市": 343},"新疆": {"_": 28,"昌吉州": 19,"克孜勒苏柯尔克孜自治州": 20,"伊犁州": 21,"阿拉尔市": 23,"克拉玛依市": 24,"博尔塔拉州": 27,"乌鲁木齐市": 28,"吐鲁番市": 31,"阿克苏市": 32,"石河子市": 33,"喀什市": 35,"和田市": 39,"哈密市": 41,"奇台市": 52},"江苏省": {"_": 244,"无锡市": 43,"苏州市": 44,"盱眙市": 45,"赣榆市": 46,"东台市": 47,"镇江市": 59,"泰州市": 61,"宿迁市": 62,"徐州市": 236,"连云港市": 237,"淮安市": 240,"南京市": 244,"扬州市": 245,"盐城市": 246,"南通市": 247,"常州市": 250 },"江西省": {"_": 264,"庐山市": 111,"玉山市": 137,"贵溪市": 138,"广昌市": 145,"萍乡市": 153,"新余市": 154,"宜春市": 224,"赣州市": 234,"九江市": 258,"景德镇市": 259,"南昌市": 264,"鹰潭市": 265,"上饶市": 267,"抚州市": 273 },"河北省": {"_": 82,"邯郸市": 3,"衡水市": 8,"石家庄市": 82,"邢台市": 86,"张家口市": 120,"承德市": 121,"廊坊市": 126,"唐山市": 128,"保定市": 130,"沧州市": 131 },"河南省": {"_": 189,"安阳市": 89,"三门峡市": 188,"郑州市": 189,"南阳市": 192,"周口市": 193,"驻马店市": 197,"信阳市": 198,"开封市": 207,"洛阳市": 228,"平顶山市": 231,"焦作市": 251,"鹤壁市": 260,"新乡市": 304,"濮阳市": 305,"许昌市": 306,"漯河市": 307,"商丘市": 308,"济源市": 309 },"浙江省": {"_": 255,"湖州市": 65,"嵊州市": 66,"平湖市": 67,"石浦市": 68,"宁海市": 71,"洞头市": 73,"舟山市": 74,"杭州市": 255,"嘉兴市": 256,"金华市": 261,"绍兴市": 262,"宁波市": 263,"衢州市": 266,"丽水市": 268,"台州市": 269,"温州市": 272},"海南省": {"_": 303,"海口市": 303,"三亚市": 344,"屯昌市": 345,"琼海市": 346,"儋州市": 347,"文昌市": 348,"万宁市": 349,"东方市": 350,"澄迈市": 351,"定安市": 352,"临高市": 353,"白沙黎族自治县": 354,"乐东黎族自治县": 355,"陵水黎族自治县": 356,"保亭黎族苗族自治县": 357,"琼中黎族苗族自治县": 358 },"湖北省": {"_": 211,"襄樊市": 196,"荆门市": 202,"黄冈市": 203,"恩施州": 208,"武汉市": 211,"黄石市": 310,"鄂州市": 314,"孝感市": 315,"随州市": 317,"仙桃市": 318,"天门市": 319,"潜江市": 320,"神农架市": 321 },"湖南省": {"_": 218,"张家界市": 214,"岳阳市": 215,"怀化市": 217,"长沙市": 218,"邵阳市": 222,"益阳市": 223,"郴州市": 233,"桑植市": 311,"沅陵市": 312,"南岳市": 313,"株洲市": 326,"湘潭市": 327,"衡阳市": 328,"娄底市": 329,"常德市": 387 },"甘肃省": {"_": 57,"张掖市": 49,"金昌市": 50,"武威市": 51,"兰州市": 57,"白银市": 58,"定西市": 60,"平凉市": 90,"庆阳市": 91,"甘南市": 225,"临夏市": 229,"天水市": 377,"酒泉市": 379,"陇南市": 380},"福建省": {"_": 276,"莆田市": 107,"浦城市": 271,"南平市": 274,"宁德市": 275,"福州市": 276,"龙岩市": 277,"三明市": 278,"泉州市": 279,"漳州市": 286,"厦门市": 287},"**": {"_": 150,"那曲地区": 148,"日喀则地区": 149,"**市": 150,"山南地区": 151,"阿里地区": 152,"昌都地区": 161,"林芝地区": 169 },"贵州省": {"_": 227,"毕节市": 219,"遵义市": 220,"铜仁市": 221,"安顺市": 226,"贵阳市": 227,"黔西南州": 230,"六盘水市": 368 },"辽宁省": {"_": 115,"葫芦岛市": 25,"盘锦市": 26,"辽阳市": 29,"铁岭市": 30,"阜新市": 108,"朝阳市": 112,"锦州市": 113,"鞍山市": 114,"沈阳市": 115,"本溪市": 116,"抚顺市": 117,"营口市": 123,"丹东市": 124,"瓦房店市": 129,"大连市": 133 },"陕西省": {"_": 186,"榆林市": 79,"延安市": 87,"西安市": 186,"渭南市": 187,"汉中市": 190,"商洛市": 191,"安康市": 194,"铜川市": 374,"宝鸡市": 375,"咸阳市": 376 },"青海": {"_": 56,"海北州": 48,"海南州": 55,"西宁市": 56,"玉树州": 155,"黄南州": 157,"果洛州": 158,"海西州": 195,"海东市": 210},"黑龙江省": {"_": 17,"大兴安岭地区": 5,"黑河市": 6,"齐齐哈尔市": 10,"绥化市": 11,"鹤岗市": 12,"佳木斯市": 13,"伊春市": 14,"双鸭山市": 15,"哈尔滨市": 17,"鸡西市": 18,"漠河市": 38,"大庆市": 40,"七台河市": 42,"牡丹江市": 97,"绥芬河市": 98}},_print: function(province, city, conainter){if (typeof this.city[province] != "undefined"){if (typeof this.city[province][city] != "undefined"){var _city_ = this.city[province][city];}else if (typeof this.city[province]["_"] != "undefined"){var _city_ = this.city[province]["_"];}else{var _city_ = this.defaultCity;}}else{var _city_ = this.defaultCity;}MiniSite.JsLoader.load("/inc/minisite_"+_city_+".js", function(){try{MiniSite.$(conainter).innerHTML = "<a href='#'onclick=\"window.open('/inc/07_dc"+ _city_ + ".htm','','width=630,height=380,resizable=0')\"target='_blank'>"+ __minisite__weather__ + "</a>";}catch (e){}});},print: function(conainter){var ok = function(){var province = null;var city = null;var ipAddress = MiniSite.Cookie.get("QQ_IPAddress");if (ipAddress != null){try{var ipAddressArr = ipAddress.split(",");province = ipAddressArr[0];city =ipAddressArr[1];}catch (e){}}MiniSite.Weather._print(province, city, conainter);};if (!MiniSite.Cookie.get("QQ_IPAddress")){MiniSite.JsLoader.load(":80/ipaddress", function(){if (typeof IPData != "undefined"){MiniSite.Cookie.set('QQ_IPAddress', IPData[2]+','+IPData[3]);ok();}});}else{ok();}}};。

天气预报代码(WeatherDemo.java)

天气预报代码(WeatherDemo.java)

同学的天气预报代码,供参考!package com.example.baidumap;import java.io.BufferedInputStream;import java.io.IOException;import java.io.InputStream;import .URL;import .URLConnection;import org.apache.http.HttpResponse;import org.apache.http.HttpStatus;import org.apache.http.client.ClientProtocolException;import org.apache.http.client.HttpClient;import org.apache.http.client.methods.HttpGet;import org.apache.http.impl.client.DefaultHttpClient;import org.apache.http.util.EntityUtils;import org.json.JSONException;import org.json.JSONObject;import android.content.Context;import android.content.res.Resources;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.util.Log;publicclass WeatherDemo{privatestatic Resources resources;private JSONObject cityAndcode;private String weatherPicUrl1;privateboolean update=false;WeatherDemo(Context context){Log.i("Weather","create");System.out.println("create");cityAndcode = new JSONObject();resources = context.getResources();try {cityAndcode = loadLocalJson();} catch (JSONException e) {e.printStackTrace();}}public String getWeather(String city){String result="";try {Log.i("weather","cityAndcode.getString(city)"+cityAndcode.getString(city));String jsonUrl=new String("/data/"+cityAndcode.get(city)+".html");String strResult =getJson(jsonUrl);Log.i("weather",strResult);String message = getInfo(strResult);result = message;update =true;} catch (JSONException e) {result = "璇锋寜鏍煎紡杈撳叆鍩庡競鍚嶇О锛氬 锛堟俯宸烇級";update=false;}return result;}publicboolean weUpdate(){return update;}public JSONObjectloadLocalJson() throws JSONException{cityAndcode=new JSONObject();InputStreaminputStream = null;try {inputStream = resources.openRawResource(R.raw.cityandcode);byte[] reader = newbyte[inputStream.available()];while (inputStream.read(reader) != -1) {String[] cAc = new String(reader,"gb2312").split("\r\n");for(int i=0;i<cAc.length;i++){ String [] sub_cAc = cAc[i].split(":");sub_cAc[1] = sub_cAc[1].substring(0, sub_cAc[1].length()-1);cityAndcode.put(sub_cAc[0],sub_cAc[1]);Log.i("city","cityname:"+sub_cAc[0]+",citycode:"+cityAndcode.getString(sub _cAc[0]));}}} catch (IOException e) {Log.i("city", e.getMessage(), e);}return cityAndcode;}public StringgetJson(String jsonUrl){HttpGethttpRequest = new HttpGet(jsonUrl);String strResult = "";try {HttpClienthttpClient = new DefaultHttpClient();HttpResponsehttpResponse = httpClient.execute(httpRequest);if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { strResult = EntityUtils.toString(httpResponse.getEntity());}} catch (ClientProtocolException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}Log.i("H", strResult);return strResult;}public StringgetInfo(String strResult){StringBuildersb = new StringBuilder();String str=null;try {JSONObjectjsonObj = new JSONObject(strResult).getJSONObject("weatherinfo");str = jsonObj.getString("city");sb.append("鍩庡競:"+str+'\n');str= jsonObj.getString("date_y");sb.append("鏃ユ湡:"+str+"\n");str=jsonObj.getString("weather1");sb.append("澶╂皵:"+str+"\n");// str= jsonObj.getString("week");// sb.append("鏄熸湡锛�+str+"\n");str = jsonObj.getString("temp1");sb.append("浠婃棩娓╁害:"+str+"\n");// str=jsonObj.getString("tempF1");// sb.append("鍗庢皬娓╁害:"+str+"\n");// str=jsonObj.getString("temp2");// sb.append("鏄庢棩娓╁害:"+str+"\n");str=jsonObj.getString("wind1");sb.append("椋庡姏:"+str+"\n");// str=jsonObj.getString("index");// sb.append("浠婃棩寤鸿 :"+str+"\n");sb.append("浠婃棩寤鸿 :");str=jsonObj.getString("index_d");String[] strs=str.split("");int length=0;for(int i=0;i<strs.length;i++){ length = strs[i].length()+length;if(length>10){sb.append("\n");length=0;}else{sb.append(strs[i]);}}// str=jsonObj.getString("index48");// sb.append("48灏忔椂寤鸿 :"+str+"\t");// str=jsonObj.getString("index48_d");// s b.append(str+"\n");// str=jsonObj.getString("index_xc");// sb.append("娲楄溅鎸囨暟:"+str+"\n");str=jsonObj.getString("index_tr");sb.append("鏃呮父鎸囨暟:"+str+"\n");str=jsonObj.getString("index_co");sb.append("鏁f 鎸囨暟:"+str+"\n");weatherPicUrl1 =jsonObj.getString("img1");// sb.append("鍥剧墖鍦板潃:"+weatherPicUrl1+"\n");setWeatherPicUrl(weatherPicUrl1);} catch (JSONException e) {Log.i("Erorr","Json parse error");e.printStackTrace();}return sb.toString();}privatevoid setWeatherPicUrl(String url){this.weatherPicUrl1=url;}public Bitmap getBimap(){Bitmap bm=null;try{URL iconurl =new URL("/img/b"+weatherPicUrl1+".gif");URLConnection conn = iconurl.openConnection();conn.connect();InputStream is =conn.getInputStream();BufferedInputStreambis = new BufferedInputStream(is, 8192); bm = BitmapFactory.decodeStream(bis);bis.close();is.close();}catch(Exception e){Log.i("img","getBimap error");}return bm;}}。

Vue实现天气预报小应用

Vue实现天气预报小应用

Vue实现天⽓预报⼩应⽤这是本⼈在⾃学vue框架时候所模仿的⼀个⽹站,可以查询⼀些城市的天⽓情况,⼤家可以看看:html代码<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="X-UA-Compatible" content="ie=edge" /><title>焕鑫知道</title><link rel="stylesheet" href="css/reset.css" /><link rel="stylesheet" href="css/index.css" /></head><body><div class="wrap" id="app"><div class="search_form"><div class="logo"><p style="color: red;text-align: center; font-size: 64px;">查天⽓</p></div><div class="form_group"><input type="text" class="input_txt" placeholder="请输⼊查询的天⽓" v-model="city" @keyup.enter="queryWeather" /> <button class="input_sub" @click="queryWeather">搜索</button></div><div class="hotkey"><!-- <a href="javascript:;" @click="clickSearch('北京')">北京</a><a href="javascript:;" @click="clickSearch('上海')">上海</a><a href="javascript:;" @click="clickSearch('⼴州')">⼴州</a><a href="javascript:;" @click="clickSearch('深圳')">深圳</a> --><a href="javascript:;" v-for="city in hotCitys" @click="clickSearch(city)">{{ city }}</a></div></div><ul class="weather_list"><li v-for="(item,index) in forecastList" :key="item.date" :style="{transitionDelay:index*100+'ms'}"><div class="info_type"><span class="iconfont">{{ item.type }}</span></div><div class="info_temp"><b>{{ item.low}}</b>~<b>{{ item.high}}</b></div><div class="info_date"><span>{{ item.date }}</span></div></li></ul></div><!-- 开发环境版本,包含了有帮助的命令⾏警告 --><script src="https:///npm/vue/dist/vue.js"></script><!-- 官⽹提供的 axios 在线地址 --><script src="https:///axios/dist/axios.min.js"></script><script>new Vue({el: "#app",data: {city: "武汉",forecastList: [],hotCitys: ["北京", "上海", "⼴州", "深圳"]},methods: {queryWeather() {this.forecastList = [];axios.get(`/weather_mini?city=${this.city}`).then(res => {console.log(res);this.forecastList = res.data.data.forecast;}).catch(err => {console.log(err);}).finally(() => { });},clickSearch(city) {this.city = city;this.queryWeather();}}});</script></body></html>js的代码/*请求地址:/weather_mini请求⽅法:get请求参数:city(城市名)响应内容:天⽓信息1. 点击回车2. 查询数据3. 渲染数据*/var app = new Vue({el:"#app",data:{city:'',weatherList:[]},methods: {searchWeather:function(){// console.log('天⽓查询');// console.log(this.city);// 调⽤接⼝// 保存thisvar that = this;axios.get('/weather_mini?city='+this.city) .then(function(response){// console.log(response);console.log(response.data.data.forecast);that.weatherList = response.data.data.forecast}).catch(function(err){})}},})⾸页的css⽂件body{font-family:'Microsoft YaHei';}.wrap{position: fixed;left:0;top:0;width:100%;height:100%;/* background: radial-gradient(#f3fbfe, #e4f5fd, #8fd5f4); *//* background:#8fd5f4; *//* background: linear-gradient(#6bc6ee, #fff); */background:#fff;}.search_form{width:640px;margin:100px auto 0;}.logo img{display:block;margin:0 auto;.form_group{width:640px;height:40px;margin-top:45px;}.input_txt{width:538px;height:38px;padding:0px;float:left;border:1px solid #41a1cb;outline:none;text-indent:10px;}.input_sub{width:100px;height:40px;border:0px;float: left;background-color: #41a1cb;color:#fff;font-size:16px;outline:none;cursor: pointer;position: relative;}.input_sub.loading::before{content:'';position: absolute;left: 0;top: 0;width: 100%;height: 100%;background: url('../img/loading.gif');}.hotkey{margin:3px 0 0 2px;}.hotkey a{font-size:14px;color:#666;padding-right:15px;}.weather_list{height:200px;text-align:center;margin-top:50px;font-size:0px;}.weather_list li{display:inline-block;width:140px;height:200px;padding:0 10px;overflow: hidden;position: relative;background:url('../img/line.png') right center no-repeat; background-size: 1px 130px;}.weather_list li:last-child{background:none;}/* .weather_list .col02{background-color: rgba(65, 165, 158, 0.8);}.weather_list .col03{background-color: rgba(94, 194, 237, 0.8);}.weather_list .col04{background-color: rgba(69, 137, 176, 0.8);.weather_list .col05{background-color: rgba(118, 113, 223, 0.8); } */.info_date{width:100%;height:40px;line-height:40px;color:#999;font-size:14px;left:0px;bottom:0px;margin-top: 15px;}.info_date b{float: left;margin-left:15px;}.info_type span{color:#fda252;font-size:30px;line-height:80px;}.info_temp{font-size:14px;color:#fda252;}.info_temp b{font-size:13px;}.tem .iconfont {font-size: 50px;}reset的css⽂件body,ul,h1,h2,h3,h4,h5,h6{margin: 0;padding: 0;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}a{text-decoration:none;}ul{list-style:none;}img{border:0px;}/* 清除浮动,解决margin-top塌陷 */.clearfix:before,.clearfix:after{content:'';display:table;}.clearfix:after{clear:both;}.clearfix{zoom:1;}.fl{float:left;}.fr{float:right;}测试结果以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

js实现天气预报模板

js实现天气预报模板

JS实现天气预报将代码复制到html文档中,直接可以出来<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="Generator" content="EditPlus®"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Description" content=""><title>天气预报</title></head><body><iframe name="weather_inc" src="/cframe/2" width="890" height="70" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br/><iframe name="weather_inc" src="/cframe/1" width="330" height="35" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br/><iframe name="weather_inc" src="/cframe/2" width="890" height="70" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br/><iframe name="weather_inc" src="/cframe/9" width="250" height="64" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br/><iframe name="weather_inc" src="/cframe/11" width="500" height="15" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" ></iframe><br /><br /><iframe name="weather_inc" src="/index.php?c=code&id=55" style="border:solid 1px #7ec8ea" width="255" height="294" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br /><br /><iframe name="weather_inc" src="/index.php?c=code&id=8&num=3" width="225" height="80" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br /><br /><iframe name="weather_inc" src="/index.php?c=code&id=9" width="500" height="60" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br /><br /><iframe name="weather_inc" src="/index.php?c=code&id=13" width="650" height="221" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br /><br /><iframe name="weather_inc" src="/index.php?c=code&id=57" width="650" height="427" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br /><br /><iframe name="weather_inc" src="/index.php?c=code&id=64" width="540" height="291" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br /><br /><br /><iframe name="weather_inc" src="/cframe/4" width="130" height="120" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></body></html>。

天气预报模块测试用例(P707)

天气预报模块测试用例(P707)

2
点击“功能说明”按钮
3 4 5
点击“订阅”按钮
自动发送“订阅”服务信息
订阅成功后,再点击“功能说 进入功能说明界面,下文无显 明”按钮 示“订阅”按钮 按“返回”按钮 可返回到上一级目录 提示“连接中”,连网成功 后,显示当前默认城市天气预 报信息,且信息要正常,字体 和图标显示正确 进入设置界面,可对主界面显 示的两个城市、更新方式、待 机下显示城市,进行重新设置
6
再“点击”更新
7
点击“设置”按钮
8
设置完成后,点击“保存”按 分别查看各重新设置的项,重 钮 新修改设置项有效
9
点击“更多城市”按钮 点击其他各分类主题名称
默认显示主题为“全部”城市 名称 能正常刷新列表信息
10
11
在搜索输入框,默认显示拼音 按输入的信息,正确搜索出城 查找,输入拼音 市信息 切换另外两个输入法:笔画输 查找结果显示正确 入、数字输入,进行重新查找
项目名: 测试人: 未通过的用例编号: 准备工作: 序号 测试步骤 用例编号: 测试说明: 验证功能点:天气预报功能验证 1 点击“天气预报”菜单
天气预报模块标准化的测试用例 软件版本: 参考手机:
期望结果
P/F
进入天气预报界面,界面上方显 示默认两个城市名称为“北京 ”,列表显示:请到‘功能说明 ’订阅天气预报,下文显示功能 进入功能说明界面,说明文字要 正确,无错别字
请到功能说明订阅天气预报下文显示功能按钮进入功能说明界面说明文字要正确无错别字进入功能说明界面下文无显示订阅按钮提示连接中连网成功后显示当前默认城市天气预报信息且信息要正常字体和图标显示正确进入设置界面可对主界面显示的两个城市更新方式待机下显示城市进行重新设置分别查看各重新设置的项重新修改设置项有效点击更多城市按钮默认显示主题为全部城市名称10点击其他各分类主题名称能正常刷新列表信息11按输入的信息正确搜索出城市信息12查找结果显示正确13可按要求操作查找结果显示正确14可返回到待机界面在搜索输入框默认显示拼音查找输入拼音切换另外两个输入法

CSS如何实现天气带动画的天气图标

CSS如何实现天气带动画的天气图标

CSS如何实现天气带动画的天气图标CSS如何实现天气带动画的天气图标最好不是在夕阳西下的时候去幻想什么,而要在旭日初升的时候即投入学习。

以下是店铺为大家搜索整理的用CSS如何实现天气带动画的'天气图标,希望能给大家带来帮助!下面我们来做一个会下雨的天气图标实例,过程其实很简单哦。

STEP1: 整体HTML架构STEP2: 用CSS绘制云朵图标CSS代码如下body {max-width: 42em;padding: 2em;margin: 0 auto;color: #161616;font-family: 'Roboto', sans-serif;text-align: center;background-color: currentColor;}.icon {position: relative;display: inline-block;width: 12em;height: 10em;font-size: 1em; /* control icon size here */}.cloud {position: absolute;z-index: 1;top: 50%;left: 50%;width: 3.6875em;height: 3.6875em;margin: -1.84375em;background: currentColor;border-radius: 50%;box-shadow:-2.1875em 0.6875em 0 -0.6875em,2.0625em 0.9375em 0 -0.9375em,0 0 0 0.375em #fff,-2.1875em 0.6875em 0 -0.3125em #fff, 2.0625em 0.9375em 0 -0.5625em #fff;}.cloud:after {content: '';position: absolute;bottom: 0;left: -0.5em;display: block;width: 4.5625em;height: 1em;background: currentColor;box-shadow: 0 0.4375em 0 -0.0625em #fff; }.cloud:nth-child(2) {z-index: 0;background: #fff;box-shadow:-2.1875em 0.6875em 0 -0.6875em #fff, 2.0625em 0.9375em 0 -0.9375em #fff,0 0 0 0.375em #fff,-2.1875em 0.6875em 0 -0.3125em #fff,2.0625em 0.9375em 0 -0.5625em #fff;opacity: 0.3;transform: scale(0.5) translate(6em, -3em); animation: cloud 4s linear infinite;}.cloud:nth-child(2):after { background: #fff; }.rain{position: absolute;z-index: 2;top: 50%;left: 50%;width: 3.75em;height: 3.75em;margin: 0.375em 0 0 -2em;background: currentColor;}.rain:after {content: '';position: absolute;z-index: 2;top: 50%;left: 50%;width: 1.125em;height: 1.125em;margin: -1em 0 0 -0.25em;background: #0cf;border-radius: 100% 0 60% 50% / 60% 0 100% 50%; box-shadow:0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2), -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2), -1.375em -0.125em 0 rgba(255,255,255,0.2); transform: rotate(-28deg);animation: rain 3s linear infinite; /*设置动画 rain */}STEP3: 下雨动画/* 下雨动画 Animations */@keyframes rain {0% {background: #0cf;box-shadow:0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2), -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2), -1.375em -0.125em 0 #0cf;}25% {box-shadow:0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2), -0.875em 1.125em 0 -0.125em #0cf,-1.375em -0.125em 0 rgba(255,255,255,0.2);}50% {background: rgba(255,255,255,0.3);box-shadow:0.625em 0.875em 0 -0.125em #0cf,-0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2), -1.375em -0.125em 0 rgba(255,255,255,0.2);}100% {box-shadow:0.625em 0.875em 0 -0.125em rgba(255,255,255,0.2), -0.875em 1.125em 0 -0.125em rgba(255,255,255,0.2), -1.375em -0.125em 0 #0cf;}}最图效果:【CSS如何实现天气带动画的天气图标】。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

JS实现天气预报
将代码复制到html文档中,直接可以出来
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>天气预报</title>
</head>
<body>
<iframe name="weather_inc" src="/cframe/2" width="890" height="70" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br/>
<iframe name="weather_inc" src="/cframe/1" width="330" height="35" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br/>
<iframe name="weather_inc" src="/cframe/2" width="890" height="70" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br/>
<iframe name="weather_inc" src="/cframe/9" width="250" height="64" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br/>
<iframe name="weather_inc" src="/cframe/11" width="500" height="15" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" ></iframe>
<br />
<br />
<iframe name="weather_inc" src="/index.php?c=code&id=55" style="border:solid 1px #7ec8ea" width="255" height="294" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br />
<br />
<iframe name="weather_inc" src="/index.php?c=code&id=8&num=3" width="225" height="80" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br />
<br />
<iframe name="weather_inc" src="/index.php?c=code&id=9" width="500" height="60" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br />
<br />
<iframe name="weather_inc" src="/index.php?c=code&id=13" width="650" height="221" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br />
<br />
<iframe name="weather_inc" src="/index.php?c=code&id=57" width="650" height="427" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br />
<br />
<iframe name="weather_inc" src="/index.php?c=code&id=64" width="540" height="291" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<br />
<br />
<br />
<iframe name="weather_inc" src="/cframe/4" width="130" height="120" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</body>
</html>。

相关文档
最新文档