From 223c331985684683964b9bf9816d9fb3fb0d557b Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Wed, 15 Apr 2026 20:28:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=87=91=E5=B8=81=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2):=20=E5=81=9A=E4=B8=A4=E7=A7=8D=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/ar.json | 3 +- src/locales/bn.json | 3 +- src/locales/en.json | 3 +- src/locales/tr.json | 3 +- src/locales/zh.json | 3 +- src/views/RechargeAgency/index.vue | 69 +++++++++++++++++++++++++----- 6 files changed, 68 insertions(+), 16 deletions(-) diff --git a/src/locales/ar.json b/src/locales/ar.json index 016778f..0abda73 100644 --- a/src/locales/ar.json +++ b/src/locales/ar.json @@ -96,7 +96,8 @@ "search_user": "البحث عن المستخدم", "enter_user_id": "يرجى إدخال id المستخدم", "recharge": "شحن", - "enter_recharge_amount": "أدخل مبلغ الدولارات المراد شحنه للمستخدم.", + "enter_recharge_amount": "أدخل عدد القطع النقدية التي تريد إيداعها على المستخدم.", + "enter_recharge_dollar_amount": "أدخل مبلغ الدولارات المراد شحنه للمستخدم.", "recharge_auto_convert_tip": "تحويل تلقائي لعدد العملات الذهبية المطلوبة للشحن.", "recharge_ratio_text": "*$1={ratio} عملة", "recharge_now": "شحن الآن", diff --git a/src/locales/bn.json b/src/locales/bn.json index 91d38b6..6adf99d 100644 --- a/src/locales/bn.json +++ b/src/locales/bn.json @@ -96,7 +96,8 @@ "search_user": "ব্যবহারকারী অনুসন্ধান", "enter_user_id": "দয়া করে ব্যবহারকারী আইডি লিখুন", "recharge": "রিচার্জ", - "enter_recharge_amount": "ব্যবহারকারীকে রিচার্জ করার ডলারের পরিমাণ লিখুন।", + "enter_recharge_amount": "ব্যবহারকারীকে রিচার্জ করার মুদ্রার পরিমাণ লিখুন।", + "enter_recharge_dollar_amount": "ব্যবহারকারীকে রিচার্জ করার ডলারের পরিমাণ লিখুন।", "recharge_auto_convert_tip": "রিচার্জের জন্য প্রয়োজনীয় গোল্ড কয়েন স্বয়ংক্রিয়ভাবে রূপান্তর করা হবে।", "recharge_ratio_text": "*$1={ratio} কয়েন", "recharge_now": "এখন রিচার্জ করুন", diff --git a/src/locales/en.json b/src/locales/en.json index bbe6f35..0ac4ac9 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -96,7 +96,8 @@ "search_user": "Search user", "enter_user_id": "Please enter the user ID", "recharge": "Recharge", - "enter_recharge_amount": "Enter the amount of Dollars to be recharged to the user.", + "enter_recharge_amount": "Enter the amount of coins to be recharged to the user.", + "enter_recharge_dollar_amount": "Enter the amount of Dollars to be recharged to the user.", "recharge_auto_convert_tip": "Autoconvert the gold coins needed for recharge.", "recharge_ratio_text": "*$1={ratio}coins", "recharge_now": "Recharge now", diff --git a/src/locales/tr.json b/src/locales/tr.json index 8fe151c..3cea25c 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -96,7 +96,8 @@ "search_user": "Kullanıcı ara", "enter_user_id": "Lütfen kullanıcı ID'sini girin", "recharge": "Yükle", - "enter_recharge_amount": "Kullanıcıya yüklenecek Dolar miktarını girin.", + "enter_recharge_amount": "Kullanıcıya yüklenecek coin miktarını girin.", + "enter_recharge_dollar_amount": "Kullanıcıya yüklenecek Dolar miktarını girin.", "recharge_auto_convert_tip": "Yükleme için gereken altın coin miktarı otomatik olarak dönüştürülür.", "recharge_ratio_text": "*$1={ratio} coin", "recharge_now": "Şimdi yükle", diff --git a/src/locales/zh.json b/src/locales/zh.json index e703f35..3f54984 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -96,7 +96,8 @@ "search_user": "搜索用户", "enter_user_id": "请输入用户id", "recharge": "充值", - "enter_recharge_amount": "请输入要向用户充值的美元金额。", + "enter_recharge_amount": "请输入要向用户充值的硬币数量。", + "enter_recharge_dollar_amount": "请输入要向用户充值的美元金额。", "recharge_auto_convert_tip": "自动换算本次充值所需的金币数量。", "recharge_ratio_text": "*$1={ratio}金币", "recharge_now": "现在充值", diff --git a/src/views/RechargeAgency/index.vue b/src/views/RechargeAgency/index.vue index 9b8c8a4..f4d9915 100644 --- a/src/views/RechargeAgency/index.vue +++ b/src/views/RechargeAgency/index.vue @@ -198,12 +198,15 @@ background-color: white; padding: 10px 16px; border-radius: 12px; + margin-bottom: 16px; box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25); " > -
+
{ + return ( + freightThreshold.value && + Object.prototype.hasOwnProperty.call(freightThreshold.value, 'rechargeRatio') + ) +}) // 选项样式 const amountStyle = (amountItem) => { @@ -561,12 +573,29 @@ const currentCoinBalance = computed(() => { const rechargeDollarAmount = computed(() => { return Number(rechargeAmount.value) || 0 }) +const maxRechargeDollarAmount = computed(() => { + const ratio = Number(rechargeRatio.value) || 0 + if (ratio <= 0) { + return 0 + } + + return Math.floor(currentCoinBalance.value / ratio) +}) const rechargeCoinsNeeded = computed(() => { return rechargeDollarAmount.value * (Number(rechargeRatio.value) || 0) }) // 是否可以充值 const canRecharge = computed(() => { + if (!hasRechargeRatio.value) { + return ( + selectedUser.value.id && + rechargeAmount.value && + rechargeDollarAmount.value > 0 && + !isRecharging.value + ) + } + return ( selectedUser.value.id && rechargeAmount.value && @@ -590,6 +619,19 @@ const preventDecimalInput = (event) => { value = '' } + // 根据模式自动限制输入的最大值 + if (value !== '') { + const numericValue = parseInt(value) + + if (hasRechargeRatio.value) { + if (numericValue > maxRechargeDollarAmount.value) { + value = maxRechargeDollarAmount.value > 0 ? String(maxRechargeDollarAmount.value) : '' + } + } else if (numericValue > currentCoinBalance.value) { + value = currentCoinBalance.value > 0 ? String(currentCoinBalance.value) : '' + } + } + // 更新输入框的值 event.target.value = value @@ -617,7 +659,7 @@ const rechargeNow = useThrottle(async () => { return } - if (quantity <= 0 || quantity > currentCoinBalance.value) { + if (hasRechargeRatio.value && (quantity <= 0 || quantity > currentCoinBalance.value)) { return } @@ -631,11 +673,16 @@ const rechargeNow = useThrottle(async () => { try { isRecharging.value = true - const rechargeData = { - acceptUserId: acceptUserId, - quantity: quantity, - amount: amount, - } + const rechargeData = hasRechargeRatio.value + ? { + acceptUserId: acceptUserId, + quantity: amount, + amount: quantity, + } + : { + acceptUserId: acceptUserId, + quantity: amount, + } const response = await freightRecharge(rechargeData) @@ -647,7 +694,7 @@ const rechargeNow = useThrottle(async () => { showSuccess( t('transfer_coin_success', { - amount: quantity, + amount: hasRechargeRatio.value ? quantity : amount, name: selectedUser.value.name, }), ) @@ -657,7 +704,7 @@ const rechargeNow = useThrottle(async () => { } else { showError( t('transfer_coin_failed', { - amount: quantity, + amount: hasRechargeRatio.value ? quantity : amount, }), ) } @@ -666,7 +713,7 @@ const rechargeNow = useThrottle(async () => { showError( error.response.errorMsg || t('transfer_coin_failed', { - amount: quantity, + amount: hasRechargeRatio.value ? quantity : amount, }), ) } finally {