فهرست منبع

首页获取当前所在城市天气情况

htc 1 ماه پیش
والد
کامیت
66fcf1644a
2فایلهای تغییر یافته به همراه7 افزوده شده و 20 حذف شده
  1. 0 5
      manifest.json
  2. 7 15
      pagesHome/index.vue

+ 0 - 5
manifest.json

@@ -112,11 +112,6 @@
         "usingComponents" : true,
         "optimization" : {
             "subPackages" : true
-        },
-        "permission" : {
-            "scope.userLocation" : {
-                "desc" : "获取当前城市天气"
-            }
         }
     },
     "mp-alipay" : {

+ 7 - 15
pagesHome/index.vue

@@ -9,8 +9,7 @@
 						<text>谷锐特</text>
 						<u-icon name="arrow-right" color="#FFFFFF" size="32"></u-icon>
 					</div>
-					<!-- <div class="tip">{{time}},天气{{weatherInfo.wea||''}},共有{{deviceNum}}个设备正在运行</div> -->
-					<div class="tip">{{time}},天气{{weatherInfo.wea||''}}</div>
+					<div class="tip">{{time}},天气{{weatherInfo.weather||''}}</div>
 				</div>
 				<div class="right" @tap="tuTurn('/pages/my/info')">
 					<image :src="avatar"></image>
@@ -18,11 +17,11 @@
 			</div>
 			<div class="weather">
 				<div class="item line">
-					<div class="text">{{weatherInfo.air_level||''}}</div>
-					<p>空气质量</p>
+					<div class="text">{{deviceNum}}<span></span></div>
+					<p>运行设备</p>
 				</div>
 				<div class="item line">
-					<div class="text">{{weatherInfo.tem||''}}<span>℃</span></div>
+					<div class="text">{{weatherInfo.temperature||''}}<span>℃</span></div>
 					<p>温度</p>
 				</div>
 				<div class="item">
@@ -63,6 +62,7 @@
 
 <script>
 	var amapFile = require('@/utils/amap-wx.130.js');
+	var myAmapFun = new amapFile.AMapWX({key:'f83be04fc5f239edfa9f1201e4bc7c47'});
 	import Tabbar from '@/components/CusTabbar/index.vue'
 	export default {
 		components:{
@@ -93,17 +93,9 @@
 				else if(hours<=24) this.time = '晚上好';
 			},
 			getWeather(){
-				// uni.request({
-				// 	url:'http://gfeljm.tianqiapi.com/free/v2030?appid=31449887&appsecret=7F6JCrvB&adcode=340100000000',
-				// 	success:res=>{
-				// 		this.weatherInfo = res.data;
-				// 		this.weatherInfo.humidity = this.weatherInfo.humidity.replace('%','')
-				// 	}
-				// })
-				var myAmapFun = new amapFile.AMapWX({key:'f83be04fc5f239edfa9f1201e4bc7c47'});
 				myAmapFun.getWeather({
-					success: function(data) {
-						console.log(data);
+					success:res=>{
+						this.weatherInfo = res.liveData;
 					}
 				})
 			},