shish 14 ساعت پیش
والد
کامیت
38a47e0f6b
1فایلهای تغییر یافته به همراه35 افزوده شده و 27 حذف شده
  1. 35 27
      hdApp/src/admin/billing/affirmSh.vue

+ 35 - 27
hdApp/src/admin/billing/affirmSh.vue

@@ -447,31 +447,25 @@ export default {
 			const method = this.currentShMethod
 			return parseFloat(Number(method && method.unMeetFee) || 0)
 		},
-		/** 未达标红色文案:加运费/包装费金额,或不能下单 */
+		/**
+		 * 未达标红色文案:用「还差」差额引导加购,比写绝对门槛更易懂
+		 * 例:还差2扎50元,免10元包装费 / 还差2扎,即可下单
+		 */
 		shMethodUnMeetWarningText() {
 			const method = this.currentShMethod
 			if (!method) {
 				return ""
 			}
-			const tips = []
-			const minAmount = Number(method.minAmount) || 0
-			const minNum = Number(method.minNum) || 0
-			if (minAmount > 0) {
-				tips.push("未满" + minAmount + "元")
-			}
-			if (minNum > 0) {
-				tips.push("未满" + minNum + "扎")
-			}
-			const conditionText = tips.length > 0 ? tips.join("并且") : "未达最低消费"
+			const lackText = this.buildShMethodLackTip(method)
 			const unMeet = Number(method.unMeet) || 0
-			// unMeet=2:未满最低消费时引导加购,文案避免生硬的「不能下单」
+			// unMeet=2:凑齐差额即可下单
 			if (unMeet === 2) {
-				return conditionText + ",请再加购后下单"
+				return lackText + ",即可下单"
 			}
-			// unMeet=0 加运费;unMeet=1 加包装费,并写出具体金额
+			// unMeet=0/1:凑齐后可免掉这笔运费/包装费
 			const fee = parseFloat(Number(method.unMeetFee) || 0)
 			const feeLabel = unMeet === 1 ? "包装费" : "运费"
-			return conditionText + ",加" + feeLabel + fee + "元"
+			return lackText + ",免" + fee + "元" + feeLabel
 		},
 		currentMethodExplains() {
 			const method = this.currentShMethod
@@ -641,6 +635,30 @@ export default {
 			const bigLength = Number(this.allCountFun.bigLength) || 0
 			return (minAmount > 0 && allPrice < minAmount) || (minNum > 0 && bigLength < minNum)
 		},
+		/**
+		 * 相对配送方式最低消费,拼出「还差x扎x元」文案(只写仍未达到的维度)
+		 * @param {Object} method - 当前配送方式
+		 * @returns {string}
+		 */
+		buildShMethodLackTip(method) {
+			const minAmount = Number(method && method.minAmount) || 0
+			const minNum = Number(method && method.minNum) || 0
+			const count = Number(this.allCountFun.bigLength) || 0
+			const price = Number(this.allPriceFun) || 0
+			const lackNum = minNum > 0 ? Math.max(0, minNum - count) : 0
+			const lackAmount = minAmount > 0 ? Math.max(0, parseFloat((minAmount - price).toFixed(2))) : 0
+			const parts = []
+			if (lackNum > 0) {
+				parts.push(lackNum + "扎")
+			}
+			if (lackAmount > 0) {
+				parts.push(lackAmount + "元")
+			}
+			if (!parts.length) {
+				return "未达最低消费"
+			}
+			return "还差" + parts.join("")
+		},
 		/** 按列表下标切换配送方式,并同步 sendType 供下单与条件展示 */
 		selectMethodByIndex(index) {
 			const list = this.visibleMethodList
@@ -1107,18 +1125,8 @@ export default {
 				}
 				const method = this.currentShMethod
 				if (method && Number(method.unMeet) === 2 && this.checkShMethodBelowMinimum(method)) {
-					// 未满最低消费且不可下单时,提示具体需要的最低金额与数量
-					const minAmount = Number(method.minAmount) || 0
-					const minNum = Number(method.minNum) || 0
-					const tips = []
-					if (minAmount > 0) {
-						tips.push(`满${minAmount}元`)
-					}
-					if (minNum > 0) {
-						tips.push(`满${minNum}扎`)
-					}
-					const tipStr = tips.length > 0 ? `${tips.join("并且")},请加购后下单` : "未达到最低消费,请再加购后下单"
-					this.$msg(tipStr)
+					// 与页面红色提示一致:用还差差额引导加购
+					this.$msg(this.buildShMethodLackTip(method) + ",即可下单")
 					return false
 				}