| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 | 
							- <!-- 订单确认的使用积分弹窗 -->
 
- <template>
 
- 	<su-popup :show="show" type="bottom" round="10" @close="emits('close')" showClose backgroundColor="#ffffff">
 
- 		<view class="title ss-m-t-16 ss-m-l-20 ss-flex">使用积分</view>
 
- 		<view class="model-box ss-p-x-30">
 
- 			<input v-model.number="state.points" class="uni-input input-points ss-m-b-10" type="number"
 
- 				placeholder="请输入抵扣积分" oninput="this.value=this.value.replace(/\D/g);" :disabled="state.disabled"/>
 
- 			<view class="subtitle">您的可用积分 {{currentMemberPoints}}</view>
 
- 			<view class="subtitle">当前订单价格¥{{state.currentTotalPrice}},可使用的最高积分 {{canUesPoint}}
 
- 			</view>
 
- 			
 
- 		</view>
 
- 		<view class="modal-footer ss-flex">
 
- 			<button class="confirm-btn ss-reset-button"
 
- 				@tap="state.points = 0;emits('confirm', state.points)">取消</button>
 
- 			<button class="confirm-btn ss-reset-button" @tap="onConfirm">确认</button>
 
- 		</view>
 
- 	</su-popup>
 
- </template>
 
- <script setup>
 
- 	import {
 
- 		computed,
 
- 		reactive,
 
- 		ref,
 
- 		watch,
 
- 		nextTick,
 
- 		watchEffect
 
- 	} from 'vue';
 
- 	const props = defineProps({
 
- 		modelValue: { // 优惠劵列表
 
- 			type: Object,
 
- 			default () {},
 
- 		},
 
- 		show: {
 
- 			type: Boolean,
 
- 			default: false,
 
- 		},
 
- 		currentMemberPoints: {
 
- 			type: Number,
 
- 			default: 0
 
- 		},
 
- 		currentTotalPrice: {
 
- 			type: Number,
 
- 			default: 0
 
- 		},
 
- 	});
 
- 	const emits = defineEmits(['confirm', 'close']);
 
- 	const state = reactive({
 
- 		currentMemberPoints: parseFloat(props.currentMemberPoints),
 
- 		currentTotalPrice: parseFloat(props.currentTotalPrice),
 
- 		points: 0,
 
- 		disabled:false
 
- 	});
 
- 	// 当前可使用的最高积分 是当前的总价格 - 1块钱 并且积分只能是正数
 
- 	const canUesPoint = computed(()=>{
 
- 		return parseInt(state.currentTotalPrice - 1)
 
- 	})
 
- 	watchEffect(() => {
 
- 		// 使用积分不能大于可用积分
 
- 		if (state.points > state.currentMemberPoints) {
 
- 			state.points = state.currentMemberPoints; 
 
- 			// 使用 nextTick 确保 DOM 更新
 
- 			nextTick(() => {
 
- 				state.points = state.currentMemberPoints;
 
- 			});
 
- 		}
 
- 		// 使用积分不能大于实际价格
 
- 		if (state.points > state.currentTotalPrice) {
 
- 			console.log("newValue", state.points)
 
- 			console.log("state.currentTotalPrice", state.currentTotalPrice)
 
- 			state.points = state.currentTotalPrice; 
 
- 			// 使用 nextTick 确保 DOM 更新
 
- 			nextTick(() => {
 
- 				state.points = canUesPoint.value;
 
- 			});
 
- 		}
 
- 		// 如果计算出来的当前价格等于0 则不给输入
 
- 		if(canUesPoint.value == 0){
 
- 			state.disabled = true
 
- 		}
 
- 	})
 
- 	// 确认
 
- 	const onConfirm = () => {
 
- 		// if (!state.points) {
 
- 		// 	return false
 
- 		// }
 
- 		emits('confirm', state.points);
 
- 	}
 
- </script>
 
- <style lang="scss" scoped>
 
- 	:deep() {
 
- 		.uni-checkbox-input {
 
- 			background-color: var(--ui-BG-Main);
 
- 		}
 
- 		.uni-input-wrapper {
 
- 			width: 100% !important
 
- 		}
 
- 	}
 
- 	.model-box {
 
- 		height: 10vh;
 
- 		text-align: center;
 
- 		font-size: 30rpx;
 
- 		.input-points {
 
- 			text-align: left;
 
- 			text-indent: 20rpx;
 
- 			height: 80rpx;
 
- 			border: 1px solid #bbbbbb;
 
- 			border-radius: 10rpx;
 
- 		}
 
- 	}
 
- 	.title {
 
- 		font-size: 36rpx;
 
- 		height: 80rpx;
 
- 		font-weight: bold;
 
- 		color: #333333;
 
- 	}
 
- 	.subtitle {
 
- 		// font-size: 26rpx;
 
- 		font-weight: 500;
 
- 		color: #333333;
 
- 	}
 
- 	.model-content {
 
- 		height: 15vh;
 
- 	}
 
- 	.modal-footer {
 
- 		width: 100%;
 
- 		height: 120rpx;
 
- 		//   background: #fff;
 
- 	}
 
- 	.confirm-btn {
 
- 		width: 710rpx;
 
- 		margin-left: 20rpx;
 
- 		height: 80rpx;
 
- 		background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
 
- 		border-radius: 40rpx;
 
- 		color: #fff;
 
- 	}
 
- 	.reason-title {
 
- 		font-weight: 600;
 
- 		font-size: 20rpx;
 
- 		line-height: 26rpx;
 
- 		color: #ff0003;
 
- 	}
 
- 	.reason-desc {
 
- 		font-weight: 600;
 
- 		font-size: 20rpx;
 
- 		line-height: 26rpx;
 
- 		color: #434343;
 
- 	}
 
- </style>
 
 
  |