uni.request({
url: 'http://wthrcdn.etouch.cn/weather_mini?city=' + city,
method: 'GET',
success: res => {
let today = res.data.data.forecast[0]
this.todayInfo.weather= today.type ? today.type : ''
this.todayInfo.lower = today.low.substr(2)
this.todayInfo.higher = today.high.substr(2)
this.todayInfo.fengli = today.fengxiang + ' ' + today.fengli.substring(today.fengli.indexOf('A[')+2, today.fengli.indexOf(']]'))
this.todayInfo.tips = res.data.data.ganmao
this.date.week = today.date.substr(today.date.indexOf('日') + 1)
let yes = res.data.data.yesterday
this.yestedayInfo.weather= yes.type ? yes.type : ''
this.yestedayInfo.lower = yes.low.substr(2)
this.yestedayInfo.higher = yes.high.substr(2)
let tomorrow = res.data.data.forecast[1]
this.tomorrowInfo.weather= tomorrow.type ? tomorrow.type : ''
this.tomorrowInfo.lower = tomorrow.low.substr(2)
this.tomorrowInfo.higher = tomorrow.high.substr(2)
let afterTomorrow = res.data.data.forecast[2]
this.afterTomorrowInfo.weather= afterTomorrow.type ? afterTomorrow.type : ''
this.afterTomorrowInfo.lower = afterTomorrow.low.substr(2)
this.afterTomorrowInfo.higher = afterTomorrow.high.substr(2)
},
fail: () => {
this.openmsg("警告","天气接口获取失败")
},
complete: () => {}
})
tips:
this.todayInfo.weather
今日天气
this.todayInfo.lower
今日最低温度
this.todayInfo.higher
今日最高温度
this.todayInfo.fengli
今日风力
this.todayInfo.tips
今日提醒
this.date.week
今日星期几
this.yestedayInfo
昨日天气情况
this.tomorrowInfo
明日天气情况
this.afterTomorrowInfo
后天天气情况