|
|
@@ -18,7 +18,11 @@
|
|
|
<view class="rightItem">
|
|
|
<view class="rightTitle">今日天气</view>
|
|
|
<view class="rightPng">
|
|
|
- <view class="rightContent">暂无</view>
|
|
|
+ <view
|
|
|
+ class="rightContent"
|
|
|
+ style="text-align: center; font-size: 40rpx"
|
|
|
+ >{{ weatherText }}</view
|
|
|
+ >
|
|
|
</view>
|
|
|
</view>
|
|
|
<view
|
|
|
@@ -146,6 +150,7 @@ export default {
|
|
|
warmNum: "",
|
|
|
warmDetail: [],
|
|
|
warmList: [],
|
|
|
+ weatherText: "",
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
|
@@ -192,14 +197,14 @@ export default {
|
|
|
},
|
|
|
goAbnormalInfo() {
|
|
|
if (uni.getStorageSync("userId")) {
|
|
|
- // if (this.warnNum <= 0) {
|
|
|
- // uni.showToast({
|
|
|
- // title: "暂无异常信息",
|
|
|
- // icon: "none",
|
|
|
- // duration: 1500,
|
|
|
- // });
|
|
|
- // return;
|
|
|
- // }
|
|
|
+ if (this.warnNum <= 0) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "暂无异常信息",
|
|
|
+ icon: "none",
|
|
|
+ duration: 1500,
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
uni.navigateTo({
|
|
|
url: "/pagesA/abnormalInfo/abnormalInfo",
|
|
|
});
|
|
|
@@ -243,6 +248,25 @@ export default {
|
|
|
this.shareNum = res.data.data?.length || 0;
|
|
|
});
|
|
|
},
|
|
|
+ // 获取天气接口
|
|
|
+ async getWeather() {
|
|
|
+ uni.request({
|
|
|
+ url: "https://kp36x7gr79.re.qweatherapi.com/v7/weather/now", // 使用官方域名
|
|
|
+ data: {
|
|
|
+ location: "101220101", // 城市ID
|
|
|
+ key: "72afe228cd7f436ebea7caa1345956f2", // 你的API Key
|
|
|
+ },
|
|
|
+ method: "GET",
|
|
|
+ success: (res) => {
|
|
|
+ if (res.statusCode === 200) {
|
|
|
+ this.weatherText = res.data.now.text;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error("网络错误:", err);
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
// 需要跟车对接一下,换一个接口
|
|
|
getWarmList() {
|
|
|
@@ -301,6 +325,7 @@ export default {
|
|
|
this.getShareNum();
|
|
|
this.getWarmList();
|
|
|
}
|
|
|
+ this.getWeather();
|
|
|
// 配置服务器
|
|
|
let selectedService = uni.getStorageSync("sercviceChoice");
|
|
|
if (!selectedService) {
|