sunshibo 11 часов назад
Родитель
Сommit
546511a467
1 измененных файлов с 22 добавлено и 4 удалено
  1. 22 4
      HBuilderProjects/shareCheckIn.html

+ 22 - 4
HBuilderProjects/shareCheckIn.html

@@ -1826,6 +1826,13 @@
 			return (Math.round(n * 10) / 10).toString();
 		}
 
+		/** 店铺评分为 0 / 0.0 时视为暂无评价 */
+		function isZeroStoreRating(score) {
+			if (score === '' || score == null) return false;
+			var n = Number(score);
+			return !isNaN(n) && n <= 0;
+		}
+
 		var STAR_PATH_D = 'M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z';
 
 		function createStarSvg(className) {
@@ -1940,9 +1947,9 @@
 			var poiScore = getMergedParam('scoreAvg') || q('scoreAvg');
 			if (poiScore === '') poiScore = getMergedParam('poiScore') || getMergedParam('storeRating') || q('poiScore') || q('storeRating');
 			if (poiScore === '' && item && item.scoreAvg != null) poiScore = String(item.scoreAvg);
-			var starText = formatStar(poiScore);
+			var poiScoreLabel = isZeroStoreRating(poiScore) ? '暂无评价' : formatStar(poiScore) + '星';
 			document.getElementById('checkInPoiLine').textContent =
-				(poiName || '—') + ' · ' + starText + '星';
+				(poiName || '—') + ' · ' + poiScoreLabel;
 
 			buildDynSlides(collectImageUrlsFromUrl());
 
@@ -1957,8 +1964,19 @@
 			if (sAvg === '' && item && item.scoreAvg != null) sAvg = String(item.scoreAvg);
 			if (sAvg === '') sAvg = '4.9';
 			var sn = Number(sAvg);
-			document.getElementById('storeScore').textContent = !isNaN(sn) ? sn.toFixed(1) : sAvg;
-			applyStoreStarsRow(isNaN(sn) ? 0 : sn);
+			var elStoreScore = document.getElementById('storeScore');
+			var elStoreStars = document.getElementById('storeStarsRow');
+			if (isZeroStoreRating(sAvg)) {
+				if (elStoreScore) elStoreScore.textContent = '暂无评价';
+				if (elStoreStars) {
+					elStoreStars.innerHTML = '';
+					elStoreStars.style.display = 'none';
+				}
+			} else {
+				if (elStoreScore) elStoreScore.textContent = !isNaN(sn) ? sn.toFixed(1) : sAvg;
+				if (elStoreStars) elStoreStars.style.display = '';
+				applyStoreStarsRow(isNaN(sn) ? 0 : sn);
+			}
 
 			var rc = getMergedParam('ratingCount') || q('ratingCount');
 			if (rc === '' && item && item.ratingCount != null) rc = String(item.ratingCount);