shish 1 месяц назад
Родитель
Сommit
febc2a9422
1 измененных файлов с 39 добавлено и 8 удалено
  1. 39 8
      hdApp/src/admin/member/level.vue

+ 39 - 8
hdApp/src/admin/member/level.vue

@@ -3,7 +3,6 @@
 		<view class="page-header">
 			<view class="page-title">会员等级设置</view>
 			<view class="page-subtitle">充值或消费1元等于1个成长值,余额消费没有成长值</view>
-			<view class="title-decor"></view>
 		</view>
 		<view class="main-content">
 			<view class="table-head">
@@ -42,6 +41,8 @@
 								class="discount-inp"
 								placeholder="8.8"
 								placeholder-style="color:#cccccc"
+								:focus="focusDiscountIndex === index"
+								@blur="onDiscountBlur"
 							/>
 							<text class="discount-unit">折</text>
 							<view class="discount-close" @click="disableDiscount(index)">
@@ -89,7 +90,9 @@ export default {
 	data() {
 		return {
 			map: [],
-			reduceDay: 30
+			reduceDay: 30,
+			// 开启折扣后要聚焦的输入框下标,-1 表示不聚焦
+			focusDiscountIndex: -1
 		};
 	},
 	methods: {
@@ -127,10 +130,26 @@ export default {
 			if (!this.map[index].discount || Number(this.map[index].discount) >= 10) {
 				this.$set(this.map[index], 'discount', '');
 			}
+			// 先重置再 nextTick 设焦点,兼容小程序 :focus 需 false→true 切换
+			this.focusDiscountIndex = -1;
+			this.$nextTick(() => {
+				this.focusDiscountIndex = index;
+			});
 		},
 		disableDiscount(index) {
 			this.$set(this.map[index], 'discountEnabled', false);
 			this.$set(this.map[index], 'discount', 10);
+			this.focusDiscountIndex = -1;
+		},
+		onDiscountBlur() {
+			this.focusDiscountIndex = -1;
+		},
+		// 取提交/校验用的有效折扣:未开启视为 10 折(无优惠)
+		getEffectiveDiscount(item) {
+			if (!item.discountEnabled) {
+				return 10;
+			}
+			return parseFloat(item.discount);
 		},
 		getSubmitData() {
 			return this.map.map(item => {
@@ -186,6 +205,18 @@ export default {
 				this.$msg('开启折扣后请输入小于10的有效折扣');
 				return false;
 			}
+			// 等级越高,折扣数值须 ≤ 上一等级(如上一级 9.5 折,本级最高只能 9.5 折)
+			for (let i = 1; i < this.map.length; i++) {
+				const prevItem = this.map[i - 1];
+				const currItem = this.map[i];
+				const prevDiscount = this.getEffectiveDiscount(prevItem);
+				const currDiscount = this.getEffectiveDiscount(currItem);
+				if (currDiscount > prevDiscount) {
+					const prevLabel = prevItem.discountEnabled ? `${prevDiscount}折` : '无折扣';
+					this.$msg(`${currItem.name}的折扣不能高于${prevItem.name}(${prevLabel})`);
+					return false;
+				}
+			}
 			const hasLongBenefit = this.map.some(item => (item.birthdayBenefit || '').length > 50);
 			if (hasLongBenefit) {
 				this.$msg('生日权益不超过50字');
@@ -223,7 +254,7 @@ export default {
 		letter-spacing: 2upx;
 	}
 	.page-subtitle {
-		font-size: 22upx;
+		font-size: 28upx;
 		color: #a5aaa8;
 		text-align: center;
 		margin-top: 12upx;
@@ -325,8 +356,8 @@ export default {
 	background: linear-gradient(90deg, #67d85a, #41b94e);
 	color: #fff;
 	padding: 0 14upx;
-	border-radius: 24upx;
-	font-size: 24upx;
+	border-radius: 20upx;
+	font-size: 28upx;
 	font-weight: 600;
 	box-shadow: 0 4upx 10upx rgba(67, 183, 78, 0.2);
 	box-sizing: border-box;
@@ -342,7 +373,7 @@ export default {
 	border: 1upx solid #edf0ed;
 	border-radius: 8upx;
 	padding: 0 8upx;
-	font-size: 26upx;
+	font-size: 32upx;
 	font-weight: 600;
 	color: #368753;
 	text-align: center;
@@ -378,14 +409,14 @@ export default {
 	min-width: 0;
 	height: 100%;
 	line-height: 54upx;
-	font-size: 26upx;
+	font-size: 30upx;
 	font-weight: 600;
 	color: #368753;
 	text-align: center;
 }
 .discount-unit {
 	flex-shrink: 0;
-	font-size: 22upx;
+	font-size: 28upx;
 	color: #368753;
 	margin-left: 2upx;
 }