Browse Source

首页对接接口

zhaojing 1 year ago
parent
commit
5ac89dbe70
2 changed files with 21 additions and 23 deletions
  1. 4 5
      src/api/home.js
  2. 17 18
      src/packagesEnv/pages/home/index.wpy

+ 4 - 5
src/api/home.js

@@ -17,15 +17,14 @@ export function querySpaceFunctionCard(params) {
   return $http({
     url: `/controlSpaceUser/queryPermanentSpaceFunctionCard?userId=${params.userId}&companyId=${params.companyId}`,
     method: 'GET',
-    serverSp:'http://192.168.4.29:52015/'
+    serverSp:'http://192.168.4.29:52015'
   });
 }
 //常驻空间参数属性
 export function getSpaceProperty(params) {
   return $http({
     url: `/duoduo-service/duoduoenv-service/custom/spaceProperty?projectId=${params.projectId}&spaceId=${params.spaceId}`,
-    method: 'GET',
-    serverSp:'http://192.168.4.29:52015/'
+    method: 'GET'
   });
 }
 //切换公司
@@ -37,10 +36,10 @@ export function switchCompany(companyId) {
   });
 }
 // 天气预报
-export function getWeather() {
+export function getWeather(projectId) {
   return $http({
     isNotShowErrorToast: true,
-    url: `/duoduo-service/object-service/weather/getCurrentWeather`,
+    url: `/duoduo-service/object-service/weather/getCurrentWeather?projectId=${projectId}`,
     method: 'get'
   });
 }

+ 17 - 18
src/packagesEnv/pages/home/index.wpy

@@ -322,15 +322,13 @@ wepy.page({
       })
         .then((res) => {
           console.log('querySpaceFunctionCard', res);
-        })
-        .catch((err) => {
-          this.reSpaceId = 'xxxx';
-          this.showCard = {
-            openLight: 1,
-            raiseTemperature: 2,
-            lowerTemperature: 3,
-            // oneClickFullClose: 4,
-          };
+          if (res.message == '该用户没有常驻空间') {
+            this.reSpaceId = '';
+            this.showCard = {};
+            return;
+          }
+          this.reSpaceId = res.spaceId || '';
+          this.showCard = res || {};
           console.log('showCardshowCard', this.showCard);
 
           //常驻空间参数属性
@@ -341,8 +339,6 @@ wepy.page({
             })
               .then((res) => {
                 console.log('getSpaceProperty', res);
-              })
-              .catch((err) => {
                 this.spaceParam = {
                   hcho: 0,
                   pm25: 0,
@@ -350,8 +346,12 @@ wepy.page({
                   temperature: 0,
                   humidity: 0,
                 };
+              })
+              .catch((err) => {
+           
               });
-        });
+        })
+        .catch((err) => {});
     },
     projectClick: function(item) {
       //console.log('projectClickprojectClick', item);
@@ -421,10 +421,9 @@ wepy.page({
           { name: '上格云3' },
         ];
       });
-    getWeather()
-      .then((res) => {})
-      .catch((err) => {
-        this.weather = { temperature: 30, text: '云' };
+    getWeather(this.userInfo.projectId)
+      .then((res) => {
+        this.weather = res.content || {}; //{ temperature: 30, text: '云' };
         var text = '云';
         var imgname = 'sunny.png';
         if (text.indexOf('晴') > -1) {
@@ -442,9 +441,9 @@ wepy.page({
         } else if (text.indexOf('雪') > -1) {
           imgname = 'snow.png';
         }
-
         this.weather.imgname = imgname;
-      });
+      })
+      .catch((err) => {});
     this.loadData();
   },
   onShow() {},