| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 | <!-- 消费分充值 --><template>	<s-layout :title="t('wallet.points_recharge')">		<view class="bg-white ss-modal-box ss-flex-col">			<!-- 提现金额 -->			<view class="modal-content ss-m-t-30">				<uni-forms :model="state.model" :rules="state.rules" validateTrigger="bind" labelPosition="left" border					class="form-box" labelWidth='200' ref="FormRef">					<view class="bg-white ss-p-x-30">						<uni-forms-item name="quota" :label="t('wallet.recharge_amount')" :required="true">							<uni-easyinput v-model="state.payPrice" type="number" :placeholder="t('wallet.enter_recharge_amount')"								:inputBorder="false" :clearable="false" @input="validateInput" :maxlength="9" />						</uni-forms-item>						<uni-forms-item name="quota" :label="t('wallet.actual_points_received')">							<view class="ss-flex ss-h-100">								{{consumption}}							</view>						</uni-forms-item>					</view>				</uni-forms>				<view class="ss-flex ss-row-center ss-col-center ss-m-t-30 text-red text-center">				{{ t('wallet.note_recharge_bonus',{amount:state.percentage.triggerMagnificationPoints,multiplier:parseFloat(state.percentage.consumptionMagnification)}) }}				</view>			</view>			<view class="modal-footer ss-flex ss-row-center ss-col-center ss-m-t-80 ss-m-b-40 ss-flex-5">				<button class="ss-reset-button save-btn" @tap="submit">					{{ t('common.confirm') }}				</button>			</view>		</view>	</s-layout></template><script setup>	import {		computed,		reactive,		watchEffect,		nextTick,		onUnmounted	} from 'vue';	import {		onLoad	} from '@dcloudio/uni-app';	import sheep from '@/sheep';	import {		clone	} from 'lodash';	import {		fen2yuan,		points2point	} from '@/sheep/hooks/useGoods';	import md5 from 'blueimp-md5';	import PayWalletApi from '@/sheep/api/pay/wallet';	import WithdrawalApi from '@/sheep/api/distri/withdrawal';	import {		showAuthModal,		showShareModal	} from '@/sheep/hooks/useModal';	import { t } from '@/locale'	const userWallet = computed(() => sheep.$store('user').userWallet);	const userInfo = computed(() => sheep.$store('user').userInfo);	const state = reactive({		model: {},		payPrice: undefined,		percentage: {			consumptionMagnification: 0,			userTopUpConsumptionPoints: 0,			triggerMagnificationPoints: 0		}	});	const consumption = computed(() => {		if (!state.payPrice) {			return 0;		}		let result;		if (state.payPrice >= parseFloat(state.percentage.triggerMagnificationPoints)) {			result = (parseFloat(state.percentage.consumptionMagnification) * state.payPrice).toFixed(2)		} else {			result = state.payPrice		}		return result;	});	// 确保输入是整数	async function validateInput(value) {		const intValue = parseInt(value);		const strPoints = value.toString()		const [integerPart, decimalPart] = strPoints.split('.')		if (decimalPart) {			nextTick(() => {				// state.payPrice = integerPart;			});		}	}	const submit = async () => {		if (!state.payPrice) {			sheep.$helper.toast(t('wallet.enter_recharge_amount'));			return;		}		if (parseFloat(state.payPrice) < state.percentage.userTopUpConsumptionPoints) {			sheep.$helper.toast(t('wallet.recharge_amount_less_than',{point:state.percentage.userTopUpConsumptionPoints}));			return;		}		let {			code,			data		} = await PayWalletApi.topupConsumptionPointsCreate({			payPrice: state.payPrice,			topUpConsumptionPoints: state.payPrice,			userName: userInfo.value.username,		});		if (code === 0) {			sheep.$router.redirect('/pages/pay/index', {				id: data.payOrderId,				type: 2			});		}	};	const getpercentage = async () => {		const {			code,			data		} = await WithdrawalApi.getWithdrawalPercentage();		if (code === 0) {			state.percentage = data;		}	}	onLoad(async (options) => {		await getpercentage();	});</script><style lang="scss" scoped>	.all-btn {		height: 60rpx;		line-height: 60rpx;		min-width: 80rpx;		padding: 0 30rpx;		border-radius: 30rpx;		font-size: 26rpx;		margin-right: 10rpx;		border: 2rpx solid var(--ui-BG-Main);		color: var(--ui-BG-Main);	}	.out-icon {		width: 36rpx;		height: 36rpx;		margin-right: 26rpx;	}	.ss-modal-box {		height: calc(100vh - 88rpx);		// max-height: 1000rpx;		.input-money {			width: 90%;			padding: 0 10rpx;			// text-indent: 20rpx;			height: 80rpx;			border: 1px solid #bbbbbb;			border-radius: 10rpx;			margin: 15rpx auto;			font-size: 28rpx;			input {				width: 100%;				height: 100%;				font-size: 28rpx;			}		}		.modal-header {			position: relative;			padding: 60rpx 20rpx 40rpx;			.money-text {				color: $red;				font-size: 46rpx;				font-weight: bold;				font-family: OPPOSANS;				&::before {					content: '¥';					font-size: 30rpx;				}			}			.time-text {				font-size: 26rpx;				color: $gray-b;			}			.close-icon {				position: absolute;				top: 10rpx;				right: 20rpx;				font-size: 46rpx;				opacity: 0.2;			}		}		.modal-content {			overflow-y: auto;			.out-title {				font-size: 26rpx;				font-weight: 500;				color: #333333;			}			.out-tip {				font-size: 26rpx;				color: #bbbbbb;			}			.out-item {				height: 86rpx;			}			.disabled-out-item {				.out-title {					color: #999999;				}			}			.userInfo-money {				font-size: 26rpx;				color: #bbbbbb;				line-height: normal;			}		}		.save-btn {			width: 710rpx;			height: 80rpx;			border-radius: 40rpx;			background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));			color: $white;		}		.disabled-btn {			background: #e5e5e5;			color: #999999;		}		.past-due-btn {			width: 710rpx;			height: 80rpx;			border-radius: 40rpx;			background-color: #999;			color: #fff;		}	}</style>
 |