日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言写天气预报程序,微信小程序实现天气预报功能

發布時間:2025/3/12 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言写天气预报程序,微信小程序实现天气预报功能 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

獲取應用實例

var app = getApp()

Page({

data: {

//加載狀態

loadingHidden: false,//當前溫度

currentTemperature: '',//夜間溫度

nightAirTemperature: '',//白天溫度

dayAirTemperature: '',//當前天氣

weather: '',//污染指數

aqi: '',//污染程度

quality: '',//風力

windPower: '',//風向

windDirection: '',//因為數據返回不是數組所以要自己封裝一個數組

list: [],height: 0,},onLoad: function () {

console.log('onLoad')

var that = this

//100%好像不好使 可以獲取設備高度

wx.getSystemInfo({

success: function (res) {

that.data.height = res.windowHeight;

}

})

wx.getLocation({

success: function (res) {

//通過經緯度請求數據

wx.request({

//這個網站有免費API趕緊收藏

url: 'http://route.showapi.com/9-5',data: {

showapi_appid: '11697',showapi_sign: '6c0c15c5ec61454dac5288cea2d32881',//

from: '5',lng: res.longitude,lat: res.latitude,//獲取一周情況 0是不獲取

needMoreDay: '1',needIndex: '1'

},success: function (res) {

console.log(res)

console.log(res.data.showapi_res_body.now.api)

that.setData({

//改變加載狀態

loadingHidden: true,currentTemperature: res.data.showapi_res_body.now.temperature,nightAirTemperature: res.data.showapi_res_body.f1.night_air_temperature,dayAirTemperature: res.data.showapi_res_body.f1.day_air_temperature,weather: res.data.showapi_res_body.now.weather,aqi: res.data.showapi_res_body.now.aqi,quality: res.data.showapi_res_body.now.aqiDetail.quality,windPower: res.data.showapi_res_body.now.wind_power,windDirection: res.data.showapi_res_body.now.wind_direction,//拼接數組

list: [

{

'day_weather_pic': res.data.showapi_res_body.f1.day_weather_pic,'weekday': res.data.showapi_res_body.f1.weekday,'day_air_temperature': res.data.showapi_res_body.f1.day_air_temperature,'night_air_temperature': res.data.showapi_res_body.f1.night_air_temperature

},{

'day_weather_pic': res.data.showapi_res_body.f2.day_weather_pic,'weekday': res.data.showapi_res_body.f2.weekday,'day_air_temperature': res.data.showapi_res_body.f2.day_air_temperature,'night_air_temperature': res.data.showapi_res_body.f2.night_air_temperature

},{

'day_weather_pic': res.data.showapi_res_body.f3.day_weather_pic,'weekday': res.data.showapi_res_body.f3.weekday,'day_air_temperature': res.data.showapi_res_body.f3.day_air_temperature,'night_air_temperature': res.data.showapi_res_body.f3.night_air_temperature

},{

'day_weather_pic': res.data.showapi_res_body.f4.day_weather_pic,'weekday': res.data.showapi_res_body.f4.weekday,'day_air_temperature': res.data.showapi_res_body.f4.day_air_temperature,'night_air_temperature': res.data.showapi_res_body.f4.night_air_temperature

},{

'day_weather_pic': res.data.showapi_res_body.f5.day_weather_pic,'weekday': res.data.showapi_res_body.f5.weekday,'day_air_temperature': res.data.showapi_res_body.f5.day_air_temperature,'night_air_temperature': res.data.showapi_res_body.f5.night_air_temperature

},{

'day_weather_pic': res.data.showapi_res_body.f6.day_weather_pic,'weekday': res.data.showapi_res_body.f6.weekday,'day_air_temperature': res.data.showapi_res_body.f6.day_air_temperature,'night_air_temperature': res.data.showapi_res_body.f6.night_air_temperature

},{

'day_weather_pic': res.data.showapi_res_body.f7.day_weather_pic,'weekday': res.data.showapi_res_body.f7.weekday,'day_air_temperature': res.data.showapi_res_body.f7.day_air_temperature,'night_air_temperature': res.data.showapi_res_body.f7.night_air_temperature

}

]

})

}

})

}

})

}

})

總結

以上是生活随笔為你收集整理的c语言写天气预报程序,微信小程序实现天气预报功能的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。