Jelajahi Sumber

treatInfo添加容错

zhangxc 5 tahun lalu
induk
melakukan
bff9609ca1
2 mengubah file dengan 17 tambahan dan 4 penghapusan
  1. 9 2
      src/js/index.js
  2. 8 2
      src/js/indexHorizontal.js

+ 9 - 2
src/js/index.js

@@ -163,7 +163,12 @@ function getTreatment() {
 function getTipsInfo() {
   post(config.information,{name:getUrlArgObject('tipsName'),type:getUrlArgObject('tipsType'), position: 1}).then((res)=>{
     var data = res.data
-    window.tipsInfo = data
+    if(data) {
+        window.tipsInfo = data
+    }
+    
+  }).catch(function (err) {
+    console.log(err);
   })
 }
 
@@ -184,7 +189,7 @@ function getPageInfo() {
     } else {
       treatResult = {}
     }
-    if(tipsInfo.code == 0) {
+    if(tipsInfo.code &&tipsInfo.code == 0) {
       tipsResult = tipsInfo.data
     } else {
       tipsResult = {}
@@ -254,6 +259,8 @@ function getPageInfo() {
     
     // renderRecommendConditTips('conditTips','病情提示', medicalIndications || [])
     
+  }).catch(function (err) {
+    console.log(err);
   })
 
 

+ 8 - 2
src/js/indexHorizontal.js

@@ -160,7 +160,9 @@ function getPushInfo() {
 function getTreatment() {
   post(config.pushTreatment,Object.assign({featureType: '8'},msg)).then((res)=>{
     var data = res.data
-    window.treatInfo = data
+    if(data) {
+      window.tipsInfo = data
+    }
     // if(data.code == 0){
     //   var result = data.data;
     //   renderTreat(treatImg, 'treatRecommend','治疗方案',result)
@@ -179,6 +181,8 @@ function getTreatment() {
     // } else {
     //   renderTreat(treatImg,'treatRecommend','治疗方案',{})
     // }
+  }).catch(function (err) {
+    console.log(err);
   })
 }
 
@@ -202,7 +206,7 @@ function getPageInfo() {
     } else {
       treatResult = {}
     }
-    if(tipsInfo.code == 0) {
+    if(tipsInfo.code && tipsInfo.code == 0) {
       tipsResult = tipsInfo.data
     } else {
       tipsResult = {}
@@ -308,6 +312,8 @@ function getPageInfo() {
     
     // renderRecommendConditTips(conditTipsImg, 'conditTips','病情提示', medicalIndications || [])
     
+  }).catch(function (err) {
+    console.log(err);
   })
 
 }