Browse Source

小程序食堂只显示有内容的榜单

wrh 2 years ago
parent
commit
2db89729d9

+ 8 - 2
nngkxxdp/src/main/resources/static/nnzwminiapp/pages/deliciousList/deliciousList.js

@@ -25,7 +25,13 @@ Page({
 			url: '/mini/canteen/getDeliciousList',
 			method: 'GET'
 		}).then(res => {
+			let temp = [];
 			res.data.forEach(element => {
+				if (element.deliciousList.length > 0) {
+					temp.push(element);
+				}
+			})
+			temp.forEach(element => {
 				element.deliciousList.forEach(item => {
 					if (item.dishesPic) {
 						wx.getImageInfo({
@@ -33,7 +39,7 @@ Page({
 							fail() {
 								item.dishesPic = '';
 								that.setData({
-									canteenList: res.data
+									canteenList: temp
 								})
 							}
 						});
@@ -41,7 +47,7 @@ Page({
 				});
 			});
 			this.setData({
-				canteenList: res.data
+				canteenList: temp
 			})
 		})
 	},