|
|
|
@ -355,23 +355,23 @@ export default { |
|
|
|
|
// |
|
|
|
|
getWeather: function (region) { |
|
|
|
|
let this_ = this |
|
|
|
|
var myAmapFun = new amap.AMapWX({ key: 'e2ee6a41e07306db2214f0edfa86f73a' }); |
|
|
|
|
myAmapFun.getWeather({ |
|
|
|
|
success: function (data) { |
|
|
|
|
//成功回调 |
|
|
|
|
this_.showWeather = true |
|
|
|
|
console.log(data, 'success') |
|
|
|
|
this_.city = data.city.data, |
|
|
|
|
this_.time = data.liveData.reporttime, |
|
|
|
|
this_.weather = data.weather.data + ' ' + data.temperature.data + '°C' + ' ' + data.winddirection.data + ' ' + data.windpower.data, |
|
|
|
|
this_.$forceUpdate() |
|
|
|
|
}, |
|
|
|
|
fail: function (info) { |
|
|
|
|
//失败回调 |
|
|
|
|
this_.showWeather = false |
|
|
|
|
console.log(info, 'fail'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
// var myAmapFun = new amap.AMapWX({ key: 'e2ee6a41e07306db2214f0edfa86f73a' }); |
|
|
|
|
// myAmapFun.getWeather({ |
|
|
|
|
// success: function (data) { |
|
|
|
|
// //成功回调 |
|
|
|
|
// this_.showWeather = true |
|
|
|
|
// console.log(data, 'success') |
|
|
|
|
// this_.city = data.city.data, |
|
|
|
|
// this_.time = data.liveData.reporttime, |
|
|
|
|
// this_.weather = data.weather.data + ' ' + data.temperature.data + '°C' + ' ' + data.winddirection.data + ' ' + data.windpower.data, |
|
|
|
|
// this_.$forceUpdate() |
|
|
|
|
// }, |
|
|
|
|
// fail: function (info) { |
|
|
|
|
// //失败回调 |
|
|
|
|
// this_.showWeather = false |
|
|
|
|
// console.log(info, 'fail'); |
|
|
|
|
// } |
|
|
|
|
// }); |
|
|
|
|
// var data = { |
|
|
|
|
// region: region |
|
|
|
|
// }; |
|
|
|
@ -393,6 +393,23 @@ export default { |
|
|
|
|
// this.weatherImgUrl = '../../../static/images/whe_cloudy.png'; |
|
|
|
|
// } |
|
|
|
|
// }); |
|
|
|
|
|
|
|
|
|
uni.request({ |
|
|
|
|
url: `https://restapi.amap.com/v3/weather/weatherInfo?city=131100&key=7d0d358762ba1af430645a7592f75789`, |
|
|
|
|
method: 'get', |
|
|
|
|
success(res) { |
|
|
|
|
this_.showWeather = true |
|
|
|
|
const datas = res.data.lives[0] |
|
|
|
|
console.log(datas, 'success') |
|
|
|
|
this_.city = datas.city, |
|
|
|
|
this_.time = datas.reporttime, |
|
|
|
|
this_.weather = datas.weather+ ' ' + datas.temperature_float + '°C' + ' ' + datas.winddirection + '风 ' + datas.windpower+'级', |
|
|
|
|
this_.$forceUpdate() |
|
|
|
|
}, |
|
|
|
|
fail(err) { |
|
|
|
|
console.log(err) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
changeSwiper(e) { |
|
|
|
|
this.swiperCurrent = e.detail.current; |
|
|
|
@ -780,4 +797,12 @@ export default { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
.we-item{ |
|
|
|
|
font-size: 26rpx; |
|
|
|
|
color: #737373; |
|
|
|
|
} |
|
|
|
|
.we-item:first-child{ |
|
|
|
|
font-size: 30rpx; |
|
|
|
|
color: #424242; |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|