diff --git a/src/views/mealSurplusInformation/mealSurplusInformation.vue b/src/views/mealSurplusInformation/mealSurplusInformation.vue index e4b6422..911f9a2 100644 --- a/src/views/mealSurplusInformation/mealSurplusInformation.vue +++ b/src/views/mealSurplusInformation/mealSurplusInformation.vue @@ -167,52 +167,68 @@ export default { }, methods: { getKitchenInfo() { - let params = {}; - httpRequest("GET", "https://dev.yixiong-tech.com:8081/terminal/neglect/large-screen/kitchen/info", params, { + var params = {}; + var _this = this; + + httpRequest("GET", "http://dev.yixiong-tech.com:8087/terminal/neglect/large-screen/kitchen/info", params, { "authorization": "57ee87183f2a4fa59683ec9ef41c8f5d" - }).then((res) => { - this.dinnerType = ""; - this.mealTime = ""; - this.nutritionFoodList = []; - this.recipeFoodNotMadeList = []; - this.recipeFoodProducedList = []; - if (res.code === "00000" && res.data) { - this.dinnerType = res.data.dinnerType; + }).then(function(res) { + _this.dinnerType = ""; + _this.mealTime = ""; + _this.nutritionFoodList = []; + _this.recipeFoodNotMadeList = []; + _this.recipeFoodProducedList = []; + + if (res && res.code === "00000" && res.data) { + _this.dinnerType = res.data.dinnerType; + if (res.data.mealTimeStart && res.data.mealTimeEnd) { - this.mealTime = res.data.mealTimeStart + ' - ' + res.data.mealTimeEnd; + _this.mealTime = res.data.mealTimeStart + ' - ' + res.data.mealTimeEnd; } + + // 处理营养菜品列表 if (res.data.nutritionFoodList && res.data.nutritionFoodList.length) { - res.data.nutritionFoodList.map(item => { + res.data.nutritionFoodList.map(function(item) { if (item.marginWeight >= item.warningWeight) { item.class = "normal"; - } - if (item.marginWeight < item.warningWeight && item.marginWeight >= item.dangerWeight) { + } else if (item.marginWeight >= item.dangerWeight) { item.class = "warning"; - } - if (item.marginWeight < item.dangerWeight) { + } else { item.class = "danger"; } item.foodWeight_kg = Math.round(item.foodWeight / 10) / 100; item.marginWeight_kg = Math.round(item.marginWeight / 10) / 100; item.progress = (1 - item.marginWeight / item.foodWeight) * 100 + '%'; + return item; }); - this.nutritionFoodList = res.data.nutritionFoodList; + _this.nutritionFoodList = res.data.nutritionFoodList; } + if (res.data.recipeFoodNotMadeList && res.data.recipeFoodNotMadeList.length) { - this.recipeFoodNotMadeList = res.data.recipeFoodNotMadeList; + _this.recipeFoodNotMadeList = res.data.recipeFoodNotMadeList; } + + // 处理已出菜品列表 if (res.data.recipeFoodProducedList && res.data.recipeFoodProducedList.length) { - res.data.recipeFoodProducedList.map(item => { - item.foodWeight_kg = Math.round(item.foodWeight / 10) / 100; + res.data.recipeFoodProducedList.map(function(item) { + item.foodWeight_kg = Math.round(item.foodWeight / 10) / 100; + return item; }); - this.recipeFoodProducedList = res.data.recipeFoodProducedList; + _this.recipeFoodProducedList = res.data.recipeFoodProducedList; } } - }).catch(() => {}).finally(() => { - setTimeout(() => { - this.getKitchenInfo(); - }, 10000) - }) + + // 模拟 finally 效果:成功时触发下一次轮询 + setTimeout(function() { + _this.getKitchenInfo(); + }, 10000); + }).catch(function(err) { + console.error("H5 Log: 请求出错", err); + // 模拟 finally 效果:失败时也触发下一次轮询,保证页面不卡死 + setTimeout(function() { + _this.getKitchenInfo(); + }, 10000); + }); } }, mounted() {